refactor: send transactions with the official transaction client - #123
Merged
Conversation
Signing, broadcasting and waiting for execution now go through
BlockchainTransactionClient from
@partisiablockchain/blockchain-api-transaction-client instead of the
hand-rolled pipeline over the reader node's /blockchain endpoints.
- the chain id is read from the node (/chain) rather than derived from
the environment flag, so isMainnet is gone from createTransaction
- inclusion and spawned-event waiting use the client's condition waiter;
the spawned-event timeout is capped at 30s instead of its ten-minute
default, which no caller awaiting fetchResult would tolerate
- a wait that times out is still reported as { hasError: true } rather
than thrown, so ITransactionResult is unchanged; eventTrace is
rebuilt from the TransactionPointers of the executed tree and keeps
its { txHash, shardId } shape
- the broadcast retry for non-interactive backends is kept
Deletes src/transactions/helper.ts and the transaction half of
ShardedClient (nonce, broadcast, transaction lookup, event-trace walk,
finalization poller) along with putRequestOnce; ShardedClient is now
just shard derivation and the BYOC coin lookup. builderToBytesBe was a
one-line wrapper around rpc.getBytes() and is inlined.
Net -169 lines of SDK code. All 269 live testnet tests pass.
Claude-Session: https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb
|
Total Coverage: 92.00% Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Two changes aimed at consumers that bundle the SDK for a browser. `assert` was the last node builtin left in the source; esbuild, vite and webpack 5 all fail to resolve it for a browser target unless the consumer wires up a polyfill. It guarded one signature-length check, which is now a plain throw with a message. `privateKeyToAddress` exposes the address derivation consumers were pulling `partisia-blockchain-applications-crypto` in for. It sits on the lazily loaded signing path, so it costs nothing to anyone who does not call it. Claude-Session: https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb
|
Total Coverage: 91.83% Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
yeboster
added a commit
that referenced
this pull request
Aug 30, 2026
* fix: clean dist before build and retry throttled reader responses Three release-blocking issues found while reviewing v7 end to end. `yarn build` wrote into whatever `dist/` was already there, so files deleted from `src` survived in the published package: 7.0.0 packed with `dist/transactions/helper.js` (deleted in #123) and `dist/version.js` (deleted in #124), both reachable through the `./dist/*` exports pattern. `prepublishOnly` runs `build`, so the fix is a clean step in `build` itself. A reader node under load answers 429 or 503. `handleFetch` only resolves a body on HTTP 200, so those answers arrived at callers as `undefined` and surfaced as `Error: Contract not found` -- observed against the app's `/api/domains/recent` and `/api/domains/stats` routes while running its end-to-end suite. Retry them. 404 still falls through to `undefined`, which is how a missing AVL value is reported. `privateKeyToAddress` and the signing backends had no exports entry, leaving `@metanames/sdk/dist/transactions` as the only way in. Add `./transactions`. * fix: keep directory subpath imports resolvable 6.3.1 shipped no exports map, so `@metanames/sdk/dist/models` and its siblings resolved through plain file lookup. The exports map added in v7 turns those into `./dist/models.js`, which does not exist, and Node does not fall back to a directory index. Consumers on those specifiers would break on upgrade for no reason: each directory has an `index.js`, so the entries point at it. Claude-Session: https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb * chore: drop the scratch notes from the branch Working notes committed by accident in the previous commit. #125 squash merges, so main never carries them. Claude-Session: https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb * fix: drop the dist subpaths from the exports map `./dist/*` was carried over so consumers importing the build output kept working. That advertises the build layout as API: the paths hard-code the CJS tree, and nothing outside it can move without breaking someone. v7 is the major to stop. The named subpaths cover every use. Claude-Session: https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Final step of the plan to drop the unmaintained
partisia-blockchain-applications-*packages. #120 replaced the rpc reader, #122 replaced the signing crypto; this replaces the transaction pipeline itself.What changed
createTransactionnow builds aBlockchainTransactionClientfrom@partisiablockchain/blockchain-api-transaction-clientand callssignAndSend/waitForSpawnedEvents, instead of driving the reader node's/blockchainendpoints by hand.GET /chainreturns"Partisia Blockchain"/"Partisia Blockchain Testnet", so theisMainnetflag and the string it built are gone.fetchResult; capped at 30s, matching the previous 30x1s poll per event.{ hasError: true, errorMessage }rather than thrown, andeventTraceis rebuilt from theTransactionPointers of the executed tree, keeping{ txHash, shardId }.What was deleted
src/transactions/helper.ts—buildTransactionResult, the finalization poller,getChainId.builderToBytesBewas a one-line wrapper aroundrpc.getBytes()and is inlined at its 9 call sites.ShardedClient:getNonce,broadcastTransaction,getTransaction,getTransactionEventTraceand its recursive event walk,pollTransaction,shardUrl/shardUrlForAddress. It is now shard derivation plus the BYOC coin lookup.putRequestOncein the HTTP helper; nothing PUTs any more.7 files, +86 / -255.
Endpoints
The client talks to
/chain,/chain/accounts/{address},/chain/shards/{shard}/blocksand/chain/shards/{shard}/transactions/{id}. All verified 200 on bothnode1.testnet.partisiablockchain.comandreader.partisiablockchain.com; an unknown account returnsnonce: 1rather than a 404, matching the old fallback.Verification
tsc,eslint,yarn buildclean.npx jest -i: 269/269 passing against live testnet, in 44s (previous runs ~2.5min — the official waiter polls tighter than the fixed 1s/2s sleeps).Bundle
Code-split esbuild bundle of
dist/esm/index.js, versus currentmain:Small, as expected: no dependency leaves the graph here, the win is 169 fewer lines of SDK-maintained transaction plumbing. The dependency reductions were #120 and #122.
https://claude.ai/code/session_01GceWCwGXu66D1xEBDxZWBb
Follow-up commit: browser bundling
Two additions after looking at how the React app consumes this package:
assertis gone. It was the last node builtin in the source (one signature-length check in the MetaMask backend). esbuild/vite/webpack 5 all refuse to resolve it for a browser target without a polyfill; the SDK now bundles for--platform=browserwith none.privateKeyToAddress(privateKey)exported fromdist/transactions, on the lazy signing path. Consumers derive an address from a private key by importingpartisia-blockchain-applications-cryptodirectly; this is the same derivation over the official client, so that dependency can leave theirpackage.json. Verified to return the suite's known test address.Measured for an app-shaped entry (
MetaNamesSdk,Enviroment,RecordClassEnum,getRecordValidator), minified, code-split:@metanames/sdk@6.3.1RecordClassEnumonly269/269 live tests still pass.