Skip to content

refactor: Modernize Adena#809

Open
clockworkgr wants to merge 14 commits intoonbloc:mainfrom
clockworkgr:feat/modernize
Open

refactor: Modernize Adena#809
clockworkgr wants to merge 14 commits intoonbloc:mainfrom
clockworkgr:feat/modernize

Conversation

@clockworkgr
Copy link
Copy Markdown

@clockworkgr clockworkgr commented Apr 2, 2026

Goals:

  • Migrate to pnpm from yarn
  • Typescript v6
  • Bring deps up-to-date
  • gno-js-client and tm2-js-client to v2
  • Latest eslint + stylistic (remove prettier)
  • Modern build-system/bundler (tsup or tsdown, remove babel/webpack)

New files created

  - pnpm-workspace.yaml - Workspace packages definition (replaces workspaces in package.json)
  - .npmrc - pnpm config: node-linker=hoisted, ignore-scripts=true
  - pnpm-lock.yaml - Generated lockfile

  Files modified

  - package.json - Updated packageManager to pnpm@9.15.4, removed workspaces array, removed @yarnpkg/sdks devDep, converted resolutions to pnpm.overrides, added pnpm.packageExtensions (from
  .yarnrc.yml), added @types/minimatch override (fix for stub package hoisting), converted all scripts to pnpm, added missing build:storybook script
  - packages/adena-extension/package.json - Changed workspace deps to workspace:* protocol
  - packages/adena-torus-signin/package.json - Removed packageManager and resolutions
  - packages/adena-module/rollup.config.js - Added explicit include patterns for rpt2 (fix for picomatch extglob compatibility)
  - packages/adena-module/tsconfig.json - Added skipLibCheck: true (fixes @types/node compatibility with TS 4.9.5)
  - packages/adena-torus-signin/tsconfig.json - Added skipLibCheck: true
  - .github/actions/setup/action.yml - Added pnpm/action-setup@v4, changed cache to pnpm
  - .github/workflows/pull-request-test.yml - yarn -> pnpm install/pnpm
  - .github/workflows/build-deploy.yml - yarn -> pnpm install/pnpm
  - .husky/pre-commit - yarn lint-staged -> pnpm lint-staged
  - .gitignore - Removed yarn entries, added pnpm-debug.log*, added yarn.lock
  - README.md / packages/adena-module/README.md - yarn -> pnpm in commands

  Files deleted

  - .yarn/ (entire directory - plugins, releases, sdks)
  - .yarnrc.yml, .yarnrc
  - yarn.lock

  Verification

  - pnpm install - 1699 packages installed
  - pnpm build:module - Both adena-module and adena-torus-signin build successfully
  - pnpm build:service - Extension builds successfully (webpack compiled with only size warnings)
  - pnpm run test - 121 test suites, 200 tests all passing
@clockworkgr clockworkgr requested a review from a team as a code owner April 2, 2026 10:28
@clockworkgr clockworkgr marked this pull request as draft April 2, 2026 10:29
Replace legacy build stack (Babel, Rollup, Jest, Prettier, legacy ESLint)
with modern equivalents (tsdown, Vitest, flat ESLint config with @Stylistic).

Replace libsodium-wrappers-sumo (~350KB WASM) with lightweight pure-JS
@noble packages for all three crypto operations:
- Argon2id: @noble/hashes/argon2
- Ed25519 keypair/sign/verify: @noble/curves/ed25519
- XChaCha20-Poly1305 AEAD: @noble/ciphers/chacha

This eliminates the WASM initialization overhead (no more `await sodium.ready`)
while maintaining full API compatibility — all methods remain async to avoid
breaking callers.

Simplify platform-detection shims left over from the Webpack/Babel era:
- pbkdf2.ts: Remove getCryptoModule/getSubtle/pbkdf2Sha512Subtle/
  pbkdf2Sha512Crypto cascade; delegate directly to @noble/hashes/pbkdf2
  which works universally in Node and browsers.
- random.ts: Remove window/self/msCrypto/require("crypto") fallback chain;
  use globalThis.crypto.getRandomValues() which is standard in all modern
  runtimes.

Fix all ESLint errors:
- Remove all `any` types from pbkdf2.ts and random.ts (eliminated by the
  refactors above).
- Add targeted eslint-disable for intentionally loose interop types in
  multisig.ts (AminoMessage, ProtoMessage) and messages.ts
  (encodeMessageValue, Document.msgs).
- Fix pre-existing build errors in messages.ts: loosen encodeMessageValue
  parameter type to match actual callers, fix null vs undefined in MsgRun
  send field, add MemPackage cast.
