Skip to content

refactor: replace unmaintained partisia rpc package with a native reader client - #120

Merged
yeboster merged 1 commit into
mainfrom
refactor/official-partisia-client
Aug 29, 2026
Merged

refactor: replace unmaintained partisia rpc package with a native reader client#120
yeboster merged 1 commit into
mainfrom
refactor/official-partisia-client

Conversation

@yeboster

@yeboster yeboster commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Why

partisia-blockchain-applications-rpc was last published 2024-03-18 and is unmaintained. It is not an official Partisia package — the official, actively maintained ones are the @partisiablockchain/* scope (abi-client 6.198.0, published 2026-07-02), which this SDK already depends on.

It accounted for 33 of the 45 advisories across the partisia dependency subtrees:

via advisories
axios 30
form-data 2 (1 critical, 1 high)
follow-redirects 1

…for what are plain GET/POST/PUT calls against the reader REST API.

What

Only six of its methods were ever used, and the SDK already talks to the same reader API directly via helpers/client.ts and AvlClient. This adds helpers/sharded-client.ts covering those six against the identical endpoints:

method endpoint
deriveShardId pure — int32be at offset 17 of the address, mod shard count
getNonce GET {shard}/blockchain/account/{address}
fetchCoins POST {global}/blockchain/accountPlugin/global
getTransaction GET {shard}/blockchain/transaction/{hash}
broadcastTransaction PUT {shard}/blockchain/transaction
getTransactionEventTrace recursive walk over spawned events

getRequest gained postRequest and putRequestOnce siblings. All three now route through the same abort-on-timeout fetch wrapper the read path already used, so the new write calls inherit the 30s ceiling rather than being able to hang.

IContractInfo is replaced by a local ContractInfo interface — only abi and serializedContract were ever read from it.

Behaviour changes, deliberate

  • getTransaction with no shard queries every shard and takes the first hit, matching the rpc package. A transaction hash does not encode its shard, and the event-trace walker depends on this.
  • Finality polling is now bounded. getTransactionForce looped forever; the replacement polls 30× at 1s then throws, so a stuck transaction surfaces instead of hanging the caller.
  • Broadcasting does not retry. It uses putRequestOnce — wrapping a PUT in promiseRetry would resubmit the transaction.

Measured

Rebased onto current main (with #115#119 in), re-measured against it.

Production dependency graph, npm ls --omit=dev --all:

packages
main 122
this branch 107

15 removed, none added: partisia-blockchain-applications-rpc, axios, mime-db, mime-types, form-data, follow-redirects, combined-stream, delayed-stream, asynckit, agent-base, https-proxy-agent, proxy-from-env, es-set-tostringtag, debug, ms.

Bundle, esbuild --bundle --minify --format=esm --splitting --platform=node:

bytes
all chunks on main 1,192,467
all chunks on this branch 915,298
−277,169 (−23.2%)

The 280,009-byte shared chunk holding axios is gone entirely. The entry chunk is unchanged at ~343 KB: after #119 the rpc client was only reachable from the lazily loaded signing chunks, so this shrinks what a signing consumer downloads, not what a read-only one does.

Test status

npx tsc --noEmit clean, eslint clean, yarn build clean, npx jest -i21 suites / 269 tests pass against the live testnet, including the signing, registration and record-update suites that exercise every replaced method end to end.

Remaining production advisories are all elliptic / bn.js beneath the official @partisiablockchain/abi-client. The resolutions block already pins elliptic ^6.6.1, which clears the critical; that entry should also gain "bn.js": "^5.2.3".

Not in this PR

partisia-blockchain-applications-crypto (11 advisories, 5 critical) stays. Replacing it with the official BlockchainTransactionClient / SenderAuthenticationKeyPair is the next step, written up in PLAN-drop-unmaintained-partisia-deps.md. partisia-blockchain-applications-sdk stays too — it is the browser wallet connector and has no official replacement.

https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb

@github-actions

Copy link
Copy Markdown

Total Coverage: 90.01%

Coverage Report
File Branch Funcs Lines Uncovered Lines
src
   actions.ts 100% 100% 100%
   index.ts 100% 100% 100%
   interface.ts 100% 100% 100%
   meta-names-sdk.ts 75% 75% 95.65% 22, 44, 45
   partisia-name-system.ts 58% 87.50% 84.07% 106, 114, 12, 139, 152, 160, 164, 169, 170, 171, 178, 180, 188, 189, 19, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 22, 220, 221, 222, 29, 33, 42, 49, 54, 55, 7, 78, 82
   version.ts 100% 100% 100%
src/actions
   domain.ts 64.29% 100% 100% 35, 44, 56, 71, 74
   record.ts 77.78% 100% 100% 14, 48
src/models
   domain.ts 100% 83.33% 95.95% 45, 46, 47
   index.ts 100% 100% 100%
src/models/helpers
   domain.ts 100% 100% 100%
src/providers
   config.ts 66.67% 100% 98.11% 40, 49, 50
   index.ts 100% 100% 100%
   secrets.ts 45.45% 62.50% 78.57% 19, 23, 24, 25, 26, 27, 29, 30, 44, 50, 51, 52, 53, 56, 57, 58, 59, 62, 63, 64, 65
src/providers/config
   mainnet.ts 100% 100% 100%
   testnet.ts 100% 100% 100%
src/repositories
   contract-repository.ts 76.19% 100% 95.65% 101, 112, 126, 127, 128, 129, 131, 132, 133, 134, 136, 137, 138, 139, 141, 142, 151, 167, 189, 205, 32, 44, 45, 55, 61
   domain-repository.ts 60% 100% 100% 102, 113, 117, 118, 133, 142, 150, 176, 220, 225, 240, 256, 262, 269, 34, 53, 54, 96, 98, 99
   index.ts 100% 75% 100%
   record-repository.ts 71.43% 100% 100% 24, 34, 50, 60
src/repositories/contracts
   meta-names-contract-repository.ts 84.62% 88.89% 88.66% 58, 59, 60, 61, 62, 63, 64, 65, 77, 78, 79, 80, 90
src/repositories/helpers
   avl-client.ts 80% 77.78% 61.62% 16, 22, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95
   client.ts 92.31% 100% 100% 54
   contract.ts 75% 100% 92.45% 41, 42, 43, 44, 45, 50
   sharded-client.ts 57.69% 100% 88.24% 109, 109, 110, 111, 112, 113, 114, 115, 116, 117, 121, 138, 155, 156, 157, 158, 160, 161, 162, 163, 164, 176, 176, 177, 178, 179, 180, 181, 59, 67, 81, 84, 92
src/transactions
   helper.ts 84.62% 83.33% 88.54% 24, 25, 26, 27, 28, 29, 64, 65, 66, 67, 68, 88, 89
   index.ts 80% 50% 39.77% 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 164, 20, 21, 22, 23, 24, 25, 26, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
src/validators
   base-validator.ts 100% 100% 100%
   domain-validator.ts 87.50% 100% 100% 29, 30, 31
   index.ts 100% 100% 100%
   record-validator.ts 100% 100% 100%
src/validators/records
   default-validator.ts 100% 100% 100%
   discord-validator.ts 100% 100% 100%
   email-validator.ts 100% 100% 100%
   main-validator.ts 100% 100% 100%
   price-validator.ts 100% 100% 100%
   regex-validator.ts 100% 100% 100%
   twitter-validator.ts 100% 100% 100%
   uri-validator.ts 100% 100% 100%
   wallet-validator.ts 100% 100% 100%
test
test/helpers
   config.ts 0% 100% 100% 7
   helper.ts 100% 60% 68% 25, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 38, 39, 40, 41, 42
   index.ts 100% 100% 100%

Base automatically changed from feat/optional-signing-backends to main August 29, 2026 09:01
`partisia-blockchain-applications-rpc` was last published 2024-03-18 and is
no longer maintained. It contributed 33 of the 45 advisories in the partisia
dependency subtrees -- axios (30), form-data (critical + high) and
follow-redirects -- for what are plain GET/POST/PUT calls against the reader
REST API.

Only six of its methods were ever used, and the SDK already talks to that same
API directly through `helpers/client.ts` and `AvlClient`. This adds
`helpers/sharded-client.ts` covering those six against the same endpoints:

  deriveShardId              int32be at offset 17 of the address, mod shards
  getNonce                   GET  {shard}/blockchain/account/{address}
  fetchCoins                 POST {global}/blockchain/accountPlugin/global
  getTransaction             GET  {shard}/blockchain/transaction/{hash}
  broadcastTransaction       PUT  {shard}/blockchain/transaction
  getTransactionEventTrace   recursive walk over spawned events

`helpers/client.ts` gains `postRequest` and `putRequestOnce` siblings to
`getRequest`. All three go through the existing abort-on-timeout fetch wrapper,
so the new calls inherit the same 30s ceiling as the read path.

`getTransaction` with no shard queries every shard and takes the first hit, as
the rpc package did -- a transaction hash does not encode its shard, and the
event-trace walker depends on that behaviour.

Two behavioural notes:

- `getTransactionForce` looped forever waiting for finality. The replacement
  polls 30 times at 1s and then throws, so a stuck transaction surfaces instead
  of hanging the caller.
- Broadcasting uses `putRequestOnce`, which does not retry. `promiseRetry`
  around a PUT would resubmit the transaction.

`IContractInfo` is replaced by a local `ContractInfo` interface; only `abi` and
`serializedContract` were ever read from it.

Production dependency graph 122 -> 107 packages, axios and mime-db among them.
Bundled with esbuild (--bundle --minify --format=esm --splitting), total bytes
across all chunks 1,192,467 -> 915,298 (-277,169, -23.2%); the 280 KB shared
chunk holding axios is gone. The entry chunk is unchanged at ~343 KB, since
after #119 the rpc client only reached the lazily loaded signing chunks.

21 suites / 269 tests pass against live testnet.
@yeboster
yeboster force-pushed the refactor/official-partisia-client branch from fa1bbef to bb6d0e5 Compare August 29, 2026 09:09
@github-actions

Copy link
Copy Markdown

Total Coverage: 90.67%

Coverage Report
File Branch Funcs Lines Uncovered Lines
src
   actions.ts 100% 100% 100%
   index.ts 100% 100% 100%
   interface.ts 100% 100% 100%
   meta-names-sdk.ts 75% 75% 95.65% 22, 44, 45
   partisia-name-system.ts 58% 87.50% 84.07% 106, 114, 12, 139, 152, 160, 164, 169, 170, 171, 178, 180, 188, 189, 19, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 22, 220, 221, 222, 29, 33, 42, 49, 54, 55, 7, 78, 82
   version.ts 100% 100% 100%
src/actions
   domain.ts 64.29% 100% 100% 35, 44, 56, 71, 74
   record.ts 77.78% 100% 100% 14, 48
src/models
   domain.ts 100% 83.33% 95.95% 45, 46, 47
   index.ts 100% 100% 100%
src/models/helpers
   domain.ts 100% 100% 100%
src/providers
   config.ts 66.67% 100% 98.11% 40, 49, 50
   index.ts 100% 100% 100%
   secrets.ts 45.45% 62.50% 78.57% 19, 23, 24, 25, 26, 27, 29, 30, 44, 50, 51, 52, 53, 56, 57, 58, 59, 62, 63, 64, 65
src/providers/config
   mainnet.ts 100% 100% 100%
   testnet.ts 100% 100% 100%
src/repositories
   contract-repository.ts 76.19% 100% 95.65% 101, 112, 126, 127, 128, 129, 131, 132, 133, 134, 136, 137, 138, 139, 141, 142, 151, 167, 189, 205, 32, 44, 45, 55, 61
   domain-repository.ts 60% 100% 100% 102, 113, 117, 118, 133, 142, 150, 176, 220, 225, 240, 256, 262, 269, 34, 53, 54, 96, 98, 99
   index.ts 100% 75% 100%
   record-repository.ts 71.43% 100% 100% 24, 34, 50, 60
src/repositories/contracts
   meta-names-contract-repository.ts 84.62% 88.89% 86.14% 57, 58, 59, 60, 61, 62, 63, 64, 78, 79, 80, 81, 82, 83, 84, 94
src/repositories/helpers
   avl-client.ts 80% 77.78% 61.62% 16, 22, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95
   client.ts 92.86% 100% 100% 64
   contract.ts 75% 100% 92.45% 41, 42, 43, 44, 45, 50
   sharded-client.ts 57.69% 100% 88.24% 109, 109, 110, 111, 112, 113, 114, 115, 116, 117, 121, 138, 155, 156, 157, 158, 160, 161, 162, 163, 164, 176, 176, 177, 178, 179, 180, 181, 59, 67, 81, 84, 92
src/transactions
   helper.ts 84.62% 83.33% 94.32% 56, 57, 58, 59, 60, 80, 81
   index.ts 55.56% 42.86% 41.99% 100, 101, 102, 103, 104, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 157, 162, 175, 176, 177, 179, 179, 180, 181, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
src/validators
   base-validator.ts 100% 100% 100%
   domain-validator.ts 87.50% 100% 100% 29, 30, 31
   index.ts 100% 100% 100%
   record-validator.ts 100% 100% 100%
src/validators/idna
   index.ts 81.54% 100% 95.93% 108, 110, 110, 111, 118, 119, 120, 121, 122, 123, 124, 125, 136, 138, 139, 144, 151, 155, 168, 210, 46
   table.ts 100% 100% 100%
src/validators/records
   default-validator.ts 100% 100% 100%
   discord-validator.ts 100% 100% 100%
   email-validator.ts 100% 100% 100%
   main-validator.ts 100% 100% 100%
   price-validator.ts 100% 100% 100%
   regex-validator.ts 100% 100% 100%
   twitter-validator.ts 100% 100% 100%
   uri-validator.ts 100% 100% 100%
   wallet-validator.ts 100% 100% 100%
test
test/helpers
   config.ts 0% 100% 100% 7
   helper.ts 100% 60% 68% 25, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 38, 39, 40, 41, 42
   index.ts 100% 100% 100%

@yeboster
yeboster merged commit 899f5f8 into main Aug 29, 2026
8 checks passed
@yeboster
yeboster deleted the refactor/official-partisia-client branch August 29, 2026 09:39
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.

1 participant