Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: canary esm build and deprecating packages #535

Draft
wants to merge 10 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 0 additions & 47 deletions etc/replacements-ledger.js

This file was deleted.

47 changes: 0 additions & 47 deletions etc/replacements.js

This file was deleted.

6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module.exports = {
moduleNameMapper: {
...pathsToModuleNameMapper(packagePaths, { prefix: '<rootDir>/' }),
...pathsToModuleNameMapper(directoryPaths),
// '^crypto-es$': 'crypto-js'
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Expand Down Expand Up @@ -181,7 +182,10 @@ module.exports = {
extensionsToTreatAsEsm: ['.ts'],

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: ['^.+\\.json$', 'node_modules/(?!(eth-crypto)/)'],
transformIgnorePatterns: [
'^.+\\.json$',
'node_modules/(?!' + ['@noble/secp256k1'].join('|') + ')',
],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
Expand Down
1 change: 0 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"packages/wallets/*"
],
"version": "independent",
"useWorkspaces": true,
"command": {
"version": {
"message": "chore: release"
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"postinstall": "node etc/bootstrapEnv",
"build": "node etc/bootstrapEnv && lerna run build",
"build": "node etc/bootstrapEnv && patch-package && lerna run build",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Document the purpose and status of 8 wallet-related patches

Found 8 undocumented patches for wallet connectivity dependencies:

  • 5 Ledger hardware wallet patches (@ledgerhq/*)
  • 1 Trezor connection patch (@trezor/connect-web)
  • 1 WalletConnect provider patch
  • 1 store2 utility patch

Please document:

  1. The purpose of each patch and why it's needed
  2. Whether these are temporary workarounds or permanent solutions
  3. If there are related upstream issues that need to be tracked
🔗 Analysis chain

Document patch-package usage.

The addition of patch-package to build and bootstrap scripts indicates custom patches are being applied. Please:

  1. Document the patches in the PR description
  2. Add a README section explaining which packages are patched and why
  3. Consider if these patches are temporary or need upstream fixes

Also applies to: 38-38

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for existing patches
fd -t f . patches/

Length of output: 375


Script:

#!/bin/bash
# Check README files and documentation
echo "=== Searching for patch documentation in README files ==="
fd -t f -e md . | xargs rg -i "patch" -C2

echo -e "\n=== Checking PR description if available ==="
gh pr view --json body | jq -r .body

Length of output: 361

🧰 Tools
🪛 GitHub Actions: Publish canary branch

[warning] Missing peer dependency '@babel/core' for multiple packages


[warning] Incorrect peer dependency for typedoc-monorepo-link-types, requires [email protected]

"generate:core-proto-ts": "./proto/core/gen.sh",
"publish:core-proto-ts": "./proto/core/publish.sh",
"generate:indexer-proto-ts": "./proto/indexer/gen.sh",
Expand All @@ -35,10 +35,11 @@
"build:patch:publish": "yarn build:fresh && yarn patch && yarn lerna:publish",
"patch": "lerna version patch",
"clean-up": "lerna run clean && shx rm -rf .build-cache *.log coverage junit.xml",
"bootstrap": "yarn clean-up && yarn install",
"bootstrap": "yarn clean-up && yarn install && patch-package",
"test": "jest",
"test:sdk-ts:core:stargate": "jest ./packages/sdk-ts/src/core/stargate",
"test:sdk-ts:core:modules": "jest ./packages/sdk-ts/src/core/modules",
"test:sdk-ts:core:account": "jest ./packages/sdk-ts/src/core/account",
"test:sdk-ts:core": "jest ./packages/sdk-ts/src/core",
"test:sdk-ts:utils": "jest ./packages/sdk-ts/src/utils",
"test:sdk-ts:client": "jest ./packages/sdk-ts/src/client",
Expand Down Expand Up @@ -70,8 +71,8 @@
"@babel/preset-env": "^7.19.0",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@types/jest": "^29.4.0",
"@types/node": "^22.9.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.1",
Comment on lines +74 to +75
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Address peer dependency warnings.

The pipeline shows warnings about missing peer dependencies:

  1. @babel/core is missing
  2. typedoc-monorepo-link-types requires [email protected]

Consider:

  1. Adding @babel/core as a dev dependency
  2. Updating typedoc to match the required version or updating typedoc-monorepo-link-types

Also applies to: 93-96, 100-100, 112-112

🧰 Tools
🪛 GitHub Actions: Publish canary branch

[warning] Missing peer dependency '@babel/core' for multiple packages


[warning] Incorrect peer dependency for typedoc-monorepo-link-types, requires [email protected]

"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"babel-jest": "^29.4.3",
Expand All @@ -89,13 +90,14 @@
"eslint-plugin-markdown": "^2.2.1",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.2",
"jest": "^29.4.3",
"jest": "^29.7.0",
"jest-junit": "^15.0.0",
"jest-resolve": "^29.7.0",
"lerna": "6.6.1",
"lerna": "8.1.9",
"lint-staged": "^11.1.2",
"live-server": "^1.2.1",
"markdownlint-cli": "^0.28.1",
"patch-package": "^8.0.0",
"prettier": "^2.4.1",
"serve": "^12.0.1",
"shx": "^0.3.4",
Expand All @@ -107,11 +109,10 @@
"tsconfig-paths": "^4.2.0",
"typedoc": "^0.25.11",
"typedoc-monorepo-link-types": "^0.0.4",
"typescript": "^5.1.1"
"typescript": "^5.7.2"
},
"resolutions": {
"@ethereumjs/tx": "^4.1.1",
"**/libsodium": "npm:@bangjelkoski/noop",
"**/libsodium-wrappers": "npm:@bangjelkoski/noop"
"@solana/web3.js": "1.98.0",
"rpc-websockets": "9.0.4"
}
}
4 changes: 2 additions & 2 deletions packages/exceptions/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const baseConfig = require('../../jest.config.js')
import baseConfig from '../../jest.config.js'

module.exports = {
export default {
...baseConfig,
globals: {
'ts-jest': {
Expand Down
9 changes: 5 additions & 4 deletions packages/exceptions/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@injectivelabs/exceptions",
"description": "List of exceptions that can be reused throughout Injective's projects.",
"version": "1.14.40",
"version": "1.14.41-alpha.0",
"sideEffects": false,
"license": "Apache-2.0",
"type": "module",
"types": "dist/cjs/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -55,9 +56,9 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/grpc-web": "^0.0.1",
"@injectivelabs/ts-types": "^1.14.40",
"http-status-codes": "^2.2.0",
"http-status-codes": "^2.2.0"
},
"devDependencies": {
"shx": "^0.3.2"
},
"gitHead": "6442ae377bbfb3459d2fb3a44c650630a5b7f445"
Expand Down
36 changes: 33 additions & 3 deletions packages/exceptions/src/exceptions/types/codes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
import { grpc, grpcPkg } from '../utils/grpc.js'
import * as grpcPkg from '@injectivelabs/grpc-web'
import { StatusCodes } from 'http-status-codes'

export enum GrpcErrorCode {
OK = 0,
Canceled = 1,
Unknown = 2,
InvalidArgument = 3,
DeadlineExceeded = 4,
NotFound = 5,
AlreadyExists = 6,
PermissionDenied = 7,
ResourceExhausted = 8,
FailedPrecondition = 9,
Aborted = 10,
OutOfRange = 11,
Unimplemented = 12,
Internal = 13,
Unavailable = 14,
DataLoss = 15,
Unauthenticated = 16,
}

export const grpcErrorCodeToErrorCode = <T extends number>(
grpcErrorCode: T,
): GrpcErrorCode => {
return grpcErrorCode as GrpcErrorCode
}

export enum TransactionChainErrorModule {
Auction = 'auction',
CosmosSdk = 'sdk',
Expand Down Expand Up @@ -767,8 +793,12 @@ export type IndexerApiErrorCode = number

export const UnspecifiedErrorCode = -1

export type ErrorCode = StatusCodes | typeof UnspecifiedErrorCode | grpcPkg.grpc.Code
export const GRPC_REQUEST_FAILED = grpc.Code.Unavailable
export type ErrorCode =
| grpcPkg.grpc.Code
| StatusCodes
| typeof UnspecifiedErrorCode
| GrpcErrorCode
export const GRPC_REQUEST_FAILED = GrpcErrorCode.Unavailable

export type ErrorContextCode =
| ChainAuctionErrorCodes
Expand Down
4 changes: 2 additions & 2 deletions packages/exceptions/tsconfig.build.esm.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"module": "ESNext",
"module": "NodeNext",
"outDir": "./dist/esm",
"rootDir": "./src",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "ESNext",
"moduleResolution": "Bundler",
"moduleResolution": "NodeNext",
"tsBuildInfoFile": "../../.build-cache/exceptions.esm.tsbuildinfo"
}
}
11 changes: 4 additions & 7 deletions packages/exceptions/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"rootDir": "./src",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist/cjs",
"tsBuildInfoFile": "../../.build-cache/exceptions.tsbuildinfo"
},
"include": [
"./src/**/*.ts",
],
"exclude": [
"./src/**/*.spec.ts",
"./src/**/*.test.ts"
],
"include": ["./src/**/*.ts"],
"exclude": ["./src/**/*.spec.ts", "./src/**/*.test.ts"]
}
4 changes: 2 additions & 2 deletions packages/networks/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const baseConfig = require('../../jest.config.js')
import baseConfig from '../../jest.config.js'

module.exports = {
export default {
...baseConfig,
globals: {
'ts-jest': {
Expand Down
9 changes: 5 additions & 4 deletions packages/networks/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "@injectivelabs/networks",
"description": "Endpoints, networks, etc. Can be reused throughout Injective's projects.",
"version": "1.14.41-beta.1",
"version": "1.14.41-alpha.0",
"sideEffects": false,
"type": "module",
"license": "Apache-2.0",
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -55,9 +56,9 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.14.40",
"@injectivelabs/ts-types": "^1.14.40",
"@injectivelabs/utils": "^1.14.40",
"@injectivelabs/ts-types": "^1.14.41-alpha.0"
},
"devDependencies": {
"shx": "^0.3.2"
},
"gitHead": "6442ae377bbfb3459d2fb3a44c650630a5b7f445"
Expand Down
3 changes: 2 additions & 1 deletion packages/networks/src/chainInfos.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ChainId, EthereumChainId } from '@injectivelabs/ts-types'
import { INJ_DENOM } from '@injectivelabs/utils'
import { ChainInfo } from './types.js'

const INJ_DENOM = 'inj'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Migration of INJ_DENOM constant appears incomplete

The constant is now duplicated across the codebase:

  • Defined in packages/utils/src/constants.ts
  • Newly added in packages/networks/src/chainInfos.ts
  • Still imported from @injectivelabs/utils in multiple test files under packages/sdk-ts/

If the goal is to deprecate @injectivelabs/utils, the constant should be fully migrated to the new location and all imports should be updated accordingly.

🔗 Analysis chain

LGTM! Moving INJ_DENOM locally aligns with package deprecation goals.

The change reduces external dependencies by moving the constant locally, which is consistent with the PR's refactoring objectives.

Let's verify there are no inconsistencies in the INJ_DENOM value across the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other declarations or usages of INJ_DENOM
# to ensure consistency across the codebase
rg -g '!*.{json,md}' "INJ_DENOM.*=.*['\"]inj['\"]" -A 1

Length of output: 293


Script:

#!/bin/bash
# Search for imports of INJ_DENOM from utils package
rg "import.*\{.*INJ_DENOM.*\}.*from.*@injectivelabs/utils" -A 1

# Also check for any other files still using the utils constant
ast-grep --pattern 'from "@injectivelabs/utils"'

Length of output: 1088


export const mainnetChainInfo: ChainInfo = {
feeDenom: INJ_DENOM,
chainId: ChainId.Mainnet,
Expand Down
17 changes: 3 additions & 14 deletions packages/networks/tsconfig.build.esm.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"module": "ESNext",
"module": "NodeNext",
"outDir": "./dist/esm",
"rootDir": "./src",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "ESNext",
"moduleResolution": "Bundler",
"moduleResolution": "NodeNext",
"tsBuildInfoFile": "../../.build-cache/networks.esm.tsbuildinfo"
},
"references": [
{
"path": "../exceptions/tsconfig.build.esm.json"
},
{
"path": "../ts-types/tsconfig.build.esm.json"
},
{
"path": "../utils/tsconfig.build.esm.json"
}
]
}
}
11 changes: 4 additions & 7 deletions packages/networks/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"rootDir": "./src",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist/cjs",
"tsBuildInfoFile": "../../.build-cache/networks.tsbuildinfo"
},
"include": [
"./src/**/*.ts",
],
"exclude": [
"./src/**/*.spec.ts",
"./src/**/*.test.ts"
]
"include": ["./src/**/*.ts"],
"exclude": ["./src/**/*.spec.ts", "./src/**/*.test.ts"]
}
Loading