Repository navigation
feat(sdk): complete the typed build, sign, submit API for exchange actions - #168
Merged
Merged
Conversation
…tions - Document every operation builder with @param/@return/@throws like the method functions. - Cover cancellation at each stage in the docs and in tests: an abort before signing frees the nonce, an abort during signing burns it without posting, and submit forwards its signal. - Copy builder input with plain assignment (own __proto__ keys still preserved), which makes fresh builds cheaper, especially on Node. - Add .dev/perf/canonical_reuse.ts: paired offline direct/fresh/reused/staged measurements with stub, viem and fast wallets over in-memory and HTTP transports. - Move imports below the module headers in client.ts and _shell.ts and document prepareOnly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Most of the build → sign → submit core landed with #166: canonical builders for every exchange operation,
signAction/submitAction/executeAction,ExchangeClient.sign/submit/execute, cached L1 bytes for reused actions, and the stage and contract tests. This PR covers what #157 still needed:submitcannot recall a request that was already sent, and resubmitting the same signed request cannot apply it twice. A new test covers each case..dev/perf/canonical_reuse.tscompares direct, fresh, reused and staged calls. It uses stub, viem and fast (WASM) wallets over an in-memory transport and the realHttpTransport, and rotates cases inside each round. Results are below.immutableCopynow uses plain assignment instead ofObject.definePropertyper key, except for own__proto__keys, which are still defined explicitly. Key order, deep freezing and the prototype are unchanged, and a new test checks this. A fresh 100-order build on Node dropped from about 1.38x to 1.12x of the raw method.@param/@return/@throwsJSDoc like the method functions; the 6 alias re-exports have no JSDoc of their own. Imports inclient.tsand_shell.tsnow sit below the module header.executeWithShelldocumentsprepareOnly.Scope: nothing from #158–#161 is included (no dispatch policy, order batcher or per-operation entry-point changes).
bun run perfis untouched, so the CI perf suite fingerprint stays the same.Acceptance criteria
issuedstays 0 afterbuildOrder)._actions.test.ts, plussignCount/noncesin the published consumer check).OrderSuccessResponseassignments in tests and inconsumer.tsundertscnodenext).l1Cache.test.tscovers hash equality across nonces, vaults and expiry.__proto__-safe. Reconstructed or JSON-roundtripped actions and requests are rejected, and so is a cross-network submit.prepareRequest/submitPreparedare unchanged.clients.md, "Canonical actions and explicit execution").Measurements
bun|node .dev/perf/canonical_reuse.ts, Apple M3 Max. Each cell is the median of 11 rotating rounds after 3 warmup rounds, in µs per call, with the ratio todirect. CPU time only, using mocks: no network latency.direct: raworder()fresh:buildOrder()+executeAction()on every callreused: one built action passed toexecuteAction()staged: one built action, thensignAction()+submitAction()Bun 1.4.0
Node 24.10.0
What the numbers show:
executeAction, and the 1-order stub rows stay under 1.5 µs.Test plan
bun run check(format, lint, docs, types, ts7, jsdoc, export, imports)bun run test:offline: 2024 pass, 0 fail (19 in_actions.test.ts, including new immutable-copy and cancellation tests)bun run build, including the published consumer checks on Bun and Node.dev/perf/canonical_reuse.tson Bun and Node (tables above)Closes #157
🤖 Generated with Claude Code