From 8588b55725246d5c3f17f80793b735f2f2778686 Mon Sep 17 00:00:00 2001 From: Aleksandr Kraiz Date: Fri, 31 Mar 2023 17:47:56 +0400 Subject: [PATCH] ESM --- .eslintrc.js | 128 ----- .eslintrc.json | 140 ++++++ jest.config.ts | 15 +- package-lock.json | 466 +++++++----------- package.json | 31 +- src/BalanceGuard.ts | 10 +- src/Orion/bridge/getHistory.ts | 10 +- src/Orion/bridge/swap.ts | 20 +- src/Orion/index.ts | 18 +- src/OrionUnit/Exchange/deposit.ts | 14 +- src/OrionUnit/Exchange/getSwapInfo.ts | 10 +- src/OrionUnit/Exchange/index.ts | 14 +- src/OrionUnit/Exchange/swapLimit.ts | 20 +- src/OrionUnit/Exchange/swapMarket.ts | 20 +- src/OrionUnit/Exchange/withdraw.ts | 14 +- src/OrionUnit/FarmingManager/index.ts | 14 +- src/OrionUnit/index.ts | 16 +- src/__tests__/basic.test.ts | 8 +- src/__tests__/bridge.test.ts | 4 +- src/__tests__/exchangeContract.test.ts | 2 +- src/__tests__/orionAggregator.test.ts | 2 +- src/__tests__/pools.test.ts | 2 +- src/__tests__/priceFeed.test.ts | 2 +- src/__tests__/trading.test.ts | 4 +- src/config/index.ts | 8 +- src/config/schemas/index.ts | 6 +- src/config/schemas/pureChainSchema.ts | 4 +- src/config/schemas/pureEnvSchema.ts | 2 +- src/constants/chains.ts | 2 +- src/constants/exchangesMap.ts | 2 +- src/constants/index.ts | 20 +- src/constants/orderStatuses.ts | 2 +- src/crypt/getDomainData.ts | 6 +- src/crypt/hashCFDOrder.ts | 2 +- src/crypt/hashOrder.ts | 2 +- src/crypt/index.ts | 10 +- src/crypt/signCFDOrder.ts | 18 +- src/crypt/signCFDOrderPersonal.ts | 2 +- src/crypt/signCancelOrder.ts | 10 +- src/crypt/signCancelOrderPersonal.ts | 4 +- src/crypt/signOrder.ts | 18 +- src/crypt/signOrderPersonal.ts | 2 +- src/index.ts | 20 +- src/initOrionUnit.ts | 2 +- src/services/OrionAggregator/index.ts | 38 +- .../schemas/aggregatedOrderbookSchema.ts | 2 +- .../schemas/atomicSwapHistorySchema.ts | 4 +- .../schemas/exchangeInfoSchema.ts | 2 +- src/services/OrionAggregator/schemas/index.ts | 18 +- .../OrionAggregator/schemas/orderSchema.ts | 2 +- .../OrionAggregator/schemas/swapInfoSchema.ts | 2 +- src/services/OrionAggregator/ws/index.ts | 24 +- .../ws/schemas/addressUpdateSchema.ts | 14 +- .../ws/schemas/assetPairConfigSchema.ts | 4 +- .../ws/schemas/assetPairsConfigSchema.ts | 4 +- .../ws/schemas/balancesSchema.ts | 2 +- .../ws/schemas/baseMessageSchema.ts | 2 +- .../ws/schemas/brokerMessageSchema.ts | 4 +- .../ws/schemas/cfdAddressUpdateSchema.ts | 8 +- .../ws/schemas/cfdBalancesSchema.ts | 2 +- .../OrionAggregator/ws/schemas/errorSchema.ts | 4 +- .../ws/schemas/futuresTradeInfoSchema.ts | 2 +- .../OrionAggregator/ws/schemas/index.ts | 22 +- .../ws/schemas/initMessageSchema.ts | 4 +- .../ws/schemas/orderBookSchema.ts | 6 +- .../ws/schemas/pingPongMessageSchema.ts | 4 +- .../ws/schemas/swapInfoSchema.ts | 6 +- .../ws/schemas/unsubscriptionDoneSchema.ts | 4 +- src/services/OrionBlockchain/index.ts | 12 +- .../schemas/adminPoolsListSchema.ts | 2 +- .../schemas/atomicHistorySchema.ts | 2 +- .../schemas/cfdHistorySchema.ts | 2 +- .../OrionBlockchain/schemas/historySchema.ts | 2 +- src/services/OrionBlockchain/schemas/index.ts | 34 +- .../OrionBlockchain/schemas/infoSchema.ts | 2 +- .../schemas/poolsConfigSchema.ts | 4 +- src/services/PriceFeed/index.ts | 10 +- src/services/PriceFeed/schemas/index.ts | 4 +- .../PriceFeed/ws/PriceFeedSubscription.ts | 10 +- src/services/PriceFeed/ws/index.ts | 4 +- .../PriceFeed/ws/schemas/allTickersSchema.ts | 2 +- src/services/PriceFeed/ws/schemas/index.ts | 8 +- src/services/ReferralSystem/index.ts | 4 +- src/services/ReferralSystem/schemas/index.ts | 14 +- src/services/index.ts | 6 +- src/types.ts | 10 +- src/utils/calculateFeeInFeeAsset.ts | 8 +- src/utils/calculateNetworkFee.ts | 4 +- src/utils/calculateNetworkFeeInFeeAsset.ts | 4 +- src/utils/calculateOrionFeeInFeeAsset.ts | 2 +- src/utils/denormalizeNumber.ts | 2 +- src/utils/generateSecret.ts | 4 +- src/utils/getAvailableFundsSources.ts | 2 +- src/utils/getBalance.ts | 8 +- src/utils/getBalances.ts | 6 +- src/utils/index.ts | 34 +- src/utils/isKnownEnv.ts | 4 +- src/utils/isNetworkCodeInEnvironment.ts | 2 +- src/utils/isUppercasedNetworkCode.ts | 4 +- src/utils/isValidChainId.ts | 2 +- src/utils/normalizeNumber.ts | 2 +- tsconfig.json | 96 +--- webpack.config.js => webpack.config.cjs | 24 +- 103 files changed, 745 insertions(+), 905 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 .eslintrc.json rename webpack.config.js => webpack.config.cjs (65%) diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b9e7312..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,128 +0,0 @@ -module.exports = { - ignorePatterns: ['.eslintrc.js'], - env: { - browser: true, - es2021: true, - node: true, - }, - extends: [ - 'standard-with-typescript', - 'eslint:recommended', - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:@typescript-eslint/recommended-requiring-type-checking', - 'plugin:@typescript-eslint/strict', - 'plugin:import/recommended', - 'plugin:import/typescript' - ], - parser: '@typescript-eslint/parser', - parserOptions: { - tsconfigRootDir: __dirname, - project: [ - "./tsconfig.json" - ], - ecmaVersion: 2021, - sourceType: 'module', - }, - plugins: [ - '@typescript-eslint', - ], - rules: { - "@typescript-eslint/consistent-type-imports": [ - "error", - { - "fixStyle": "separate-type-imports", - "disallowTypeAnnotations": true - } - ], - "@typescript-eslint/strict-boolean-expressions": [ - "error", - { - "allowNullableObject": true, - "allowString": false, - "allowNumber": false, - "allowNullableBoolean": false, - "allowNullableString": false, - "allowNullableNumber": false, - "allowAny": false, - "allowNullableEnum": false - } - ], - "eqeqeq": "error", - "@typescript-eslint/consistent-type-definitions": [ - "warn", - "type" - ], - "@typescript-eslint/indent": [ - "error", - 2, - { - "SwitchCase": 1, - "ignoredNodes": [ - "TSTypeParameterInstantiation" - ] - } - ], - "@typescript-eslint/promise-function-async": 0, - "import/no-cycle": "error", - "@typescript-eslint/space-before-function-paren": 0, - "@typescript-eslint/comma-dangle": 0, - "@typescript-eslint/semi": 0, - "comma-dangle": 0, - "semi": 0, - "space-before-function-paren": 0, - "@typescript-eslint/explicit-function-return-type": 0, - "no-param-reassign": [ - "error", - { - "props": true, - "ignorePropertyModificationsFor": ["acc", "prev"] - } - ], - "camelcase": "off", - '@typescript-eslint/consistent-type-assertions': [ - 'error', - { - assertionStyle: 'never', - }, - ], - 'import/max-dependencies': [ - 'error', - { - max: 20, - ignoreTypeImports: false, - }, - ], - 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': 'error', - 'no-shadow': 'off', - '@typescript-eslint/no-shadow': ['error'], - 'max-len': [ - 1, - 140, - 2, - { - ignoreComments: true, - ignoreUrls: true, - ignoreTemplateLiterals: true, - } - ], - 'import/extensions': [ - 'error', - 'ignorePackages', - { - js: 'never', - jsx: 'never', - ts: 'never', - tsx: 'never', - }, - ], - }, - settings: { - 'import/resolver': { - node: { - extensions: ['.js', '.jsx', '.ts', '.tsx'], - }, - }, - }, -}; diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..4079548 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,140 @@ +{ + "ignorePatterns": [ + ".eslintrc.js" + ], + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "extends": [ + "standard-with-typescript", + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "plugin:@typescript-eslint/strict" + // "plugin:import/recommended", + // "plugin:import/typescript" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "tsconfigRootDir": ".", + "project": [ + "./tsconfig.json" + ], + "ecmaVersion": 2020, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/consistent-type-imports": [ + "error", + { + "fixStyle": "separate-type-imports", + "disallowTypeAnnotations": true + } + ], + "@typescript-eslint/strict-boolean-expressions": [ + "error", + { + "allowNullableObject": true, + "allowString": false, + "allowNumber": false, + "allowNullableBoolean": false, + "allowNullableString": false, + "allowNullableNumber": false, + "allowAny": false, + "allowNullableEnum": false + } + ], + "eqeqeq": "error", + "@typescript-eslint/consistent-type-definitions": [ + "warn", + "type" + ], + "@typescript-eslint/indent": [ + "error", + 2, + { + "SwitchCase": 1, + "ignoredNodes": [ + "TSTypeParameterInstantiation" + ] + } + ], + "@typescript-eslint/promise-function-async": 0, + // "import/no-cycle": "error", + "@typescript-eslint/space-before-function-paren": 0, + "@typescript-eslint/comma-dangle": 0, + "@typescript-eslint/semi": 0, + "comma-dangle": 0, + "semi": 0, + "space-before-function-paren": 0, + "@typescript-eslint/explicit-function-return-type": 0, + "no-param-reassign": [ + "error", + { + "props": true, + "ignorePropertyModificationsFor": [ + "acc", + "prev" + ] + } + ], + "camelcase": "off", + "@typescript-eslint/consistent-type-assertions": [ + "error", + { + "assertionStyle": "never" + } + ], + // "import/max-dependencies": [ + // "error", + // { + // "max": 20, + // "ignoreTypeImports": false + // } + // ], + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "error", + "no-shadow": "off", + "@typescript-eslint/no-shadow": [ + "error" + ], + "max-len": [ + 1, + 140, + 2, + { + "ignoreComments": true, + "ignoreUrls": true, + "ignoreTemplateLiterals": true + } + ] + // "import/extensions": [ + // "error", + // "ignorePackages", + // { + // "js": "never", + // "jsx": "never", + // "ts": "never", + // "tsx": "never" + // } + // ] + }, + "settings": { + "import/resolver": { + "node": { + "extensions": [ + ".js", + ".jsx", + ".ts", + ".tsx" + ] + } + } + } +} \ No newline at end of file diff --git a/jest.config.ts b/jest.config.ts index 8148c2c..a44abbc 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,12 +1,23 @@ import type { JestConfigWithTsJest } from 'ts-jest'; const config: JestConfigWithTsJest = { + extensionsToTreatAsEsm: ['.ts'], + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, preset: 'ts-jest', testEnvironment: 'node', testMatch: ['**/__tests__/**/*.test.ts'], modulePathIgnorePatterns: ['lib', 'node_modules'], transform: { - '^.+\\.ts$': 'ts-jest', - }, + // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest` + // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest` + '^.+\\.tsx?$': [ + 'ts-jest', + { + useESM: true, + }, + ], + }, }; export default config; diff --git a/package-lock.json b/package-lock.json index f35fd69..0c73a86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@babel/runtime": "^7.21.0", "@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/providers": "^5.7.2", - "@lukeed/csprng": "^1.0.1", "@orionprotocol/contracts": "0.6.0", "bignumber.js": "^9.1.1", "bson-objectid": "^2.0.4", @@ -24,7 +23,7 @@ "just-clone": "^6.2.0", "merge-anything": "^5.1.4", "neverthrow": "^6.0.0", - "simple-typed-fetch": "^0.1.4", + "simple-typed-fetch": "^0.1.5", "stream-browserify": "^3.0.0", "tiny-invariant": "^1.3.1", "ts-is-present": "^1.2.2", @@ -34,25 +33,26 @@ "zod": "3.21.4" }, "devDependencies": { - "@babel/core": "^7.21.3", - "@tsconfig/strictest": "^1.0.2", + "@babel/core": "^7.21.4", + "@babel/plugin-syntax-import-assertions": "^7.20.0", + "@tsconfig/esm": "^1.0.2", + "@tsconfig/strictest": "^2.0.0", "@types/express": "^4.17.17", "@types/jest": "^29.5.0", - "@types/node": "^18.15.6", - "@types/node-fetch": "^2.6.2", + "@types/node": "^18.15.11", "@types/socket.io-client": "1.4.33", "@types/uuid": "^9.0.1", "@types/ws": "^8.5.4", - "@typescript-eslint/eslint-plugin": "^5.56.0", - "@typescript-eslint/parser": "^5.56.0", + "@typescript-eslint/eslint-plugin": "^5.57.0", + "@typescript-eslint/parser": "^5.57.0", "babel-loader": "^9.1.2", - "concurrently": "^7.6.0", - "eslint": "^8.35.0", + "concurrently": "^8.0.1", + "eslint": "^8.37.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-standard": "^17.0.0", - "eslint-config-standard-with-typescript": "^34.0.0", + "eslint-config-standard-with-typescript": "^34.0.1", "eslint-plugin-import": "^2.27.5", - "eslint-plugin-n": "^15.6.1", + "eslint-plugin-n": "^15.7.0", "eslint-plugin-promise": "^6.1.1", "http-terminator": "^3.2.0", "husky": "^8.0.3", @@ -60,8 +60,8 @@ "jest": "^29.5.0", "ts-jest": "^29.0.5", "ts-loader": "^9.4.2", - "typescript": "^5.0.2", - "webpack": "^5.76.3", + "typescript": "^5.0.3", + "webpack": "^5.77.0", "webpack-cli": "^5.0.1" }, "engines": { @@ -82,9 +82,9 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", + "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", "dev": true, "dependencies": { "@babel/highlight": "^7.18.6" @@ -94,30 +94,30 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.0.tgz", - "integrity": "sha512-gMuZsmsgxk/ENC3O/fRw5QY8A9/uxQbbCEypnLIiYYc/qVJtEV7ouxC3EllIIwNzMqAQee5tanFabWsUOutS7g==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.4.tgz", + "integrity": "sha512-/DYyDpeCfaVinT40FPGdkkb+lYSKvsVuMjDAG7jPOWWiM1ibOaB9CXJAlc4d1QpP/U2q2P9jbrSlClKSErd55g==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.3.tgz", - "integrity": "sha512-qIJONzoa/qiHghnm0l1n4i/6IIziDpzqc36FBs4pzMhDUraHqponwJLiAKm1hGLP3OSB/TVNz6rMwVGpwxxySw==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.4.tgz", + "integrity": "sha512-qt/YV149Jman/6AfmlxJ04LMIu8bMoyl3RB91yTFrxQmgbrSvQMy7cI8Q62FHx1t8wJ8B5fu0UDoLwHAhUo1QA==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.21.3", - "@babel/helper-compilation-targets": "^7.20.7", + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.4", + "@babel/helper-compilation-targets": "^7.21.4", "@babel/helper-module-transforms": "^7.21.2", "@babel/helpers": "^7.21.0", - "@babel/parser": "^7.21.3", + "@babel/parser": "^7.21.4", "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.3", - "@babel/types": "^7.21.3", + "@babel/traverse": "^7.21.4", + "@babel/types": "^7.21.4", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -133,12 +133,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.3.tgz", - "integrity": "sha512-QS3iR1GYC/YGUnW7IdggFeN5c1poPUurnGttOV/bZgPGV+izC/D8HnD6DLwod0fsatNyVn1G3EVWMYIF0nHbeA==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.4.tgz", + "integrity": "sha512-NieM3pVIYW2SwGzKoqfPrQsf4xGs9M9AIG3ThppsSRmO+m7eQhmI6amajKMUeIO37wFfsvnvcxQFx6x6iqxDnA==", "dev": true, "dependencies": { - "@babel/types": "^7.21.3", + "@babel/types": "^7.21.4", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -162,13 +162,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz", - "integrity": "sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.4.tgz", + "integrity": "sha512-Fa0tTuOXZ1iL8IeDFUWCzjZcn+sJGd9RZdH9esYVjEejGmzf+FFYQpMi/kZUk2kPy/q1H3/GPw7np8qar/stfg==", "dev": true, "dependencies": { - "@babel/compat-data": "^7.20.5", - "@babel/helper-validator-option": "^7.18.6", + "@babel/compat-data": "^7.21.4", + "@babel/helper-validator-option": "^7.21.0", "browserslist": "^4.21.3", "lru-cache": "^5.1.1", "semver": "^6.3.0" @@ -349,9 +349,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.3.tgz", - "integrity": "sha512-lobG0d7aOfQRXh8AyklEAgZGvA4FShxo6xQbUrrT/cNBPUdIDojlokwJsQyCC/eKia7ifqM0yP+2DRZ4WKw2RQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz", + "integrity": "sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -396,6 +396,21 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-import-assertions": { + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.20.0.tgz", + "integrity": "sha512-IUh1vakzNoWalR8ch/areW7qFopR2AEw03JlG7BbrDqmQ4X3q9uuipQwSGrUn7oGiemKjtSLDhNtQHzMHr1JdQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.19.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-import-meta": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", @@ -568,19 +583,19 @@ } }, "node_modules/@babel/traverse": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.3.tgz", - "integrity": "sha512-XLyopNeaTancVitYZe2MlUEvgKb6YVVPXzofHgqHijCImG33b/uTurMS488ht/Hbsb2XK3U2BnSTxKVNGV3nGQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.4.tgz", + "integrity": "sha512-eyKrRHKdyZxqDm+fV1iqL9UAHMoIg0nDaGqfIOd8rKH17m5snv7Gn4qgjBoFfLz9APvjFU/ICT00NVCv1Epp8Q==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.21.3", + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.4", "@babel/helper-environment-visitor": "^7.18.9", "@babel/helper-function-name": "^7.21.0", "@babel/helper-hoist-variables": "^7.18.6", "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.3", - "@babel/types": "^7.21.3", + "@babel/parser": "^7.21.4", + "@babel/types": "^7.21.4", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -589,9 +604,9 @@ } }, "node_modules/@babel/types": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.3.tgz", - "integrity": "sha512-sBGdETxC+/M4o/zKC0sl6sjWv62WFR/uzxrJ6uYyMLZOUlPnwzw0tKgVHOXxaAd5l2g8pEDM5RZ495GPQI77kg==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.4.tgz", + "integrity": "sha512-rU2oY501qDxE8Pyo7i/Orqma4ziCOrby0/9mvbDUGEfvZjb279Nk9k19e2fiCxHbRRpY2ZyrgW1eq22mvmOIzA==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.19.4", @@ -662,14 +677,14 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.0.tgz", - "integrity": "sha512-fluIaaV+GyV24CCu/ggiHdV+j4RNh85yQnAYS/G2mZODZgGmmlrgCydjUcV3YvxCm9x8nMAfThsqTni4KiXT4A==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", + "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.5.1", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -712,9 +727,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.35.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.35.0.tgz", - "integrity": "sha512-JXdzbRiWclLVoD8sNUjR443VVlYqiYmDVT6rGUEIEHU5YJW0gaVZwV2xgM7D4arkvASqD0IlLUVjHiFuxaftRw==", + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", + "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2285,14 +2300,6 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, - "node_modules/@lukeed/csprng": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.0.1.tgz", - "integrity": "sha512-uSvJdwQU5nK+Vdf6zxcWAY2A8r7uqe+gePwLWzJ+fsQehq18pc0I2hJKwypZ2aLM90+Er9u1xn4iLJPZ+xlL4g==", - "engines": { - "node": ">=8" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2357,6 +2364,12 @@ "@sinonjs/commons": "^2.0.0" } }, + "node_modules/@tsconfig/esm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@tsconfig/esm/-/esm-1.0.2.tgz", + "integrity": "sha512-awiISx+G4L+7k97nKnfA5QF6rukawiuycMPfASFHG/0fqjrUlYBuNISy3Yjl1SHIpVi57lYf7dc6L/FoQQCKcA==", + "dev": true + }, "node_modules/@tsconfig/node10": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", @@ -2378,9 +2391,9 @@ "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" }, "node_modules/@tsconfig/strictest": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-1.0.2.tgz", - "integrity": "sha512-IRKlC8cnP7zMz1SDBjyIVyPapkEGWLZ6wkF6Z8T+xU80P9sO5uGXlIUvtzjx+7ehPJRWxkB6CeIDwUfyqNtYkQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.0.tgz", + "integrity": "sha512-E0dpiZNdwO20c8d3seh7OmjAvDpwoRkTcU6M8cvggzB45Bd45tyTU2XJeA5Wfq+8NzVGhunvqOJ30AjSkywMXA==", "dev": true }, "node_modules/@types/babel__core": { @@ -2554,19 +2567,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.15.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.7.tgz", - "integrity": "sha512-LFmUbFunqmBn26wJZgZPYZPrDR1RwGOu2v79Mgcka1ndO6V0/cwjivPTc4yoK6n9kmw4/ls1r8cLrvh2iMibFA==" - }, - "node_modules/@types/node-fetch": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz", - "integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==", - "dev": true, - "dependencies": { - "@types/node": "*", - "form-data": "^3.0.0" - } + "version": "18.15.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz", + "integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==" }, "node_modules/@types/prettier": { "version": "2.7.2", @@ -2645,15 +2648,15 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.56.0.tgz", - "integrity": "sha512-ZNW37Ccl3oMZkzxrYDUX4o7cnuPgU+YrcaYXzsRtLB16I1FR5SHMqga3zGsaSliZADCWo2v8qHWqAYIj8nWCCg==", + "version": "5.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.57.0.tgz", + "integrity": "sha512-itag0qpN6q2UMM6Xgk6xoHa0D0/P+M17THnr4SVgqn9Rgam5k/He33MA7/D7QoJcdMxHFyX7U9imaBonAX/6qA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.56.0", - "@typescript-eslint/type-utils": "5.56.0", - "@typescript-eslint/utils": "5.56.0", + "@typescript-eslint/scope-manager": "5.57.0", + "@typescript-eslint/type-utils": "5.57.0", + "@typescript-eslint/utils": "5.57.0", "debug": "^4.3.4", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", @@ -2720,7 +2723,7 @@ } } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { + "node_modules/@typescript-eslint/scope-manager": { "version": "5.57.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.0.tgz", "integrity": "sha512-NANBNOQvllPlizl9LatX8+MHi7bx7WGIWYjPHDmQe5Si/0YEYfxSljJpoTyTWFTgRy3X8gLYSE4xQ2U+aCozSw==", @@ -2737,103 +2740,14 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { - "version": "5.57.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.0.tgz", - "integrity": "sha512-mxsod+aZRSyLT+jiqHw1KK6xrANm19/+VFALVFP5qa/aiJnlP38qpyaTd0fEKhWvQk6YeNZ5LGwI1pDpBRBhtQ==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { - "version": "5.57.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.0.tgz", - "integrity": "sha512-LTzQ23TV82KpO8HPnWuxM2V7ieXW8O142I7hQTxWIHDcCEIjtkat6H96PFkYBQqGFLW/G/eVVOB9Z8rcvdY/Vw==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.57.0", - "@typescript-eslint/visitor-keys": "5.57.0", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.57.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.0.tgz", - "integrity": "sha512-ery2g3k0hv5BLiKpPuwYt9KBkAp2ugT6VvyShXdLOkax895EC55sP0Tx5L0fZaQueiK3fBLvHVvEl3jFS5ia+g==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.57.0", - "eslint-visitor-keys": "^3.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/parser/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "5.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.56.0.tgz", - "integrity": "sha512-jGYKyt+iBakD0SA5Ww8vFqGpoV2asSjwt60Gl6YcO8ksQ8s2HlUEyHBMSa38bdLopYqGf7EYQMUIGdT/Luw+sw==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.56.0", - "@typescript-eslint/visitor-keys": "5.56.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.56.0.tgz", - "integrity": "sha512-8WxgOgJjWRy6m4xg9KoSHPzBNZeQbGlQOH7l2QEhQID/+YseaFxg5J/DLwWSsi9Axj4e/cCiKx7PVzOq38tY4A==", + "version": "5.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.57.0.tgz", + "integrity": "sha512-kxXoq9zOTbvqzLbdNKy1yFrxLC6GDJFE2Yuo3KqSwTmDOFjUGeWSakgoXT864WcK5/NAJkkONCiKb1ddsqhLXQ==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.56.0", - "@typescript-eslint/utils": "5.56.0", + "@typescript-eslint/typescript-estree": "5.57.0", + "@typescript-eslint/utils": "5.57.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -2854,9 +2768,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.56.0.tgz", - "integrity": "sha512-JyAzbTJcIyhuUhogmiu+t79AkdnqgPUEsxMTMc/dCZczGMJQh1MK2wgrju++yMN6AWroVAy2jxyPcPr3SWCq5w==", + "version": "5.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.0.tgz", + "integrity": "sha512-mxsod+aZRSyLT+jiqHw1KK6xrANm19/+VFALVFP5qa/aiJnlP38qpyaTd0fEKhWvQk6YeNZ5LGwI1pDpBRBhtQ==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2867,13 +2781,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.56.0.tgz", - "integrity": "sha512-41CH/GncsLXOJi0jb74SnC7jVPWeVJ0pxQj8bOjH1h2O26jXN3YHKDT1ejkVz5YeTEQPeLCCRY0U2r68tfNOcg==", + "version": "5.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.0.tgz", + "integrity": "sha512-LTzQ23TV82KpO8HPnWuxM2V7ieXW8O142I7hQTxWIHDcCEIjtkat6H96PFkYBQqGFLW/G/eVVOB9Z8rcvdY/Vw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.56.0", - "@typescript-eslint/visitor-keys": "5.56.0", + "@typescript-eslint/types": "5.57.0", + "@typescript-eslint/visitor-keys": "5.57.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2909,17 +2823,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.56.0.tgz", - "integrity": "sha512-XhZDVdLnUJNtbzaJeDSCIYaM+Tgr59gZGbFuELgF7m0IY03PlciidS7UQNKLE0+WpUTn1GlycEr6Ivb/afjbhA==", + "version": "5.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.57.0.tgz", + "integrity": "sha512-ps/4WohXV7C+LTSgAL5CApxvxbMkl9B9AUZRtnEFonpIxZDIT7wC1xfvuJONMidrkB9scs4zhtRyIwHh4+18kw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.56.0", - "@typescript-eslint/types": "5.56.0", - "@typescript-eslint/typescript-estree": "5.56.0", + "@typescript-eslint/scope-manager": "5.57.0", + "@typescript-eslint/types": "5.57.0", + "@typescript-eslint/typescript-estree": "5.57.0", "eslint-scope": "^5.1.1", "semver": "^7.3.7" }, @@ -2950,12 +2864,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.56.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.56.0.tgz", - "integrity": "sha512-1mFdED7u5bZpX6Xxf5N9U2c18sb+8EvU3tyOIj6LQZ5OOvnmj8BVeNNP603OFPm5KkS1a7IvCIcwrdHXaEMG/Q==", + "version": "5.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.0.tgz", + "integrity": "sha512-ery2g3k0hv5BLiKpPuwYt9KBkAp2ugT6VvyShXdLOkax895EC55sP0Tx5L0fZaQueiK3fBLvHVvEl3jFS5ia+g==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.56.0", + "@typescript-eslint/types": "5.57.0", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -3431,12 +3345,6 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true - }, "node_modules/babel-jest": { "version": "29.5.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.5.0.tgz", @@ -4079,18 +3987,6 @@ "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", "dev": true }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", @@ -4110,27 +4006,27 @@ "dev": true }, "node_modules/concurrently": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-7.6.0.tgz", - "integrity": "sha512-BKtRgvcJGeZ4XttiDiNcFiRlxoAeZOseqUvyYRUp/Vtd+9p1ULmeoSqGsDA+2ivdeDFpqrJvGvmI+StKfKl5hw==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.0.1.tgz", + "integrity": "sha512-Sh8bGQMEL0TAmAm2meAXMjcASHZa7V0xXQVDBLknCPa9TPtkY9yYs+0cnGGgfdkW0SV1Mlg+hVGfXcoI8d3MJA==", "dev": true, "dependencies": { - "chalk": "^4.1.0", - "date-fns": "^2.29.1", + "chalk": "^4.1.2", + "date-fns": "^2.29.3", "lodash": "^4.17.21", - "rxjs": "^7.0.0", - "shell-quote": "^1.7.3", - "spawn-command": "^0.0.2-1", - "supports-color": "^8.1.0", + "rxjs": "^7.8.0", + "shell-quote": "^1.8.0", + "spawn-command": "0.0.2-1", + "supports-color": "^8.1.1", "tree-kill": "^1.2.2", - "yargs": "^17.3.1" + "yargs": "^17.7.1" }, "bin": { "conc": "dist/bin/concurrently.js", "concurrently": "dist/bin/concurrently.js" }, "engines": { - "node": "^12.20.0 || ^14.13.0 || >=16.0.0" + "node": "^14.13.0 || >=16.0.0" }, "funding": { "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" @@ -4431,15 +4327,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -4715,13 +4602,15 @@ } }, "node_modules/eslint": { - "version": "8.35.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.35.0.tgz", - "integrity": "sha512-BxAf1fVL7w+JLRQhWl2pzGeSiGqbWumV4WNvc9Rhp6tiCtm4oHnyPBSEtMGZwrQgudFQ+otqzWoPB7x+hxoWsw==", + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", + "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", "dev": true, "dependencies": { - "@eslint/eslintrc": "^2.0.0", - "@eslint/js": "8.35.0", + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.2", + "@eslint/js": "8.37.0", "@humanwhocodes/config-array": "^0.11.8", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -4732,9 +4621,8 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", + "eslint-visitor-keys": "^3.4.0", + "espree": "^9.5.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -4756,7 +4644,6 @@ "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" @@ -4817,16 +4704,16 @@ } }, "node_modules/eslint-config-standard-with-typescript": { - "version": "34.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-34.0.0.tgz", - "integrity": "sha512-zhCsI4/A0rJ1ma8sf3RLXYc0gc7yPmdTWRVXMh9dtqeUx3yBQyALH0wosHhk1uQ9QyItynLdNOtcHKNw8G7lQw==", + "version": "34.0.1", + "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-34.0.1.tgz", + "integrity": "sha512-J7WvZeLtd0Vr9F+v4dZbqJCLD16cbIy4U+alJMq4MiXdpipdBM3U5NkXaGUjePc4sb1ZE01U9g6VuTBpHHz1fg==", "dev": true, "dependencies": { - "@typescript-eslint/parser": "^5.0.0", + "@typescript-eslint/parser": "^5.43.0", "eslint-config-standard": "17.0.0" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^5.0.0", + "@typescript-eslint/eslint-plugin": "^5.43.0", "eslint": "^8.0.1", "eslint-plugin-import": "^2.25.2", "eslint-plugin-n": "^15.0.0", @@ -4974,9 +4861,9 @@ } }, "node_modules/eslint-plugin-n": { - "version": "15.6.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz", - "integrity": "sha512-R9xw9OtCRxxaxaszTQmQAlPgM+RdGjaL1akWuY/Fv9fRAi8Wj4CUKc6iYVG8QNRjRuo8/BqVYIpfqberJUEacA==", + "version": "15.7.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.7.0.tgz", + "integrity": "sha512-jDex9s7D/Qial8AGVIHq4W7NswpUD5DPDL2RH8Lzd9EloWUuvUkHfv4FRLMipH5q2UtyurorBkPeNi1wVWNh3Q==", "dev": true, "dependencies": { "builtins": "^5.0.1", @@ -5066,12 +4953,15 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", + "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/ansi-styles": { @@ -5206,14 +5096,14 @@ } }, "node_modules/espree": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", - "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", + "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", "dev": true, "dependencies": { "acorn": "^8.8.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -5698,20 +5588,6 @@ "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, - "node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dev": true, - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -9507,9 +9383,9 @@ } }, "node_modules/rxjs": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz", - "integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", + "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", "dev": true, "dependencies": { "tslib": "^2.1.0" @@ -9750,9 +9626,9 @@ } }, "node_modules/shell-quote": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.4.tgz", - "integrity": "sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.0.tgz", + "integrity": "sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==", "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -10438,9 +10314,9 @@ } }, "node_modules/tslib": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", - "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", "dev": true }, "node_modules/tsutils": { @@ -10510,9 +10386,9 @@ } }, "node_modules/typescript": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz", - "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz", + "integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -10658,9 +10534,9 @@ } }, "node_modules/webpack": { - "version": "5.76.3", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.3.tgz", - "integrity": "sha512-18Qv7uGPU8b2vqGeEEObnfICyw2g39CHlDEK4I7NK13LOur1d0HGmGNKGT58Eluwddpn3oEejwvBPoP4M7/KSA==", + "version": "5.77.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.77.0.tgz", + "integrity": "sha512-sbGNjBr5Ya5ss91yzjeJTLKyfiwo5C628AFjEa6WSXcZa4E+F57om3Cc8xLb1Jh0b243AWuSYRf3dn7HVeFQ9Q==", "dev": true, "dependencies": { "@types/eslint-scope": "^3.7.3", @@ -10949,9 +10825,9 @@ "dev": true }, "node_modules/yargs": { - "version": "17.6.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz", - "integrity": "sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==", + "version": "17.7.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz", + "integrity": "sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==", "dev": true, "dependencies": { "cliui": "^8.0.1", diff --git a/package.json b/package.json index 663c2d0..9583dc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.17.38", + "version": "0.18.0", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", @@ -8,6 +8,7 @@ "engines": { "node": ">=18.0.0" }, + "type": "module", "scripts": { "start": "npm run build && node lib/esm/index.js", "develop": "concurrently -i -k -p \"[{name}]\" -n \"Node,TypeScript\" -c \"yellow.bold,cyan.bold\" \"yarn watch-js\" \"yarn watch-ts\"", @@ -42,25 +43,26 @@ "url": "https://github.com/orionprotocol/sdk/issues" }, "devDependencies": { - "@babel/core": "^7.21.3", - "@tsconfig/strictest": "^1.0.2", + "@babel/core": "^7.21.4", + "@babel/plugin-syntax-import-assertions": "^7.20.0", + "@tsconfig/esm": "^1.0.2", + "@tsconfig/strictest": "^2.0.0", "@types/express": "^4.17.17", "@types/jest": "^29.5.0", - "@types/node": "^18.15.6", - "@types/node-fetch": "^2.6.2", + "@types/node": "^18.15.11", "@types/socket.io-client": "1.4.33", "@types/uuid": "^9.0.1", "@types/ws": "^8.5.4", - "@typescript-eslint/eslint-plugin": "^5.56.0", - "@typescript-eslint/parser": "^5.56.0", + "@typescript-eslint/eslint-plugin": "^5.57.0", + "@typescript-eslint/parser": "^5.57.0", "babel-loader": "^9.1.2", - "concurrently": "^7.6.0", - "eslint": "^8.35.0", + "concurrently": "^8.0.1", + "eslint": "^8.37.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-standard": "^17.0.0", - "eslint-config-standard-with-typescript": "^34.0.0", + "eslint-config-standard-with-typescript": "^34.0.1", "eslint-plugin-import": "^2.27.5", - "eslint-plugin-n": "^15.6.1", + "eslint-plugin-n": "^15.7.0", "eslint-plugin-promise": "^6.1.1", "http-terminator": "^3.2.0", "husky": "^8.0.3", @@ -68,15 +70,14 @@ "jest": "^29.5.0", "ts-jest": "^29.0.5", "ts-loader": "^9.4.2", - "typescript": "^5.0.2", - "webpack": "^5.76.3", + "typescript": "^5.0.3", + "webpack": "^5.77.0", "webpack-cli": "^5.0.1" }, "dependencies": { "@babel/runtime": "^7.21.0", "@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/providers": "^5.7.2", - "@lukeed/csprng": "^1.0.1", "@orionprotocol/contracts": "0.6.0", "bignumber.js": "^9.1.1", "bson-objectid": "^2.0.4", @@ -88,7 +89,7 @@ "just-clone": "^6.2.0", "merge-anything": "^5.1.4", "neverthrow": "^6.0.0", - "simple-typed-fetch": "^0.1.4", + "simple-typed-fetch": "^0.1.5", "stream-browserify": "^3.0.0", "tiny-invariant": "^1.3.1", "ts-is-present": "^1.2.2", diff --git a/src/BalanceGuard.ts b/src/BalanceGuard.ts index 94d10a0..1f39ec3 100644 --- a/src/BalanceGuard.ts +++ b/src/BalanceGuard.ts @@ -1,13 +1,13 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import clone from 'just-clone'; import { ERC20__factory } from '@orionprotocol/contracts'; -import { APPROVE_ERC20_GAS_LIMIT, NATIVE_CURRENCY_PRECISION } from './constants'; +import { APPROVE_ERC20_GAS_LIMIT, NATIVE_CURRENCY_PRECISION } from './constants/index.js'; import type { AggregatedBalanceRequirement, ApproveFix, Asset, BalanceIssue, BalanceRequirement, Source, -} from './types'; -import { denormalizeNumber } from './utils'; -import arrayEquals from './utils/arrayEquals'; +} from './types.js'; +import { denormalizeNumber } from './utils/index.js'; +import arrayEquals from './utils/arrayEquals.js'; export default class BalanceGuard { private readonly balances: Partial< diff --git a/src/Orion/bridge/getHistory.ts b/src/Orion/bridge/getHistory.ts index 34396b3..3b04e8f 100644 --- a/src/Orion/bridge/getHistory.ts +++ b/src/Orion/bridge/getHistory.ts @@ -1,9 +1,11 @@ import { ethers } from 'ethers'; -import type OrionUnit from '../../OrionUnit'; -import type { SupportedChainId } from '../../types'; -import { isValidChainId } from '../../utils'; -import ObjectID from 'bson-objectid'; +import type OrionUnit from '../../OrionUnit/index.js'; +import type { SupportedChainId } from '../../types.js'; +import { isValidChainId } from '../../utils/index.js'; import { simpleFetch } from 'simple-typed-fetch'; +import bsonObjectId from 'bson-objectid'; + +const ObjectID = bsonObjectId.default const getHistory = async (units: OrionUnit[], address: string, limit = 1000) => { if (!ethers.utils.isAddress(address)) throw new Error(`Invalid address: ${address}`); diff --git a/src/Orion/bridge/swap.ts b/src/Orion/bridge/swap.ts index 9633234..65ec975 100644 --- a/src/Orion/bridge/swap.ts +++ b/src/Orion/bridge/swap.ts @@ -1,22 +1,22 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import { Exchange__factory } from '@orionprotocol/contracts'; -import getBalances from '../../utils/getBalances'; -import BalanceGuard from '../../BalanceGuard'; -import getAvailableSources from '../../utils/getAvailableFundsSources'; +import getBalances from '../../utils/getBalances.js'; +import BalanceGuard from '../../BalanceGuard.js'; +import getAvailableSources from '../../utils/getAvailableFundsSources.js'; import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, LOCKATOMIC_GAS_LIMIT, REDEEMATOMIC_GAS_LIMIT, WITHDRAW_GAS_LIMIT -} from '../../constants'; -import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency'; -import { denormalizeNumber, generateSecret, normalizeNumber, toUpperCase } from '../../utils'; -import type { SupportedChainId } from '../../types'; -import type Orion from '..'; +} from '../../constants/index.js'; +import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; +import { denormalizeNumber, generateSecret, normalizeNumber, toUpperCase } from '../../utils/index.js'; +import type { SupportedChainId } from '../../types.js'; +import type Orion from '../index.js'; import type { z } from 'zod'; -import type { placeAtomicSwapSchema } from '../../services/OrionAggregator/schemas'; +import type { placeAtomicSwapSchema } from '../../services/OrionAggregator/schemas/index.js'; import { simpleFetch } from 'simple-typed-fetch'; type Params = { diff --git a/src/Orion/index.ts b/src/Orion/index.ts index bd3c0b3..aa2ebd2 100644 --- a/src/Orion/index.ts +++ b/src/Orion/index.ts @@ -1,14 +1,14 @@ -import type BigNumber from 'bignumber.js'; +import type { BigNumber } from 'bignumber.js'; import type { ethers } from 'ethers'; import { merge } from 'merge-anything'; -import { chains, envs } from '../config'; -import type { networkCodes } from '../constants'; -import OrionUnit from '../OrionUnit'; -import { ReferralSystem } from '../services/ReferralSystem'; -import type { SupportedChainId, DeepPartial, VerboseOrionUnitConfig, KnownEnv } from '../types'; -import { isValidChainId } from '../utils'; -import swap from './bridge/swap'; -import getHistory from './bridge/getHistory'; +import { chains, envs } from '../config/index.js'; +import type { networkCodes } from '../constants/index.js'; +import OrionUnit from '../OrionUnit/index.js'; +import { ReferralSystem } from '../services/ReferralSystem/index.js'; +import type { SupportedChainId, DeepPartial, VerboseOrionUnitConfig, KnownEnv } from '../types.js'; +import { isValidChainId } from '../utils/index.js'; +import swap from './bridge/swap.js'; +import getHistory from './bridge/getHistory.js'; import { simpleFetch } from 'simple-typed-fetch'; type EnvConfig = { diff --git a/src/OrionUnit/Exchange/deposit.ts b/src/OrionUnit/Exchange/deposit.ts index 1ded4f4..f2be122 100644 --- a/src/OrionUnit/Exchange/deposit.ts +++ b/src/OrionUnit/Exchange/deposit.ts @@ -1,14 +1,14 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import { Exchange__factory } from '@orionprotocol/contracts'; -import getBalances from '../../utils/getBalances'; -import BalanceGuard from '../../BalanceGuard'; -import type OrionUnit from '..'; +import getBalances from '../../utils/getBalances.js'; +import BalanceGuard from '../../BalanceGuard.js'; +import type OrionUnit from '../index.js'; import { DEPOSIT_ERC20_GAS_LIMIT, DEPOSIT_ETH_GAS_LIMIT, INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, -} from '../../constants'; -import { denormalizeNumber, normalizeNumber } from '../../utils'; -import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency'; +} from '../../constants/index.js'; +import { denormalizeNumber, normalizeNumber } from '../../utils/index.js'; +import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; import { simpleFetch } from 'simple-typed-fetch'; export type DepositParams = { diff --git a/src/OrionUnit/Exchange/getSwapInfo.ts b/src/OrionUnit/Exchange/getSwapInfo.ts index 4eec736..d173218 100644 --- a/src/OrionUnit/Exchange/getSwapInfo.ts +++ b/src/OrionUnit/Exchange/getSwapInfo.ts @@ -1,11 +1,11 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import { simpleFetch } from 'simple-typed-fetch'; -import { NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants'; -import type { OrionAggregator } from '../../services/OrionAggregator'; -import type { OrionBlockchain } from '../../services/OrionBlockchain'; +import { NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants/index.js'; +import type { OrionAggregator } from '../../services/OrionAggregator/index.js'; +import type { OrionBlockchain } from '../../services/OrionBlockchain/index.js'; -import { calculateFeeInFeeAsset, denormalizeNumber, getNativeCryptocurrency } from '../../utils'; +import { calculateFeeInFeeAsset, denormalizeNumber, getNativeCryptocurrency } from '../../utils/index.js'; export type GetSwapInfoParams = { type: 'exactSpend' | 'exactReceive' diff --git a/src/OrionUnit/Exchange/index.ts b/src/OrionUnit/Exchange/index.ts index d96ccad..99520c7 100644 --- a/src/OrionUnit/Exchange/index.ts +++ b/src/OrionUnit/Exchange/index.ts @@ -1,10 +1,10 @@ -import type OrionUnit from '..'; -import deposit, { type DepositParams } from './deposit'; -import getSwapInfo, { type GetSwapInfoParams } from './getSwapInfo'; -import type { SwapLimitParams } from './swapLimit'; -import swapLimit from './swapLimit'; -import swapMarket, { type SwapMarketParams } from './swapMarket'; -import withdraw, { type WithdrawParams } from './withdraw'; +import type OrionUnit from '../index.js'; +import deposit, { type DepositParams } from './deposit.js'; +import getSwapInfo, { type GetSwapInfoParams } from './getSwapInfo.js'; +import type { SwapLimitParams } from './swapLimit.js'; +import swapLimit from './swapLimit.js'; +import swapMarket, { type SwapMarketParams } from './swapMarket.js'; +import withdraw, { type WithdrawParams } from './withdraw.js'; type PureSwapMarketParams = Omit type PureSwapLimitParams = Omit diff --git a/src/OrionUnit/Exchange/swapLimit.ts b/src/OrionUnit/Exchange/swapLimit.ts index bba6e23..affff6d 100644 --- a/src/OrionUnit/Exchange/swapLimit.ts +++ b/src/OrionUnit/Exchange/swapLimit.ts @@ -1,15 +1,15 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import { Exchange__factory } from '@orionprotocol/contracts'; -import getBalances from '../../utils/getBalances'; -import BalanceGuard from '../../BalanceGuard'; -import getAvailableSources from '../../utils/getAvailableFundsSources'; -import type OrionUnit from '..'; -import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants'; -import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency'; -import { calculateFeeInFeeAsset, denormalizeNumber, normalizeNumber } from '../../utils'; -import { signOrder } from '../../crypt'; -import type orderSchema from '../../services/OrionAggregator/schemas/orderSchema'; +import getBalances from '../../utils/getBalances.js'; +import BalanceGuard from '../../BalanceGuard.js'; +import getAvailableSources from '../../utils/getAvailableFundsSources.js'; +import type OrionUnit from '../index.js'; +import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants/index.js'; +import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; +import { calculateFeeInFeeAsset, denormalizeNumber, normalizeNumber } from '../../utils/index.js'; +import { signOrder } from '../../crypt/index.js'; +import type orderSchema from '../../services/OrionAggregator/schemas/orderSchema.js'; import type { z } from 'zod'; import { simpleFetch } from 'simple-typed-fetch'; diff --git a/src/OrionUnit/Exchange/swapMarket.ts b/src/OrionUnit/Exchange/swapMarket.ts index 23f47a7..7575708 100644 --- a/src/OrionUnit/Exchange/swapMarket.ts +++ b/src/OrionUnit/Exchange/swapMarket.ts @@ -1,16 +1,16 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import { Exchange__factory } from '@orionprotocol/contracts'; -import getBalances from '../../utils/getBalances'; -import BalanceGuard from '../../BalanceGuard'; -import getAvailableSources from '../../utils/getAvailableFundsSources'; -import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants'; -import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency'; -import { calculateFeeInFeeAsset, denormalizeNumber, normalizeNumber } from '../../utils'; -import { signOrder } from '../../crypt'; -import type orderSchema from '../../services/OrionAggregator/schemas/orderSchema'; +import getBalances from '../../utils/getBalances.js'; +import BalanceGuard from '../../BalanceGuard.js'; +import getAvailableSources from '../../utils/getAvailableFundsSources.js'; +import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants/index.js'; +import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; +import { calculateFeeInFeeAsset, denormalizeNumber, normalizeNumber } from '../../utils/index.js'; +import { signOrder } from '../../crypt/index.js'; +import type orderSchema from '../../services/OrionAggregator/schemas/orderSchema.js'; import type { z } from 'zod'; -import type { SwapLimitParams } from './swapLimit'; +import type { SwapLimitParams } from './swapLimit.js'; import { simpleFetch } from 'simple-typed-fetch'; export type SwapMarketParams = Omit & { diff --git a/src/OrionUnit/Exchange/withdraw.ts b/src/OrionUnit/Exchange/withdraw.ts index 459d16b..0d913f9 100644 --- a/src/OrionUnit/Exchange/withdraw.ts +++ b/src/OrionUnit/Exchange/withdraw.ts @@ -1,14 +1,14 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import { Exchange__factory } from '@orionprotocol/contracts'; -import getBalances from '../../utils/getBalances'; -import BalanceGuard from '../../BalanceGuard'; -import type OrionUnit from '..'; +import getBalances from '../../utils/getBalances.js'; +import BalanceGuard from '../../BalanceGuard.js'; +import type OrionUnit from '../index.js'; import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, WITHDRAW_GAS_LIMIT, -} from '../../constants'; -import { denormalizeNumber, normalizeNumber } from '../../utils'; -import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency'; +} from '../../constants/index.js'; +import { denormalizeNumber, normalizeNumber } from '../../utils/index.js'; +import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; import { simpleFetch } from 'simple-typed-fetch'; export type WithdrawParams = { diff --git a/src/OrionUnit/FarmingManager/index.ts b/src/OrionUnit/FarmingManager/index.ts index 311e6cd..bcdf4c0 100644 --- a/src/OrionUnit/FarmingManager/index.ts +++ b/src/OrionUnit/FarmingManager/index.ts @@ -1,13 +1,13 @@ import { Exchange__factory, IUniswapV2Pair__factory, IUniswapV2Router__factory } from '@orionprotocol/contracts'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; import { simpleFetch } from 'simple-typed-fetch'; -import type OrionUnit from '..'; -import BalanceGuard from '../../BalanceGuard'; -import { ADD_LIQUIDITY_GAS_LIMIT, INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION } from '../../constants'; -import { denormalizeNumber, normalizeNumber } from '../../utils'; -import getBalances from '../../utils/getBalances'; -import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency'; +import type OrionUnit from '../index.js'; +import BalanceGuard from '../../BalanceGuard.js'; +import { ADD_LIQUIDITY_GAS_LIMIT, INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION } from '../../constants/index.js'; +import { denormalizeNumber, normalizeNumber } from '../../utils/index.js'; +import getBalances from '../../utils/getBalances.js'; +import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; const ADD_LIQUIDITY_SLIPPAGE = 0.05; diff --git a/src/OrionUnit/index.ts b/src/OrionUnit/index.ts index b2c480d..2b205f6 100644 --- a/src/OrionUnit/index.ts +++ b/src/OrionUnit/index.ts @@ -1,12 +1,12 @@ import { ethers } from 'ethers'; -import { OrionAggregator } from '../services/OrionAggregator'; -import { OrionBlockchain } from '../services/OrionBlockchain'; -import { PriceFeed } from '../services/PriceFeed'; -import type { KnownEnv, SupportedChainId, VerboseOrionUnitConfig } from '../types'; -import Exchange from './Exchange'; -import FarmingManager from './FarmingManager'; -import { chains, envs } from '../config'; -import type { networkCodes } from '../constants'; +import { OrionAggregator } from '../services/OrionAggregator/index.js'; +import { OrionBlockchain } from '../services/OrionBlockchain/index.js'; +import { PriceFeed } from '../services/PriceFeed/index.js'; +import type { KnownEnv, SupportedChainId, VerboseOrionUnitConfig } from '../types.js'; +import Exchange from './Exchange/index.js'; +import FarmingManager from './FarmingManager/index.js'; +import { chains, envs } from '../config/index.js'; +import type { networkCodes } from '../constants/index.js'; type KnownConfig = { env: KnownEnv diff --git a/src/__tests__/basic.test.ts b/src/__tests__/basic.test.ts index c207cf1..7c69581 100644 --- a/src/__tests__/basic.test.ts +++ b/src/__tests__/basic.test.ts @@ -1,10 +1,10 @@ -import Orion from '../Orion'; -import { ReferralSystem } from '../services/ReferralSystem'; -import { SupportedChainId } from '../types'; +import Orion from '../Orion/index.js'; +import { ReferralSystem } from '../services/ReferralSystem/index.js'; +import { SupportedChainId } from '../types.js'; import express from 'express'; import WebSocket from 'ws'; import http from 'http'; -import httpToWS from '../utils/httpToWS'; +import httpToWS from '../utils/httpToWS.js'; import { createHttpTerminator, } from 'http-terminator'; diff --git a/src/__tests__/bridge.test.ts b/src/__tests__/bridge.test.ts index e069846..e502c97 100644 --- a/src/__tests__/bridge.test.ts +++ b/src/__tests__/bridge.test.ts @@ -1,6 +1,6 @@ import { Wallet } from 'ethers'; -import Orion from '../Orion'; -import { SupportedChainId } from '../types'; +import Orion from '../Orion/index.js'; +import { SupportedChainId } from '../types.js'; const privateKey = process.env['PRIVATE_KEY'] if (privateKey === undefined) throw new Error('Private key is required'); diff --git a/src/__tests__/exchangeContract.test.ts b/src/__tests__/exchangeContract.test.ts index b52d048..b2b6a35 100644 --- a/src/__tests__/exchangeContract.test.ts +++ b/src/__tests__/exchangeContract.test.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import Orion from '../Orion'; +import Orion from '../Orion/index.js'; const privateKey = process.env['PRIVATE_KEY']; if (privateKey === undefined) throw new Error('Private key is required'); diff --git a/src/__tests__/orionAggregator.test.ts b/src/__tests__/orionAggregator.test.ts index c09a6c6..49ac62d 100644 --- a/src/__tests__/orionAggregator.test.ts +++ b/src/__tests__/orionAggregator.test.ts @@ -1,4 +1,4 @@ -import Orion from '../Orion'; +import Orion from '../Orion/index.js'; describe('Orion Aggregator', () => { test('Handle error aus', async () => { diff --git a/src/__tests__/pools.test.ts b/src/__tests__/pools.test.ts index 9bffd5e..6b837c1 100644 --- a/src/__tests__/pools.test.ts +++ b/src/__tests__/pools.test.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import Orion from '../Orion'; +import Orion from '../Orion/index.js'; const privateKey = process.env['PRIVATE_KEY'] if (privateKey === undefined) throw new Error('Private key is required'); diff --git a/src/__tests__/priceFeed.test.ts b/src/__tests__/priceFeed.test.ts index 95971ff..155733c 100644 --- a/src/__tests__/priceFeed.test.ts +++ b/src/__tests__/priceFeed.test.ts @@ -1,4 +1,4 @@ -import Orion from '../Orion'; +import Orion from '../Orion/index.js'; describe('Price Feed', () => { test('Ticker', async () => { diff --git a/src/__tests__/trading.test.ts b/src/__tests__/trading.test.ts index 0f8fa63..3cac2a7 100644 --- a/src/__tests__/trading.test.ts +++ b/src/__tests__/trading.test.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers'; -import Orion from '../Orion'; -import swapMarket from '../OrionUnit/Exchange/swapMarket'; +import Orion from '../Orion/index.js'; +import swapMarket from '../OrionUnit/Exchange/swapMarket.js'; const privateKey = process.env['PRIVATE_KEY'] if (privateKey === undefined) throw new Error('Private key is required'); diff --git a/src/config/index.ts b/src/config/index.ts index 5cfa626..aab5746 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,6 +1,6 @@ -import jsonChains from './chains.json'; -import jsonEnvs from './envs.json'; -import { pureEnvSchema, pureChainInfoSchema } from './schemas'; +import jsonChains from './chains.json' assert { type: 'json' }; +import jsonEnvs from './envs.json' assert { type: 'json' }; +import { pureEnvSchema, pureChainInfoSchema } from './schemas/index.js'; const chains = pureChainInfoSchema.parse(jsonChains); const envs = pureEnvSchema.parse(jsonEnvs); @@ -10,4 +10,4 @@ export { envs, }; -export * as schemas from './schemas'; +export * as schemas from './schemas/index.js'; diff --git a/src/config/schemas/index.ts b/src/config/schemas/index.ts index fb7fd35..88cef14 100644 --- a/src/config/schemas/index.ts +++ b/src/config/schemas/index.ts @@ -1,3 +1,3 @@ -export { default as eip712DomainSchema } from './eip712DomainSchema'; -export * from './pureEnvSchema'; -export * from './pureChainSchema'; +export { default as eip712DomainSchema } from './eip712DomainSchema.js'; +export * from './pureEnvSchema.js'; +export * from './pureChainSchema.js'; diff --git a/src/config/schemas/pureChainSchema.ts b/src/config/schemas/pureChainSchema.ts index 03be363..abc224b 100644 --- a/src/config/schemas/pureChainSchema.ts +++ b/src/config/schemas/pureChainSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import { networkCodes } from '../../constants'; -import { SupportedChainId } from '../../types'; +import { networkCodes } from '../../constants/index.js'; +import { SupportedChainId } from '../../types.js'; export const pureChainInfoPayloadSchema = z.object({ chainId: z.nativeEnum(SupportedChainId), diff --git a/src/config/schemas/pureEnvSchema.ts b/src/config/schemas/pureEnvSchema.ts index e3d1ceb..8838cd5 100644 --- a/src/config/schemas/pureEnvSchema.ts +++ b/src/config/schemas/pureEnvSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { SupportedChainId } from '../../types'; +import { SupportedChainId } from '../../types.js'; export const pureEnvNetworksSchema = z.object({ api: z.string(), diff --git a/src/constants/chains.ts b/src/constants/chains.ts index 2c20741..f684680 100644 --- a/src/constants/chains.ts +++ b/src/constants/chains.ts @@ -1,4 +1,4 @@ -import { SupportedChainId } from '../types'; +import { SupportedChainId } from '../types.js'; export const developmentChains = [ SupportedChainId.BSC_TESTNET, diff --git a/src/constants/exchangesMap.ts b/src/constants/exchangesMap.ts index 40dabfe..1f67ba5 100644 --- a/src/constants/exchangesMap.ts +++ b/src/constants/exchangesMap.ts @@ -1,4 +1,4 @@ -import type exchanges from './exchanges'; +import type exchanges from './exchanges.js'; const mapping: Record< typeof exchanges[number], diff --git a/src/constants/index.ts b/src/constants/index.ts index ff8dad3..b70d52a 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -1,11 +1,11 @@ -export { default as cancelOrderTypes } from './cancelOrderTypes'; -export { default as orderStatuses } from './orderStatuses'; -export { default as orderTypes } from './orderTypes'; -export { default as subOrderStatuses } from './subOrderStatuses'; -export { default as networkCodes } from './networkCodes'; -export { default as exchanges } from './exchanges'; -export { default as exchangesMap } from './exchangesMap'; +export { default as cancelOrderTypes } from './cancelOrderTypes.js'; +export { default as orderStatuses } from './orderStatuses.js'; +export { default as orderTypes } from './orderTypes.js'; +export { default as subOrderStatuses } from './subOrderStatuses.js'; +export { default as networkCodes } from './networkCodes.js'; +export { default as exchanges } from './exchanges.js'; +export { default as exchangesMap } from './exchangesMap.js'; -export * from './chains'; -export * from './precisions'; -export * from './gasLimits'; +export * from './chains.js'; +export * from './precisions.js'; +export * from './gasLimits.js'; diff --git a/src/constants/orderStatuses.ts b/src/constants/orderStatuses.ts index d1439de..69a46d4 100644 --- a/src/constants/orderStatuses.ts +++ b/src/constants/orderStatuses.ts @@ -1,4 +1,4 @@ -import subOrderStatuses from './subOrderStatuses'; +import subOrderStatuses from './subOrderStatuses.js'; // https://github.com/orionprotocol/orion-aggregator/blob/develop/src/main/java/io/orionprotocol/aggregator/model/order/status/OrderStatus.java const orderStatuses = [ diff --git a/src/crypt/getDomainData.ts b/src/crypt/getDomainData.ts index cd84ce6..2b07742 100644 --- a/src/crypt/getDomainData.ts +++ b/src/crypt/getDomainData.ts @@ -1,6 +1,6 @@ -import type { SupportedChainId } from '../types'; -import eip712DomainData from '../config/eip712DomainData.json'; -import eip712DomainSchema from '../config/schemas/eip712DomainSchema'; +import type { SupportedChainId } from '../types.js'; +import eip712DomainData from '../config/eip712DomainData.json' assert { type: 'json' }; +import eip712DomainSchema from '../config/schemas/eip712DomainSchema.js'; const EIP712Domain = eip712DomainSchema.parse(eip712DomainData); diff --git a/src/crypt/hashCFDOrder.ts b/src/crypt/hashCFDOrder.ts index ca63c77..9c771d3 100644 --- a/src/crypt/hashCFDOrder.ts +++ b/src/crypt/hashCFDOrder.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import type { CFDOrder } from '../types'; +import type { CFDOrder } from '../types.js'; const hashCFDOrder = (order: CFDOrder) => ethers.utils.solidityKeccak256( [ diff --git a/src/crypt/hashOrder.ts b/src/crypt/hashOrder.ts index aca6ed8..2106514 100644 --- a/src/crypt/hashOrder.ts +++ b/src/crypt/hashOrder.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import type { Order } from '../types'; +import type { Order } from '../types.js'; const hashOrder = (order: Order) => ethers.utils.solidityKeccak256( [ diff --git a/src/crypt/index.ts b/src/crypt/index.ts index 6a0c8d8..dbdcab5 100644 --- a/src/crypt/index.ts +++ b/src/crypt/index.ts @@ -1,5 +1,5 @@ -export { default as signCancelOrder } from './signCancelOrder'; -export { default as signCancelOrderPersonal } from './signCancelOrderPersonal'; -export { default as signOrder } from './signOrder'; -export { default as signCFDOrder } from './signCFDOrder'; -export { default as signOrderPersonal } from './signOrderPersonal'; +export { default as signCancelOrder } from './signCancelOrder.js'; +export { default as signCancelOrderPersonal } from './signCancelOrderPersonal.js'; +export { default as signOrder } from './signOrder.js'; +export { default as signCFDOrder } from './signCFDOrder.js'; +export { default as signOrderPersonal } from './signOrderPersonal.js'; diff --git a/src/crypt/signCFDOrder.ts b/src/crypt/signCFDOrder.ts index 20c69ee..d9f0ada 100644 --- a/src/crypt/signCFDOrder.ts +++ b/src/crypt/signCFDOrder.ts @@ -1,14 +1,14 @@ import type { TypedDataSigner } from '@ethersproject/abstract-signer'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import type { ethers } from 'ethers'; -import { joinSignature, splitSignature } from 'ethers/lib/utils'; -import { INTERNAL_ORION_PRECISION } from '../constants'; -import type { CFDOrder, SignedCFDOrder, SupportedChainId } from '../types'; -import normalizeNumber from '../utils/normalizeNumber'; -import getDomainData from './getDomainData'; -import signCFDOrderPersonal from './signCFDOrderPersonal'; -import hashCFDOrder from './hashCFDOrder'; -import CFD_ORDER_TYPES from '../constants/cfdOrderTypes'; +import { joinSignature, splitSignature } from 'ethers/lib/utils.js'; +import { INTERNAL_ORION_PRECISION } from '../constants/index.js'; +import type { CFDOrder, SignedCFDOrder, SupportedChainId } from '../types.js'; +import normalizeNumber from '../utils/normalizeNumber.js'; +import getDomainData from './getDomainData.js'; +import signCFDOrderPersonal from './signCFDOrderPersonal.js'; +import hashCFDOrder from './hashCFDOrder.js'; +import CFD_ORDER_TYPES from '../constants/cfdOrderTypes.js'; const DEFAULT_EXPIRATION = 29 * 24 * 60 * 60 * 1000; // 29 days diff --git a/src/crypt/signCFDOrderPersonal.ts b/src/crypt/signCFDOrderPersonal.ts index 60366ca..0e6029a 100644 --- a/src/crypt/signCFDOrderPersonal.ts +++ b/src/crypt/signCFDOrderPersonal.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import type { CFDOrder } from '../types'; +import type { CFDOrder } from '../types.js'; const { arrayify, joinSignature, splitSignature } = ethers.utils; diff --git a/src/crypt/signCancelOrder.ts b/src/crypt/signCancelOrder.ts index e48bdb0..1ed3cd1 100644 --- a/src/crypt/signCancelOrder.ts +++ b/src/crypt/signCancelOrder.ts @@ -1,10 +1,10 @@ import type { TypedDataSigner } from '@ethersproject/abstract-signer'; import type { ethers } from 'ethers'; -import { joinSignature, splitSignature } from 'ethers/lib/utils'; -import CANCEL_ORDER_TYPES from '../constants/cancelOrderTypes'; -import type { CancelOrderRequest, SignedCancelOrderRequest, SupportedChainId } from '../types'; -import getDomainData from './getDomainData'; -import signCancelOrderPersonal from './signCancelOrderPersonal'; +import { joinSignature, splitSignature } from 'ethers/lib/utils.js'; +import CANCEL_ORDER_TYPES from '../constants/cancelOrderTypes.js'; +import type { CancelOrderRequest, SignedCancelOrderRequest, SupportedChainId } from '../types.js'; +import getDomainData from './getDomainData.js'; +import signCancelOrderPersonal from './signCancelOrderPersonal.js'; type SignerWithTypedDataSign = ethers.Signer & TypedDataSigner; diff --git a/src/crypt/signCancelOrderPersonal.ts b/src/crypt/signCancelOrderPersonal.ts index 25c544d..c53975a 100644 --- a/src/crypt/signCancelOrderPersonal.ts +++ b/src/crypt/signCancelOrderPersonal.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers'; -import { arrayify, joinSignature, splitSignature } from 'ethers/lib/utils'; -import type { CancelOrderRequest } from '../types'; +import { arrayify, joinSignature, splitSignature } from 'ethers/lib/utils.js'; +import type { CancelOrderRequest } from '../types.js'; const signCancelOrderPersonal = async ( cancelOrderRequest: CancelOrderRequest, diff --git a/src/crypt/signOrder.ts b/src/crypt/signOrder.ts index afe3aa8..a11c848 100644 --- a/src/crypt/signOrder.ts +++ b/src/crypt/signOrder.ts @@ -1,14 +1,14 @@ import type { TypedDataSigner } from '@ethersproject/abstract-signer'; -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import type { ethers } from 'ethers'; -import { joinSignature, splitSignature } from 'ethers/lib/utils'; -import { INTERNAL_ORION_PRECISION } from '../constants'; -import ORDER_TYPES from '../constants/orderTypes'; -import type { Order, SignedOrder, SupportedChainId } from '../types'; -import normalizeNumber from '../utils/normalizeNumber'; -import getDomainData from './getDomainData'; -import hashOrder from './hashOrder'; -import signOrderPersonal from './signOrderPersonal'; +import { joinSignature, splitSignature } from 'ethers/lib/utils.js'; +import { INTERNAL_ORION_PRECISION } from '../constants/index.js'; +import ORDER_TYPES from '../constants/orderTypes.js'; +import type { Order, SignedOrder, SupportedChainId } from '../types.js'; +import normalizeNumber from '../utils/normalizeNumber.js'; +import getDomainData from './getDomainData.js'; +import hashOrder from './hashOrder.js'; +import signOrderPersonal from './signOrderPersonal.js'; const DEFAULT_EXPIRATION = 29 * 24 * 60 * 60 * 1000; // 29 days diff --git a/src/crypt/signOrderPersonal.ts b/src/crypt/signOrderPersonal.ts index e791b28..82c163d 100644 --- a/src/crypt/signOrderPersonal.ts +++ b/src/crypt/signOrderPersonal.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import type { Order } from '../types'; +import type { Order } from '../types.js'; const { arrayify, joinSignature, splitSignature } = ethers.utils; diff --git a/src/index.ts b/src/index.ts index 4a09da8..ba2a0e6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,14 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { simpleFetch, fetchWithValidation } from 'simple-typed-fetch'; BigNumber.config({ EXPONENTIAL_AT: 1e+9 }); -export * as config from './config'; -export { default as OrionUnit } from './OrionUnit'; -export { default as Orion } from './Orion'; -export { default as initOrionUnit } from './initOrionUnit'; -export * as utils from './utils'; -export * as services from './services'; -export * as crypt from './crypt'; -export * from './constants'; -export * from './types'; +export * as config from './config/index.js'; +export { default as OrionUnit } from './initOrionUnit.js'; +export { default as Orion } from './Orion/index.js'; +export { default as initOrionUnit } from './initOrionUnit.js'; +export * as utils from './utils/index.js'; +export * as services from './services/index.js'; +export * as crypt from './crypt/index.js'; +export * from './constants/index.js'; +export * from './types.js'; export { simpleFetch, fetchWithValidation }; diff --git a/src/initOrionUnit.ts b/src/initOrionUnit.ts index df19020..994268e 100644 --- a/src/initOrionUnit.ts +++ b/src/initOrionUnit.ts @@ -1,4 +1,4 @@ -import OrionUnit from './OrionUnit'; +import OrionUnit from './OrionUnit/index.js'; // backward compatibility export default function initOrionUnit(...params: ConstructorParameters) { diff --git a/src/services/OrionAggregator/index.ts b/src/services/OrionAggregator/index.ts index 2f8f38f..dba6f9f 100644 --- a/src/services/OrionAggregator/index.ts +++ b/src/services/OrionAggregator/index.ts @@ -1,24 +1,24 @@ -import type BigNumber from 'bignumber.js'; +import type { BigNumber } from 'bignumber.js'; import { z } from 'zod'; -import swapInfoSchema from './schemas/swapInfoSchema'; -import exchangeInfoSchema from './schemas/exchangeInfoSchema'; -import cancelOrderSchema from './schemas/cancelOrderSchema'; -import orderBenefitsSchema from './schemas/orderBenefitsSchema'; -import errorSchema from './schemas/errorSchema'; -import placeAtomicSwapSchema from './schemas/placeAtomicSwapSchema'; -import { OrionAggregatorWS } from './ws'; -import { atomicSwapHistorySchema } from './schemas/atomicSwapHistorySchema'; -import type { Exchange, SignedCancelOrderRequest, SignedCFDOrder, SignedOrder } from '../../types'; -import { pairConfigSchema } from './schemas'; +import swapInfoSchema from './schemas/swapInfoSchema.js'; +import exchangeInfoSchema from './schemas/exchangeInfoSchema.js'; +import cancelOrderSchema from './schemas/cancelOrderSchema.js'; +import orderBenefitsSchema from './schemas/orderBenefitsSchema.js'; +import errorSchema from './schemas/errorSchema.js'; +import placeAtomicSwapSchema from './schemas/placeAtomicSwapSchema.js'; +import { OrionAggregatorWS } from './ws/index.js'; +import { atomicSwapHistorySchema } from './schemas/atomicSwapHistorySchema.js'; +import type { Exchange, SignedCancelOrderRequest, SignedCFDOrder, SignedOrder } from '../../types.js'; +import { pairConfigSchema } from './schemas/index.js'; import { aggregatedOrderbookSchema, exchangeOrderbookSchema, poolReservesSchema, -} from './schemas/aggregatedOrderbookSchema'; -import type networkCodes from '../../constants/networkCodes'; -import toUpperCase from '../../utils/toUpperCase'; -import httpToWS from '../../utils/httpToWS'; +} from './schemas/aggregatedOrderbookSchema.js'; +import type networkCodes from '../../constants/networkCodes.js'; +import toUpperCase from '../../utils/toUpperCase.js'; +import httpToWS from '../../utils/httpToWS.js'; import { ethers } from 'ethers'; -import orderSchema from './schemas/orderSchema'; -import { exchanges } from '../../constants'; +import orderSchema from './schemas/orderSchema.js'; +import { exchanges } from '../../constants/index.js'; import { fetchWithValidation } from 'simple-typed-fetch'; class OrionAggregator { @@ -362,6 +362,6 @@ class OrionAggregator { return fetchWithValidation(url.toString(), atomicSwapHistorySchema); }; } -export * as schemas from './schemas'; -export * as ws from './ws'; +export * as schemas from './schemas/index.js'; +export * as ws from './ws/index.js'; export { OrionAggregator }; diff --git a/src/services/OrionAggregator/schemas/aggregatedOrderbookSchema.ts b/src/services/OrionAggregator/schemas/aggregatedOrderbookSchema.ts index e9a505b..ac7cd82 100644 --- a/src/services/OrionAggregator/schemas/aggregatedOrderbookSchema.ts +++ b/src/services/OrionAggregator/schemas/aggregatedOrderbookSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { exchanges } from '../../../constants'; +import { exchanges } from '../../../constants/index.js'; const orderbookElementSchema = z.object({ price: z.number(), diff --git a/src/services/OrionAggregator/schemas/atomicSwapHistorySchema.ts b/src/services/OrionAggregator/schemas/atomicSwapHistorySchema.ts index 5c6352f..5f5fdd8 100644 --- a/src/services/OrionAggregator/schemas/atomicSwapHistorySchema.ts +++ b/src/services/OrionAggregator/schemas/atomicSwapHistorySchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import uppercasedNetworkCodes from '../../../constants/uppercasedNetworkCodes'; -import redeemOrderSchema from './redeemOrderSchema'; +import uppercasedNetworkCodes from '../../../constants/uppercasedNetworkCodes.js'; +import redeemOrderSchema from './redeemOrderSchema.js'; export const atomicSwapHistorySchema = z.array(z.object({ id: z.string(), diff --git a/src/services/OrionAggregator/schemas/exchangeInfoSchema.ts b/src/services/OrionAggregator/schemas/exchangeInfoSchema.ts index c265717..a03a915 100644 --- a/src/services/OrionAggregator/schemas/exchangeInfoSchema.ts +++ b/src/services/OrionAggregator/schemas/exchangeInfoSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import pairConfigSchema from './pairConfigSchema'; +import pairConfigSchema from './pairConfigSchema.js'; const exchangeInfoSchema = z.array(pairConfigSchema); diff --git a/src/services/OrionAggregator/schemas/index.ts b/src/services/OrionAggregator/schemas/index.ts index 6dad79c..c1ce71f 100644 --- a/src/services/OrionAggregator/schemas/index.ts +++ b/src/services/OrionAggregator/schemas/index.ts @@ -1,9 +1,9 @@ -export { default as atomicSwapHistorySchema } from './atomicSwapHistorySchema'; -export { default as cancelOrderSchema } from './cancelOrderSchema'; -export { default as exchangeInfoSchema } from './exchangeInfoSchema'; -export { default as orderBenefitsSchema } from './orderBenefitsSchema'; -export { default as pairConfigSchema } from './pairConfigSchema'; -export { default as placeAtomicSwapSchema } from './placeAtomicSwapSchema'; -export { default as redeemOrderSchema } from './redeemOrderSchema'; -export { default as swapInfoSchema } from './swapInfoSchema'; -export { default as errorSchema } from './errorSchema'; +export { default as atomicSwapHistorySchema } from './atomicSwapHistorySchema.js'; +export { default as cancelOrderSchema } from './cancelOrderSchema.js'; +export { default as exchangeInfoSchema } from './exchangeInfoSchema.js'; +export { default as orderBenefitsSchema } from './orderBenefitsSchema.js'; +export { default as pairConfigSchema } from './pairConfigSchema.js'; +export { default as placeAtomicSwapSchema } from './placeAtomicSwapSchema.js'; +export { default as redeemOrderSchema } from './redeemOrderSchema.js'; +export { default as swapInfoSchema } from './swapInfoSchema.js'; +export { default as errorSchema } from './errorSchema.js'; diff --git a/src/services/OrionAggregator/schemas/orderSchema.ts b/src/services/OrionAggregator/schemas/orderSchema.ts index 0601051..7d33ea6 100644 --- a/src/services/OrionAggregator/schemas/orderSchema.ts +++ b/src/services/OrionAggregator/schemas/orderSchema.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers'; import { z } from 'zod'; -import { exchanges, orderStatuses, subOrderStatuses } from '../../../constants'; +import { exchanges, orderStatuses, subOrderStatuses } from '../../../constants/index.js'; const blockchainOrderSchema = z.object({ id: z.string().refine(ethers.utils.isHexString, (value) => ({ diff --git a/src/services/OrionAggregator/schemas/swapInfoSchema.ts b/src/services/OrionAggregator/schemas/swapInfoSchema.ts index 53a5a93..2befa9d 100644 --- a/src/services/OrionAggregator/schemas/swapInfoSchema.ts +++ b/src/services/OrionAggregator/schemas/swapInfoSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { exchanges } from '../../../constants'; +import { exchanges } from '../../../constants/index.js'; const orderInfoSchema = z.object({ assetPair: z.string(), diff --git a/src/services/OrionAggregator/ws/index.ts b/src/services/OrionAggregator/ws/index.ts index be45636..cf0affe 100644 --- a/src/services/OrionAggregator/ws/index.ts +++ b/src/services/OrionAggregator/ws/index.ts @@ -1,24 +1,24 @@ import { z } from 'zod'; import WebSocket from 'isomorphic-ws'; import { validate as uuidValidate, v4 as uuidv4 } from 'uuid'; -import MessageType from './MessageType'; -import SubscriptionType from './SubscriptionType'; +import MessageType from './MessageType.js'; +import SubscriptionType from './SubscriptionType.js'; import { pingPongMessageSchema, initMessageSchema, errorSchema, brokerMessageSchema, orderBookSchema, assetPairsConfigSchema, addressUpdateSchema, swapInfoSchema, -} from './schemas'; -import UnsubscriptionType from './UnsubscriptionType'; +} from './schemas/index.js'; +import UnsubscriptionType from './UnsubscriptionType.js'; import type { SwapInfoBase, AssetPairUpdate, OrderbookItem, Balance, Exchange, CFDBalance, FuturesTradeInfo, SwapInfo, Json, -} from '../../../types'; -import unsubscriptionDoneSchema from './schemas/unsubscriptionDoneSchema'; -import assetPairConfigSchema from './schemas/assetPairConfigSchema'; -import type { fullOrderSchema, orderUpdateSchema } from './schemas/addressUpdateSchema'; -import cfdAddressUpdateSchema from './schemas/cfdAddressUpdateSchema'; -import futuresTradeInfoSchema from './schemas/futuresTradeInfoSchema'; -import { objectKeys } from '../../../utils/objectKeys'; +} from '../../../types.js'; +import unsubscriptionDoneSchema from './schemas/unsubscriptionDoneSchema.js'; +import assetPairConfigSchema from './schemas/assetPairConfigSchema.js'; +import type { fullOrderSchema, orderUpdateSchema } from './schemas/addressUpdateSchema.js'; +import cfdAddressUpdateSchema from './schemas/cfdAddressUpdateSchema.js'; +import futuresTradeInfoSchema from './schemas/futuresTradeInfoSchema.js'; +import { objectKeys } from '../../../utils/objectKeys.js'; // import errorSchema from './schemas/errorSchema'; const UNSUBSCRIBE = 'u'; @@ -639,7 +639,7 @@ class OrionAggregatorWS { } } -export * as schemas from './schemas'; +export * as schemas from './schemas/index.js'; export { OrionAggregatorWS, SubscriptionType, diff --git a/src/services/OrionAggregator/ws/schemas/addressUpdateSchema.ts b/src/services/OrionAggregator/ws/schemas/addressUpdateSchema.ts index d9f53b5..becd7e7 100644 --- a/src/services/OrionAggregator/ws/schemas/addressUpdateSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/addressUpdateSchema.ts @@ -1,11 +1,11 @@ import { z } from 'zod'; -import { exchanges } from '../../../../constants'; -import orderStatuses from '../../../../constants/orderStatuses'; -import subOrderStatuses from '../../../../constants/subOrderStatuses'; -import MessageType from '../MessageType'; -import balancesSchema from './balancesSchema'; -import baseMessageSchema from './baseMessageSchema'; -import executionTypes from '../../../../constants/cfdExecutionTypes'; +import { exchanges } from '../../../../constants/index.js'; +import orderStatuses from '../../../../constants/orderStatuses.js'; +import subOrderStatuses from '../../../../constants/subOrderStatuses.js'; +import MessageType from '../MessageType.js'; +import balancesSchema from './balancesSchema.js'; +import baseMessageSchema from './baseMessageSchema.js'; +import executionTypes from '../../../../constants/cfdExecutionTypes.js'; const baseAddressUpdate = baseMessageSchema.extend({ id: z.string(), diff --git a/src/services/OrionAggregator/ws/schemas/assetPairConfigSchema.ts b/src/services/OrionAggregator/ws/schemas/assetPairConfigSchema.ts index 0b17754..13cd81e 100644 --- a/src/services/OrionAggregator/ws/schemas/assetPairConfigSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/assetPairConfigSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; const assetPairConfigSchema = baseMessageSchema.extend({ id: z.string(), diff --git a/src/services/OrionAggregator/ws/schemas/assetPairsConfigSchema.ts b/src/services/OrionAggregator/ws/schemas/assetPairsConfigSchema.ts index 0557f7e..2a60db4 100644 --- a/src/services/OrionAggregator/ws/schemas/assetPairsConfigSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/assetPairsConfigSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; const assetPairsConfigSchema = baseMessageSchema.extend({ id: z.string(), diff --git a/src/services/OrionAggregator/ws/schemas/balancesSchema.ts b/src/services/OrionAggregator/ws/schemas/balancesSchema.ts index 17ec97a..c8a14fc 100644 --- a/src/services/OrionAggregator/ws/schemas/balancesSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/balancesSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { makePartial } from '../../../../utils'; +import { makePartial } from '../../../../utils/index.js'; const balancesSchema = z.record( // changed balances in format z.string(), // asset diff --git a/src/services/OrionAggregator/ws/schemas/baseMessageSchema.ts b/src/services/OrionAggregator/ws/schemas/baseMessageSchema.ts index ec6c749..8cf25d1 100644 --- a/src/services/OrionAggregator/ws/schemas/baseMessageSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/baseMessageSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; +import MessageType from '../MessageType.js'; const baseMessageSchema = z.object({ T: z.nativeEnum(MessageType), diff --git a/src/services/OrionAggregator/ws/schemas/brokerMessageSchema.ts b/src/services/OrionAggregator/ws/schemas/brokerMessageSchema.ts index f3c3ab3..2c88270 100644 --- a/src/services/OrionAggregator/ws/schemas/brokerMessageSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/brokerMessageSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; const brokerMessageSchema = baseMessageSchema.extend({ T: z.literal(MessageType.BROKER_TRADABLE_ATOMIC_SWAP_ASSETS_BALANCE_UPDATE), diff --git a/src/services/OrionAggregator/ws/schemas/cfdAddressUpdateSchema.ts b/src/services/OrionAggregator/ws/schemas/cfdAddressUpdateSchema.ts index e282cab..126ff23 100644 --- a/src/services/OrionAggregator/ws/schemas/cfdAddressUpdateSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/cfdAddressUpdateSchema.ts @@ -1,8 +1,8 @@ import { z } from 'zod'; -import { fullOrderSchema, orderUpdateSchema } from './addressUpdateSchema'; -import baseMessageSchema from './baseMessageSchema'; -import MessageType from '../MessageType'; -import cfdBalancesSchema from './cfdBalancesSchema'; +import { fullOrderSchema, orderUpdateSchema } from './addressUpdateSchema.js'; +import baseMessageSchema from './baseMessageSchema.js'; +import MessageType from '../MessageType.js'; +import cfdBalancesSchema from './cfdBalancesSchema.js'; const baseCfdAddressUpdate = baseMessageSchema.extend({ id: z.string(), diff --git a/src/services/OrionAggregator/ws/schemas/cfdBalancesSchema.ts b/src/services/OrionAggregator/ws/schemas/cfdBalancesSchema.ts index 5037864..e4b3448 100644 --- a/src/services/OrionAggregator/ws/schemas/cfdBalancesSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/cfdBalancesSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import positionStatuses from '../../../../constants/positionStatuses'; +import positionStatuses from '../../../../constants/positionStatuses.js'; const cfdBalanceSchema = z .object({ diff --git a/src/services/OrionAggregator/ws/schemas/errorSchema.ts b/src/services/OrionAggregator/ws/schemas/errorSchema.ts index 370d9fa..e10b432 100644 --- a/src/services/OrionAggregator/ws/schemas/errorSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/errorSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; const errorSchema = baseMessageSchema.extend({ T: z.literal(MessageType.ERROR), diff --git a/src/services/OrionAggregator/ws/schemas/futuresTradeInfoSchema.ts b/src/services/OrionAggregator/ws/schemas/futuresTradeInfoSchema.ts index e6fde41..37bdf21 100644 --- a/src/services/OrionAggregator/ws/schemas/futuresTradeInfoSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/futuresTradeInfoSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; +import MessageType from '../MessageType.js'; const futuresTradeInfoSchema = z.object({ T: z.literal(MessageType.FUTURES_TRADE_INFO_UPDATE), diff --git a/src/services/OrionAggregator/ws/schemas/index.ts b/src/services/OrionAggregator/ws/schemas/index.ts index 36743dc..701d63e 100644 --- a/src/services/OrionAggregator/ws/schemas/index.ts +++ b/src/services/OrionAggregator/ws/schemas/index.ts @@ -1,12 +1,12 @@ -export { default as addressUpdateSchema } from './addressUpdateSchema'; -export { default as assetPairsConfigSchema } from './assetPairsConfigSchema'; -export { default as baseMessageSchema } from './baseMessageSchema'; -export { default as brokerMessageSchema } from './brokerMessageSchema'; -export { default as errorSchema } from './errorSchema'; -export { default as initMessageSchema } from './initMessageSchema'; -export { default as pingPongMessageSchema } from './pingPongMessageSchema'; -export { default as swapInfoSchema } from './swapInfoSchema'; -export { default as balancesSchema } from './balancesSchema'; -export { default as cfdBalancesSchema } from './cfdBalancesSchema'; +export { default as addressUpdateSchema } from './addressUpdateSchema.js'; +export { default as assetPairsConfigSchema } from './assetPairsConfigSchema.js'; +export { default as baseMessageSchema } from './baseMessageSchema.js'; +export { default as brokerMessageSchema } from './brokerMessageSchema.js'; +export { default as errorSchema } from './errorSchema.js'; +export { default as initMessageSchema } from './initMessageSchema.js'; +export { default as pingPongMessageSchema } from './pingPongMessageSchema.js'; +export { default as swapInfoSchema } from './swapInfoSchema.js'; +export { default as balancesSchema } from './balancesSchema.js'; +export { default as cfdBalancesSchema } from './cfdBalancesSchema.js'; -export * from './orderBookSchema'; +export * from './orderBookSchema.js'; diff --git a/src/services/OrionAggregator/ws/schemas/initMessageSchema.ts b/src/services/OrionAggregator/ws/schemas/initMessageSchema.ts index c7be00a..c2c4573 100644 --- a/src/services/OrionAggregator/ws/schemas/initMessageSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/initMessageSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; const initMessageSchema = baseMessageSchema.extend({ T: z.literal(MessageType.INITIALIZATION), diff --git a/src/services/OrionAggregator/ws/schemas/orderBookSchema.ts b/src/services/OrionAggregator/ws/schemas/orderBookSchema.ts index 4de8315..de07249 100644 --- a/src/services/OrionAggregator/ws/schemas/orderBookSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/orderBookSchema.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; -import exchanges from '../../../../constants/exchanges'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import exchanges from '../../../../constants/exchanges.js'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; export const orderBookItemSchema = z.tuple([ z.string(), // price diff --git a/src/services/OrionAggregator/ws/schemas/pingPongMessageSchema.ts b/src/services/OrionAggregator/ws/schemas/pingPongMessageSchema.ts index f3424ab..80a1ad3 100644 --- a/src/services/OrionAggregator/ws/schemas/pingPongMessageSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/pingPongMessageSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; const pingPongMessageSchema = baseMessageSchema.extend({ T: z.literal(MessageType.PING_PONG), diff --git a/src/services/OrionAggregator/ws/schemas/swapInfoSchema.ts b/src/services/OrionAggregator/ws/schemas/swapInfoSchema.ts index cd692ef..9693c89 100644 --- a/src/services/OrionAggregator/ws/schemas/swapInfoSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/swapInfoSchema.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; -import exchanges from '../../../../constants/exchanges'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import exchanges from '../../../../constants/exchanges.js'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; const alternativeSchema = z.object({ // execution alternatives e: z.enum(exchanges).array(), // exchanges diff --git a/src/services/OrionAggregator/ws/schemas/unsubscriptionDoneSchema.ts b/src/services/OrionAggregator/ws/schemas/unsubscriptionDoneSchema.ts index f8d33b2..e23afa6 100644 --- a/src/services/OrionAggregator/ws/schemas/unsubscriptionDoneSchema.ts +++ b/src/services/OrionAggregator/ws/schemas/unsubscriptionDoneSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import MessageType from '../MessageType'; -import baseMessageSchema from './baseMessageSchema'; +import MessageType from '../MessageType.js'; +import baseMessageSchema from './baseMessageSchema.js'; const unsubscriptionDoneSchema = baseMessageSchema.extend({ id: z.string(), diff --git a/src/services/OrionBlockchain/index.ts b/src/services/OrionBlockchain/index.ts index b48974f..a42ce49 100644 --- a/src/services/OrionBlockchain/index.ts +++ b/src/services/OrionBlockchain/index.ts @@ -12,11 +12,11 @@ import { cfdContractsSchema, cfdHistorySchema, governanceContractsSchema, -} from './schemas'; -import type redeemOrderSchema from '../OrionAggregator/schemas/redeemOrderSchema'; -import { sourceAtomicHistorySchema, targetAtomicHistorySchema } from './schemas/atomicHistorySchema'; -import { makePartial } from '../../utils'; -import type { networkCodes } from '../../constants'; +} from './schemas/index.js'; +import type redeemOrderSchema from '../OrionAggregator/schemas/redeemOrderSchema.js'; +import { sourceAtomicHistorySchema, targetAtomicHistorySchema } from './schemas/atomicHistorySchema.js'; +import { makePartial } from '../../utils/index.js'; +import type { networkCodes } from '../../constants/index.js'; import { fetchWithValidation } from 'simple-typed-fetch'; type IAdminAuthHeaders = { @@ -431,5 +431,5 @@ class OrionBlockchain { ); } -export * as schemas from './schemas'; +export * as schemas from './schemas/index.js'; export { OrionBlockchain }; diff --git a/src/services/OrionBlockchain/schemas/adminPoolsListSchema.ts b/src/services/OrionBlockchain/schemas/adminPoolsListSchema.ts index 4c7cbc7..862fcdd 100644 --- a/src/services/OrionBlockchain/schemas/adminPoolsListSchema.ts +++ b/src/services/OrionBlockchain/schemas/adminPoolsListSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { poolOnVerificationSchema } from './adminPoolSchema'; +import { poolOnVerificationSchema } from './adminPoolSchema.js'; export default z.array(poolOnVerificationSchema); diff --git a/src/services/OrionBlockchain/schemas/atomicHistorySchema.ts b/src/services/OrionBlockchain/schemas/atomicHistorySchema.ts index 9d2ed3f..4ab4fe9 100644 --- a/src/services/OrionBlockchain/schemas/atomicHistorySchema.ts +++ b/src/services/OrionBlockchain/schemas/atomicHistorySchema.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers'; import { z } from 'zod'; -import getValidArrayItemsSchema from '../../../utils/getValidArrayItems'; +import getValidArrayItemsSchema from '../../../utils/getValidArrayItems.js'; const baseAtomicHistorySchema = z.object({ success: z.boolean(), diff --git a/src/services/OrionBlockchain/schemas/cfdHistorySchema.ts b/src/services/OrionBlockchain/schemas/cfdHistorySchema.ts index 2391fe5..751a6cf 100644 --- a/src/services/OrionBlockchain/schemas/cfdHistorySchema.ts +++ b/src/services/OrionBlockchain/schemas/cfdHistorySchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { HistoryTransactionStatus } from '../../../types'; +import { HistoryTransactionStatus } from '../../../types.js'; export enum historyTransactionType { WITHDRAW = 'withdrawal', diff --git a/src/services/OrionBlockchain/schemas/historySchema.ts b/src/services/OrionBlockchain/schemas/historySchema.ts index 9aba65a..dc27125 100644 --- a/src/services/OrionBlockchain/schemas/historySchema.ts +++ b/src/services/OrionBlockchain/schemas/historySchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { HistoryTransactionStatus } from '../../../types'; +import { HistoryTransactionStatus } from '../../../types.js'; const historySchema = z.array(z.object( { diff --git a/src/services/OrionBlockchain/schemas/index.ts b/src/services/OrionBlockchain/schemas/index.ts index 297c77b..3d5bfec 100644 --- a/src/services/OrionBlockchain/schemas/index.ts +++ b/src/services/OrionBlockchain/schemas/index.ts @@ -1,17 +1,17 @@ -export * from './adminPoolSchema'; -export { default as adminPoolsListSchema } from './adminPoolsListSchema'; -export { default as addPoolSchema } from './addPoolSchema'; -export { default as atomicHistorySchema } from './atomicHistorySchema'; -export { default as checkRedeemOrderSchema } from './checkRedeemOrderSchema'; -export { default as historySchema } from './historySchema'; -export { default as IDOSchema } from './IDOSchema'; -export { default as infoSchema } from './infoSchema'; -export { default as poolsConfigSchema } from './poolsConfigSchema'; -export { default as poolsInfoSchema } from './poolsInfoSchema'; -export { default as atomicSummarySchema } from './atomicSummarySchema'; -export { default as poolsLpAndStakedSchema } from './poolsLpAndStakedSchema'; -export { default as userVotesSchema } from './userVotesSchema'; -export { default as userEarnedSchema } from './userEarnedSchema'; -export { default as cfdContractsSchema } from './cfdContractsSchema'; -export { default as cfdHistorySchema } from './cfdHistorySchema'; -export { default as governanceContractsSchema } from './governanceContractsSchema'; +export * from './adminPoolSchema.js'; +export { default as adminPoolsListSchema } from './adminPoolsListSchema.js'; +export { default as addPoolSchema } from './addPoolSchema.js'; +export { default as atomicHistorySchema } from './atomicHistorySchema.js'; +export { default as checkRedeemOrderSchema } from './checkRedeemOrderSchema.js'; +export { default as historySchema } from './historySchema.js'; +export { default as IDOSchema } from './IDOSchema.js'; +export { default as infoSchema } from './infoSchema.js'; +export { default as poolsConfigSchema } from './poolsConfigSchema.js'; +export { default as poolsInfoSchema } from './poolsInfoSchema.js'; +export { default as atomicSummarySchema } from './atomicSummarySchema.js'; +export { default as poolsLpAndStakedSchema } from './poolsLpAndStakedSchema.js'; +export { default as userVotesSchema } from './userVotesSchema.js'; +export { default as userEarnedSchema } from './userEarnedSchema.js'; +export { default as cfdContractsSchema } from './cfdContractsSchema.js'; +export { default as cfdHistorySchema } from './cfdHistorySchema.js'; +export { default as governanceContractsSchema } from './governanceContractsSchema.js'; diff --git a/src/services/OrionBlockchain/schemas/infoSchema.ts b/src/services/OrionBlockchain/schemas/infoSchema.ts index 59c1de9..326f18e 100644 --- a/src/services/OrionBlockchain/schemas/infoSchema.ts +++ b/src/services/OrionBlockchain/schemas/infoSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { makePartial } from '../../../utils'; +import { makePartial } from '../../../utils/index.js'; const internalFeeAssetSchema = z.object({ type: z.enum(['percent', 'plain']), diff --git a/src/services/OrionBlockchain/schemas/poolsConfigSchema.ts b/src/services/OrionBlockchain/schemas/poolsConfigSchema.ts index 0ae0f80..6229e2d 100644 --- a/src/services/OrionBlockchain/schemas/poolsConfigSchema.ts +++ b/src/services/OrionBlockchain/schemas/poolsConfigSchema.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import addressSchema from '../../../addressSchema'; -import { makePartial } from '../../../utils'; +import addressSchema from '../../../addressSchema.js'; +import { makePartial } from '../../../utils/index.js'; const poolsConfigSchema = z.object({ WETHAddress: addressSchema.optional(), diff --git a/src/services/PriceFeed/index.ts b/src/services/PriceFeed/index.ts index 61f74a5..a6d5345 100644 --- a/src/services/PriceFeed/index.ts +++ b/src/services/PriceFeed/index.ts @@ -1,8 +1,8 @@ import { fetchWithValidation } from 'simple-typed-fetch'; -import type { Exchange } from '../../types'; -import { statisticsOverviewSchema, topPairsStatisticsSchema } from './schemas'; -import candlesSchema from './schemas/candlesSchema'; -import { PriceFeedWS } from './ws'; +import type { Exchange } from '../../types.js'; +import { statisticsOverviewSchema, topPairsStatisticsSchema } from './schemas/index.js'; +import candlesSchema from './schemas/candlesSchema.js'; +import { PriceFeedWS } from './ws/index.js'; class PriceFeed { private readonly apiUrl: string; @@ -68,6 +68,6 @@ class PriceFeed { } } -export * as schemas from './schemas'; +export * as schemas from './schemas/index.js'; export { PriceFeed }; diff --git a/src/services/PriceFeed/schemas/index.ts b/src/services/PriceFeed/schemas/index.ts index 2e7c242..42837d7 100644 --- a/src/services/PriceFeed/schemas/index.ts +++ b/src/services/PriceFeed/schemas/index.ts @@ -1,5 +1,5 @@ -export { default as candlesSchema } from './candlesSchema'; +export { default as candlesSchema } from './candlesSchema.js'; export { statisticsOverviewSchema, topPairsStatisticsSchema, -} from './statisticsSchema'; +} from './statisticsSchema.js'; diff --git a/src/services/PriceFeed/ws/PriceFeedSubscription.ts b/src/services/PriceFeed/ws/PriceFeedSubscription.ts index fb5b8ed..4969549 100644 --- a/src/services/PriceFeed/ws/PriceFeedSubscription.ts +++ b/src/services/PriceFeed/ws/PriceFeedSubscription.ts @@ -1,11 +1,11 @@ import WebSocket from 'isomorphic-ws'; import { z } from 'zod'; import { v4 as uuidv4 } from 'uuid'; -import priceFeedSubscriptions from './priceFeedSubscriptions'; -import { tickerInfoSchema, candleSchema } from './schemas'; -import priceSchema from './schemas/priceSchema'; -import type { Json } from '../../../types'; -import allTickersSchema from './schemas/allTickersSchema'; +import priceFeedSubscriptions from './priceFeedSubscriptions.js'; +import { tickerInfoSchema, candleSchema } from './schemas/index.js'; +import priceSchema from './schemas/priceSchema.js'; +import type { Json } from '../../../types.js'; +import allTickersSchema from './schemas/allTickersSchema.js'; export const subscriptions = { [priceFeedSubscriptions.ALL_TICKERS]: { diff --git a/src/services/PriceFeed/ws/index.ts b/src/services/PriceFeed/ws/index.ts index 69aca0a..6eda1ed 100644 --- a/src/services/PriceFeed/ws/index.ts +++ b/src/services/PriceFeed/ws/index.ts @@ -1,7 +1,7 @@ import type WebSocket from 'ws'; -import PriceFeedSubscription, { type SubscriptionType, type Subscription } from './PriceFeedSubscription'; +import PriceFeedSubscription, { type SubscriptionType, type Subscription } from './PriceFeedSubscription.js'; -export * as schemas from './schemas'; +export * as schemas from './schemas/index.js'; export class PriceFeedWS { private subscriptions: Partial<{ [K in SubscriptionType]: Partial< diff --git a/src/services/PriceFeed/ws/schemas/allTickersSchema.ts b/src/services/PriceFeed/ws/schemas/allTickersSchema.ts index 17b917e..2fcb748 100644 --- a/src/services/PriceFeed/ws/schemas/allTickersSchema.ts +++ b/src/services/PriceFeed/ws/schemas/allTickersSchema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import tickerInfoSchema from './tickerInfoSchema'; +import tickerInfoSchema from './tickerInfoSchema.js'; type TickerInfo = z.infer diff --git a/src/services/PriceFeed/ws/schemas/index.ts b/src/services/PriceFeed/ws/schemas/index.ts index a5ff843..4ca9486 100644 --- a/src/services/PriceFeed/ws/schemas/index.ts +++ b/src/services/PriceFeed/ws/schemas/index.ts @@ -1,4 +1,4 @@ -export { default as tickerInfoSchema } from './tickerInfoSchema'; -export { default as candleSchema } from './candleSchema'; -export { default as priceSchema } from './priceSchema'; -export { default as allTickersSchema } from './allTickersSchema'; +export { default as tickerInfoSchema } from './tickerInfoSchema.js'; +export { default as candleSchema } from './candleSchema.js'; +export { default as priceSchema } from './priceSchema.js'; +export { default as allTickersSchema } from './allTickersSchema.js'; diff --git a/src/services/ReferralSystem/index.ts b/src/services/ReferralSystem/index.ts index 79aaa8a..ea87bf3 100644 --- a/src/services/ReferralSystem/index.ts +++ b/src/services/ReferralSystem/index.ts @@ -7,7 +7,7 @@ import { globalAnalyticsSchema, rewardsClaimedSchema, linkSchema, -} from './schemas'; +} from './schemas/index.js'; type CreateLinkPayloadType = { referer: string @@ -154,5 +154,5 @@ class ReferralSystem { ); } -export * as schemas from './schemas'; +export * as schemas from './schemas/index.js'; export { ReferralSystem }; diff --git a/src/services/ReferralSystem/schemas/index.ts b/src/services/ReferralSystem/schemas/index.ts index 2578222..22b6cf0 100644 --- a/src/services/ReferralSystem/schemas/index.ts +++ b/src/services/ReferralSystem/schemas/index.ts @@ -1,7 +1,7 @@ -export { default as linkSchema } from './linkSchema'; -export { default as distinctAnalyticsSchema } from './distinctAnalyticsSchema'; -export { default as errorSchema } from './errorSchema'; -export { default as miniStatsSchema } from './miniStatsSchema'; -export { default as rewardsMappingSchema } from './rewardsMappingSchema'; -export { default as rewardsClaimedSchema } from './rewardsClaimedSchema'; -export { default as globalAnalyticsSchema } from './globalAnalyticsSchema'; +export { default as linkSchema } from './linkSchema.js'; +export { default as distinctAnalyticsSchema } from './distinctAnalyticsSchema.js'; +export { default as errorSchema } from './errorSchema.js'; +export { default as miniStatsSchema } from './miniStatsSchema.js'; +export { default as rewardsMappingSchema } from './rewardsMappingSchema.js'; +export { default as rewardsClaimedSchema } from './rewardsClaimedSchema.js'; +export { default as globalAnalyticsSchema } from './globalAnalyticsSchema.js'; diff --git a/src/services/index.ts b/src/services/index.ts index a59bb37..66f9a95 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,3 +1,3 @@ -export * as orionAggregator from './OrionAggregator'; -export * as orionBlockchain from './OrionBlockchain'; -export * as priceFeed from './PriceFeed'; +export * as orionAggregator from './OrionAggregator/index.js'; +export * as orionBlockchain from './OrionBlockchain/index.js'; +export * as priceFeed from './PriceFeed/index.js'; diff --git a/src/types.ts b/src/types.ts index 891d740..24d95ac 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions */ -import type BigNumber from 'bignumber.js'; -import type exchanges from './constants/exchanges'; -import type subOrderStatuses from './constants/subOrderStatuses'; -import type positionStatuses from './constants/positionStatuses'; -import type { knownEnvs } from './config/schemas'; +import type { BigNumber } from 'bignumber.js'; +import type exchanges from './constants/exchanges.js'; +import type subOrderStatuses from './constants/subOrderStatuses.js'; +import type positionStatuses from './constants/positionStatuses.js'; +import type { knownEnvs } from './config/schemas/index.js'; export type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; diff --git a/src/utils/calculateFeeInFeeAsset.ts b/src/utils/calculateFeeInFeeAsset.ts index b0202b0..bb63afd 100644 --- a/src/utils/calculateFeeInFeeAsset.ts +++ b/src/utils/calculateFeeInFeeAsset.ts @@ -1,7 +1,7 @@ -import BigNumber from 'bignumber.js'; -import { FILL_ORDERS_GAS_LIMIT } from '../constants'; -import calculateNetworkFeeInFeeAsset from './calculateNetworkFeeInFeeAsset'; -import calculateOrionFeeInFeeAsset from './calculateOrionFeeInFeeAsset'; +import { BigNumber } from 'bignumber.js'; +import { FILL_ORDERS_GAS_LIMIT } from '../constants/index.js'; +import calculateNetworkFeeInFeeAsset from './calculateNetworkFeeInFeeAsset.js'; +import calculateOrionFeeInFeeAsset from './calculateOrionFeeInFeeAsset.js'; const calculateFeeInFeeAsset = ( amount: BigNumber.Value, diff --git a/src/utils/calculateNetworkFee.ts b/src/utils/calculateNetworkFee.ts index 5185c93..8f348e9 100644 --- a/src/utils/calculateNetworkFee.ts +++ b/src/utils/calculateNetworkFee.ts @@ -1,6 +1,6 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; -import { NATIVE_CURRENCY_PRECISION } from '../constants/precisions'; +import { NATIVE_CURRENCY_PRECISION } from '../constants/precisions.js'; export default function calculateNetworkFee( gasPriceGwei: BigNumber.Value, diff --git a/src/utils/calculateNetworkFeeInFeeAsset.ts b/src/utils/calculateNetworkFeeInFeeAsset.ts index eae0316..939fdfd 100644 --- a/src/utils/calculateNetworkFeeInFeeAsset.ts +++ b/src/utils/calculateNetworkFeeInFeeAsset.ts @@ -1,5 +1,5 @@ -import BigNumber from 'bignumber.js'; -import calculateNetworkFee from './calculateNetworkFee'; +import { BigNumber } from 'bignumber.js'; +import calculateNetworkFee from './calculateNetworkFee.js'; const calculateNetworkFeeInFeeAsset = ( gasPriceGwei: BigNumber.Value, diff --git a/src/utils/calculateOrionFeeInFeeAsset.ts b/src/utils/calculateOrionFeeInFeeAsset.ts index 3f19b01..d0b388c 100644 --- a/src/utils/calculateOrionFeeInFeeAsset.ts +++ b/src/utils/calculateOrionFeeInFeeAsset.ts @@ -1,4 +1,4 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; export default function calculateOrionFeeInFeeAsset( amount: BigNumber.Value, diff --git a/src/utils/denormalizeNumber.ts b/src/utils/denormalizeNumber.ts index f7e3852..6ebffd9 100644 --- a/src/utils/denormalizeNumber.ts +++ b/src/utils/denormalizeNumber.ts @@ -1,4 +1,4 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import type { ethers } from 'ethers'; /** diff --git a/src/utils/generateSecret.ts b/src/utils/generateSecret.ts index 16fda3d..e25c921 100644 --- a/src/utils/generateSecret.ts +++ b/src/utils/generateSecret.ts @@ -1,9 +1,9 @@ -import { random } from '@lukeed/csprng'; +import { randomBytes } from 'crypto'; import { ethers } from 'ethers'; const generateSecret = () => { const RANDOM_BITS = 256; - const rand = random(RANDOM_BITS); + const rand = randomBytes(RANDOM_BITS); const secret = ethers.utils.keccak256(rand); return secret; }; diff --git a/src/utils/getAvailableFundsSources.ts b/src/utils/getAvailableFundsSources.ts index 4a11576..46f90e5 100644 --- a/src/utils/getAvailableFundsSources.ts +++ b/src/utils/getAvailableFundsSources.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import type { Source } from '../types'; +import type { Source } from '../types.js'; export default function getAvailableFundsSources( expenseType: 'amount' | 'network_fee' | 'orion_fee', diff --git a/src/utils/getBalance.ts b/src/utils/getBalance.ts index 5cdcd2f..8ade83c 100644 --- a/src/utils/getBalance.ts +++ b/src/utils/getBalance.ts @@ -1,10 +1,10 @@ import { ERC20__factory, type Exchange } from '@orionprotocol/contracts'; -import type BigNumber from 'bignumber.js'; +import type { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; -import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION } from '../constants'; -import type { OrionAggregator } from '../services/OrionAggregator'; -import denormalizeNumber from './denormalizeNumber'; +import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION } from '../constants/index.js'; +import type { OrionAggregator } from '../services/OrionAggregator/index.js'; +import denormalizeNumber from './denormalizeNumber.js'; export default async function getBalance( orionAggregator: OrionAggregator, diff --git a/src/utils/getBalances.ts b/src/utils/getBalances.ts index d9904b4..aee1b72 100644 --- a/src/utils/getBalances.ts +++ b/src/utils/getBalances.ts @@ -1,8 +1,8 @@ import type { Exchange } from '@orionprotocol/contracts'; -import type BigNumber from 'bignumber.js'; +import type { BigNumber } from 'bignumber.js'; import type { ethers } from 'ethers'; -import type { OrionAggregator } from '../services/OrionAggregator'; -import getBalance from './getBalance'; +import type { OrionAggregator } from '../services/OrionAggregator/index.js'; +import getBalance from './getBalance.js'; export default async ( balancesRequired: Partial>, diff --git a/src/utils/index.ts b/src/utils/index.ts index 40b8c70..4c0b2c1 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,20 +1,20 @@ -export { default as calculateFeeInFeeAsset } from './calculateFeeInFeeAsset'; -export { default as calculateNetworkFee } from './calculateNetworkFee'; -export { default as calculateNetworkFeeInFeeAsset } from './calculateNetworkFeeInFeeAsset'; -export { default as calculateOrionFeeInFeeAsset } from './calculateOrionFeeInFeeAsset'; -export { default as checkIsToken } from './checkIsToken'; -export { default as generateSecret } from './generateSecret'; -export { default as denormalizeNumber } from './denormalizeNumber'; -export { default as normalizeNumber } from './normalizeNumber'; -export { default as isNetworkCodeInEnvironment } from './isNetworkCodeInEnvironment'; -export { default as parseExchangeTradeTransaction } from './parseExchangeTradeTransaction'; -export { default as toUpperCase } from './toUpperCase'; -export { default as toLowerCase } from './toLowerCase'; -export { default as isUppercasedNetworkCode } from './isUppercasedNetworkCode'; -export { default as getNativeCryptocurrency } from './getNativeCryptocurrency'; +export { default as calculateFeeInFeeAsset } from './calculateFeeInFeeAsset.js'; +export { default as calculateNetworkFee } from './calculateNetworkFee.js'; +export { default as calculateNetworkFeeInFeeAsset } from './calculateNetworkFeeInFeeAsset.js'; +export { default as calculateOrionFeeInFeeAsset } from './calculateOrionFeeInFeeAsset.js'; +export { default as checkIsToken } from './checkIsToken.js'; +export { default as generateSecret } from './generateSecret.js'; +export { default as denormalizeNumber } from './denormalizeNumber.js'; +export { default as normalizeNumber } from './normalizeNumber.js'; +export { default as isNetworkCodeInEnvironment } from './isNetworkCodeInEnvironment.js'; +export { default as parseExchangeTradeTransaction } from './parseExchangeTradeTransaction.js'; +export { default as toUpperCase } from './toUpperCase.js'; +export { default as toLowerCase } from './toLowerCase.js'; +export { default as isUppercasedNetworkCode } from './isUppercasedNetworkCode.js'; +export { default as getNativeCryptocurrency } from './getNativeCryptocurrency.js'; -export { default as isValidChainId } from './isValidChainId'; -export { default as isKnownEnv } from './isKnownEnv'; +export { default as isValidChainId } from './isValidChainId.js'; +export { default as isKnownEnv } from './isKnownEnv.js'; // export { default as HttpError } from './httpError'; -export * from './typeHelpers'; +export * from './typeHelpers.js'; diff --git a/src/utils/isKnownEnv.ts b/src/utils/isKnownEnv.ts index 3a1a03e..57c37e0 100644 --- a/src/utils/isKnownEnv.ts +++ b/src/utils/isKnownEnv.ts @@ -1,5 +1,5 @@ -import { knownEnvs } from '../config/schemas'; -import type { KnownEnv, } from '../types'; +import { knownEnvs } from '../config/schemas/index.js'; +import type { KnownEnv, } from '../types.js'; const isKnownEnv = (env: string): env is KnownEnv => { return knownEnvs.some((knownEnv) => knownEnv === env); diff --git a/src/utils/isNetworkCodeInEnvironment.ts b/src/utils/isNetworkCodeInEnvironment.ts index 56c4a82..0c44951 100644 --- a/src/utils/isNetworkCodeInEnvironment.ts +++ b/src/utils/isNetworkCodeInEnvironment.ts @@ -1,4 +1,4 @@ -import { chains, envs } from '../config'; +import { chains, envs } from '../config/index.js'; export default function isNetworkCodeInEnvironment(networkCode: string, env: string) { if (!(env in envs)) { diff --git a/src/utils/isUppercasedNetworkCode.ts b/src/utils/isUppercasedNetworkCode.ts index 90f3247..978f1cd 100644 --- a/src/utils/isUppercasedNetworkCode.ts +++ b/src/utils/isUppercasedNetworkCode.ts @@ -1,5 +1,5 @@ -import { networkCodes } from '../constants'; -import toUpperCase from './toUpperCase'; +import { networkCodes } from '../constants/index.js'; +import toUpperCase from './toUpperCase.js'; const isUppercasedNetworkCode = (value: string): value is Uppercase => networkCodes .map(toUpperCase).some((networkCode) => networkCode === value); diff --git a/src/utils/isValidChainId.ts b/src/utils/isValidChainId.ts index dd69b80..ade470a 100644 --- a/src/utils/isValidChainId.ts +++ b/src/utils/isValidChainId.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { SupportedChainId } from '../types'; +import { SupportedChainId } from '../types.js'; const isValidChainId = (chainId: string): chainId is SupportedChainId => { const { success } = z.nativeEnum(SupportedChainId).safeParse(chainId); diff --git a/src/utils/normalizeNumber.ts b/src/utils/normalizeNumber.ts index c544d0f..ea6b4ed 100644 --- a/src/utils/normalizeNumber.ts +++ b/src/utils/normalizeNumber.ts @@ -1,4 +1,4 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; /** diff --git a/tsconfig.json b/tsconfig.json index eb40d19..fe8cf4b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,8 @@ { - "extends": "@tsconfig/strictest/tsconfig.json", + "extends": [ + "@tsconfig/strictest/tsconfig.json", + "@tsconfig/esm/tsconfig.json" + ], "files": [ "./src/index.ts" ], @@ -12,97 +15,22 @@ "lib" ], "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - /* Projects */ - // "incremental": true, /* Enable incremental compilation */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ - "target": "ES2018", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [ - // "", - // ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ - // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - /* Modules */ - "module": "CommonJS", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* 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`. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + "target": "esnext", + "module": "esnext", + "moduleResolution": "nodenext", + "esModuleInterop": true, "resolveJsonModule": true, /* Enable importing .json files */ - // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ - /* Emit */ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ "outDir": "./lib/esm", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ - // "declarationDir": "./lib/typings/", /* Specify the output directory for generated declaration files. */ - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ - // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ - // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "noUncheckedIndexedAccess": true, "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - "importsNotUsedAsValues": null + }, + "ts-node": { + // Tell ts-node CLI to install the --loader automatically, explained below + "esm": true } } \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.cjs similarity index 65% rename from webpack.config.js rename to webpack.config.cjs index 486c445..7dce97b 100644 --- a/webpack.config.js +++ b/webpack.config.cjs @@ -30,15 +30,25 @@ module.exports = (env, argv) => { globalObject: "this" }, module: { - rules: [{ test: /\.t|js$/, use: "babel-loader" }] + rules: [{ + test: /\.t|js$/, + use: { + loader: "babel-loader", + options: { + plugins: [ + "@babel/plugin-syntax-import-assertions", + ], + } + } + }] }, resolve: { - extensions: ['.ts', '.js'], - fallback: { - "crypto": require.resolve("crypto-browserify"), - "buffer": require.resolve("buffer/"), - "stream": require.resolve("stream-browserify"), - } + extensions: ['.ts', '.js'], + fallback: { + "crypto": require.resolve("crypto-browserify"), + "buffer": require.resolve("buffer/"), + "stream": require.resolve("stream-browserify"), + } } }; }; \ No newline at end of file