This document tracks the planned work to convert 0xPolygon/matic.js into a
pnpm monorepo, add a viem provider plugin, and consolidate the existing web3
and ethers provider plugins from their standalone repos.
| Phase | PR | Description | Status |
|---|---|---|---|
| 1a | PR 1 | Monorepo structure — move core to packages/maticjs/, add workspace tooling |
✅ #463 |
| 1b | PR 2 | ESLint, commitlint, vitest, GitHub Actions workflows | ✅ #463 |
| 2 | PR 3 | Add @maticnetwork/maticjs-viem in packages/viem/ |
⬜ next |
| 3a | PR 4 | Migrate maticjs-web3 into packages/web3/, archive external repo |
⬜ |
| 3b | PR 5 | Migrate maticjs-ethers into packages/ethers/, archive external repo |
⬜ |
Out of scope: maticjs-plasma and maticjs-staking are domain bridge clients
(they extend BridgeClient, not IPlugin) and remain as independent repos.
Structural reorganisation only. No source code changes. pnpm publish of
@maticnetwork/maticjs must produce an identical artefact before and after.
-
pnpm-workspace.yaml -
.npmrc—link-workspace-packages=false,auto-install-peers=true -
package.json(root — private, devDeps only,type: module) -
tsconfig.json(root) —files: [], referencespackages/maticjs/tsconfig.build.json -
.changeset/config.json—baseBranch: master -
.nvmrc— Node 24 -
.prettierrc.json -
.markdownlint-cli2.jsonc -
.lintstagedrc.js -
.husky/pre-commit,.husky/commit-msg,.husky/pre-push -
MIGRATION.md(scaffold) -
.github/CODEOWNERS
- Move
src/,webpack.config.js,license.js,build_helper/intopackages/maticjs/ - Move
examples/to repo root (cleaner for external consumers) - Move manual dev scripts (
debug.js,ether.js,config.js) tomanual/at repo root - Delete root copies after move
-
repositorywithdirectory: packages/maticjs(trusted publishing) -
publishConfig.access: public -
MIGRATION.mdinfilesarray - Remove
huskyhooks block; replacenpm runwithpnpm run - Add
typecheckandtestscripts - Add
@ethereumjs/commonandsafe-bufferas explicit deps (pnpm strict isolation exposed these were direct imports but only transitive under npm) - Pin
typescriptto^5.9.3(tested clean; earlier apparent TS5 breakage was a mixed npm/pnpm resolution artefact)
- Standalone tsconfig (not extending root) —
module: commonjs,moduleResolution: node,skipLibCheck: true,strict: false -
tsconfig.build.json— composite,rootDir: src, used by project references -
tsconfig.jsonincludessrc/**/*,tests/**/*,vitest.config.ts
- Delete broken nested test project (
test/package.json, jest@27, npm link, live-RPC dependencies) - Migrate
specs/index.ts→packages/maticjs/tests/map-promise.test.ts(vitest, 7 passing unit tests, no network required) - Add
vitest.config.ts
- Delete root
tslint.json,.eslintignore,package-lock.json
-
eslint.config.js—@polygonlabs/apps-team-lint@2.0.0,@tsconfig/node-tsplugin extraction forno-unused-varsoverride - Fix all lint errors in
packages/maticjs/src/(0 errors; 67 advisoryno-explicit-anywarnings in public plugin interfaces) - Two config-level overrides (not inline disables):
no-require-importsoff forhttp_request.ts(webpack BUILD_ENV pattern)no-default-exportoff forsrc/index.ts(semver-major API change, deferred)
-
commitlint.config.js— conventional commits -
markdownlint-cli2@^0.21.0; fix all violations in existing.mdfiles - Fix
README.md(wrong org, npm commands, outdated structure) - Fix
examples/README.md(npm install instructions, file: reference for local dev)
- Delete
.github/workflows/ci.yml(npm-based) - Delete
.github/workflows/github_doc_deploy.yml(dead since 2022) -
.github/actions/ci/action.yml— verbatim copy -
.github/actions/upsert-changeset-comment/action.yml— verbatim copy -
.github/actions/upsert-changeset-comment/dist/index.js— compiled bundle -
.github/actions/upsert-changeset-comment/dist/package.json -
ci-trigger.yml—branches: [master], calls./.github/actions/ci -
changeset-check.yml— localupsert-changeset-commentreference -
changeset-check-trigger.yml—branches: [master] -
npm-release.yml— threemain→mastersubstitutions -
npm-release-trigger.yml—branches: [master] -
claude-code-review.yml+claude-code-review-trigger.yml -
claude.yml+claude-trigger.yml
New package. Uses tsup. Requires Node 24 / @tsconfig/node-ts. No enums.
-
packages/viem/src/index.ts— re-exports -
packages/viem/src/types.ts—ViemClientConfig -
packages/viem/src/plugin.ts—ViemPlugin implements IPlugin -
packages/viem/src/web3-client.ts—ViemWeb3Client extends BaseWeb3Client -
packages/viem/src/contract.ts—ViemContract extends BaseContract -
packages/viem/src/contract-method.ts—ViemContractMethod extends BaseContractMethod -
packages/viem/src/big-number.ts—ViemBigNumber extends BaseBigNumber -
packages/viem/src/abi-utils.ts— converts bare Solidity type strings (e.g."uint256") to viemAbiParameter[]objects forencodeAbiParameters/decodeAbiParameters -
packages/viem/tests/web3-client.test.ts— unit tests with mocked clients -
packages/viem/MIGRATION.md
-
"name": "@maticnetwork/maticjs-viem" -
"repository"withdirectory: packages/viem -
"publishConfig": { "access": "public" } -
"files": ["dist", "MIGRATION.md"] -
exportsfield (CJS + ESM + types) -
peerDependencies:@maticnetwork/maticjs: "workspace:*",viem: "^2.0.0" - devDependencies:
tsup,vitest,typescript,@tsconfig/node24,@tsconfig/node-ts,viem,@maticnetwork/maticjs - scripts:
build(tsup),test(vitest run),typecheck(tsc --noEmit)
-
entry: ['src/index.ts'],format: ['cjs', 'esm'],dts: true,clean: true,external: ['@maticnetwork/maticjs', 'viem'],target: 'es2020'
-
tsconfig.json— extends root +@tsconfig/node-ts, includes src + tests -
tsconfig.build.json— composite,rootDir: src, includes only src
- Standard config
- Add
{ "path": "packages/viem/tsconfig.build.json" }toreferences
ViemClientConfig:{ publicClient: PublicClient; walletClient?: WalletClient }ViemPlugin.setup(): setsmatic.utils.Web3Client = ViemWeb3Client,matic.utils.BN = ViemBigNumber,matic.utils.isBN = (v) => typeof v === 'bigint'write()returnsITransactionWriteResultsynchronously — transaction is only sent whengetTransactionHash()is first called (lazy evaluation)encodeParameters/decodeParameters: useabi-utils.tsconverter because viem'sencodeAbiParameterstakes typedAbiParameter[], not Solidity stringsetheriumSha3: viem'skeccak256with hex-encoded concatenation of argsViemBigNumberwraps nativeBigInt; arithmetic via BigInt operators
-
pnpm exec changeset add— minor bump for new package@maticnetwork/maticjs-viem
Source copied from 0xPolygon/maticjs-web3. Replaces webpack 4 with tsup.
- Copy
src/from0xPolygon/maticjs-web3 -
packages/web3/MIGRATION.md
-
"name": "@maticnetwork/maticjs-web3"(unchanged npm name) -
"repository"withdirectory: packages/web3 -
"publishConfig": { "access": "public" } -
"files": ["dist", "MIGRATION.md"] -
exportsfield (same pattern aspackages/viem) - peerDependencies:
@maticnetwork/maticjs: "workspace:*",web3: "^1.8.0"(web3 v2 upgrade deferred) - devDependencies:
tsup,vitest,typescript,@tsconfig/node24,@tsconfig/node-ts,web3,@maticnetwork/maticjs
-
packages/web3/tsup.config.ts,tsconfig.json,tsconfig.build.json,vitest.config.ts - Replace karma/mocha tests with vitest unit tests
- Add
{ "path": "packages/web3/tsconfig.build.json" }to roottsconfig.jsonreferences
- Update
0xPolygon/maticjs-web3README: "This package has moved to 0xPolygon/matic.js. Final standalone release: vX.Y.Z." - Archive
0xPolygon/maticjs-web3on GitHub
-
pnpm exec changeset add— patch bump for@maticnetwork/maticjs-web3
Same process as PR 4.
- Copy
src/from0xPolygon/maticjs-ethers -
packages/ethers/MIGRATION.md
-
"name": "@maticnetwork/maticjs-ethers"(unchanged npm name) -
"repository"withdirectory: packages/ethers -
"publishConfig": { "access": "public" } -
"files": ["dist", "MIGRATION.md"] -
exportsfield - peerDependencies:
@maticnetwork/maticjs: "workspace:*",ethers: "^5.5.1"(ethers v6 upgrade deferred) - devDependencies:
tsup,vitest,typescript,@tsconfig/node24,@tsconfig/node-ts,ethers,@maticnetwork/maticjs
-
packages/ethers/tsup.config.ts,tsconfig.json,tsconfig.build.json,vitest.config.ts - Replace karma/mocha tests with vitest unit tests
- Add
{ "path": "packages/ethers/tsconfig.build.json" }to roottsconfig.jsonreferences
- Update
0xPolygon/maticjs-ethersREADME, archive repo
-
pnpm exec changeset add— patch bump for@maticnetwork/maticjs-ethers
| Item | Reason |
|---|---|
Migrate webpack → tsup in packages/maticjs/ |
Working build; low risk to defer |
Remove export default from src/index.ts |
Breaking public API change; needs semver-major |
Convert enum to const in packages/maticjs/src/ |
Enables erasableSyntaxOnly; significant churn |
| ethers v6 upgrade | API chasm; own migration guide and PR |
| web3 v2 upgrade | Same |
maticjs-plasma |
Extends BridgeClient, not IPlugin; stays independent |
maticjs-staking |
Same |