- Add explicit vitest imports (describe, it, expect, etc.) to all spec files.
- Fix missing .js extensions on internal imports for ESM compatibility.

All 26 tests pass, build succeeds with zero lint errors.
      Migrate adena-extension from legacy Webpack/Babel/Jest/Prettier toolchain
      to modern Vite/Vitest/ESLint stack, matching patterns from adena-module.

      Bundler: Webpack 5 + Babel -> Vite 6 + @crxjs/vite-plugin
      - Replace 25 webpack/babel dependencies with 4 (vite, crxjs, react plugin, node polyfills)
      - Create vite.config.ts with CRXJS for MV3 extension building, 16 path aliases,
        polyfill shim resolution for pnpm strict mode, and lottie-web light build alias
      - Update manifest.json to reference source TS files (CRXJS convention)
      - Create popup.html, register.html, security.html at project root as Vite entry points
      - Copy static assets (icons, fonts) to public/ for Vite static serving
      - Fix lottie-web import from non-standard CJS default to standard ESM default import
      - Delete webpack.config.js, .babelrc.json

      Linting: ESLint 8 + Prettier -> ESLint 10 + @Stylistic
      - Replace 11 eslint/prettier deps with 7 modern equivalents
      - Create eslint.config.mjs (flat config) with @Stylistic for formatting,
        react/react-hooks plugins, simple-import-sort, typescript-eslint
      - Single quotes, 2-space indent, trailing commas, sorted imports
      - Disable React Compiler rules from react-hooks v7 (not using React Compiler)
      - Downgrade pre-existing violations to warnings (181 any, 279 exhaustive-deps, etc.)
      - Fix 11 unused catch variables, 1 missing Error cause
      - Run eslint --fix across 878 source files
      - Delete .eslintrc.json, .eslintignore, .prettierrc

      Testing: Jest 29 -> Vitest 4.1
      - Remove jest, babel-jest, ts-jest, jest-environment-jsdom, @types/jest, @jest/globals
      - Add vitest 4.1.2, update @testing-library/jest-dom to 6.9.1
      - Create vitest.config.ts with path aliases, jsdom env, 30s timeout,
        SALT_KEY env var for argon2id key derivation in migration tests
      - Create vitest.setup.ts with @testing-library/jest-dom/vitest matchers
      - Replace 3 jest.fn() calls with vi.fn()
      - Delete jest.config.js, jest.setup.js, svgTransformer.js
      - All 116 test files pass (174 tests)

      TypeScript: 4.9.5 -> 6.0.2
      - Update tsconfig: target es5->es2020, module esnext->es2022,
        moduleResolution node->bundler, lib dom+es5+es6->dom+es2022
      - Remove unnecessary allowJs, downlevelIteration options
      - Remove node/jest/@types/styled-components from types array
      - Exclude spec/test/stories from main type-checking
      - 13 pre-existing type errors from tm2-js-client version mismatch (not new)

      Dependency cleanup:
      - Remove @types/styled-components (v6 bundles types)
      - Update @types/react 18.2.21->18.3.28, @types/react-dom 18.2.7->18.3.7
      - Add lodash as explicit dependency (was implicit via webpack hoisting)
      - Sort devDependencies alphabetically
      - Clean lockfile
- Refactor GnoProvider to use Tm2Client.abciQuery() via @gnolang/tm2-rpc instead of raw HTTP calls (axios.post, fetch, RestService.post).

- Remove the getStatus() override (inherited from BaseTm2Provider), rewrite getGasPrice(), simulateTx(), and getRealmDocument() to use the new ABCI query API, and clean up unused utilities from utils.ts.

- Also fix three TypeScript errors:
  - adena-provider: use async GnoProvider.create() instead of sync constructor
  - signature-list-item.styles: replace theme.white with theme.neutral._1
  - approve-login: wrap navigate() call to discard Promise return

- Fix HighlightNumber crash on empty string by guarding BigNumber input, and add explicit vitest imports to all 116 test files.
@clockworkgr
Copy link
Copy Markdown
Author

Done for public modules.

Pending for torus-signin

Builds/Tests fine.

Next step: extended manual testing

@clockworkgr clockworkgr marked this pull request as ready for review April 8, 2026 14:12
run: |
yarn
yarn build
pnpm install
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing --frozen-lockfile

},
build: {
assetsInlineLimit: 0,
sourcemap: true,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Production source maps expose the full wallet source code, making it easier for attackers to study the code for vulnerabilities.

Set to false or 'hidden' for production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants