Skip to content

type: TxResponse narrowing#3328

Open
tequdev wants to merge 10 commits into
XRPLF:mainfrom
tequdev:txresponse-type-narrowing
Open

type: TxResponse narrowing#3328
tequdev wants to merge 10 commits into
XRPLF:mainfrom
tequdev:txresponse-type-narrowing

Conversation

@tequdev
Copy link
Copy Markdown
Member

@tequdev tequdev commented Apr 24, 2026

High Level Overview of Change

Make TxResponse type-safe based on the binary field and api_version value in TxRequest. Previously, the response type did not precisely distinguish JSON and binary transaction responses, or API v1 and API v2 response shapes. Now TypeScript narrows the response type so tx_json, tx_blob, meta, and meta_blob are only available on the response variants where they are actually returned.

Context of Change

When using client.request() with a TxRequest, developers could not rely on the request fields to get an accurate response type. For example, binary: true still allowed JSON-only fields in the response type, and api_version: 1 required explicitly passing a generic type parameter to get the API v1 response shape.

This change adds TxBinaryRequest and TxJsonRequest, maps them to the correct TxVersionResponseMap, and updates Client.request() so the api_version literal from the request is used for response inference. This follows the existing type-narrowing pattern used by similar request/response pairs.

APIVersion=2 and binary=false

  • before
const txResponse = await testContext.client.request({
  command: 'tx',
  transaction: hash,
})

txResponse.result.tx_json =>  Transaction
txResponse.result.tx_blob => Not Defined
txResponse.result.meta => TransactionMeta | string | undefined
txResponse.result.meta_blob => TransactionMetadata
  • after
const txResponse = await testContext.client.request({
  command: 'tx',
  transaction: hash,
})

txResponse.result.tx_json =>  Transaction
txResponse.result.tx_blob => Not Defined
txResponse.result.meta => TransactionMeta | undefined
txResponse.result.meta_blob => Not Defined

APIVersion=2 and binary=true

  • before
const txResponse = await testContext.client.request({
  command: 'tx',
  transaction: hash,
  binary: true,
})

txResponse.result.tx_json =>  Transaction
txResponse.result.tx_blob => Not Defined
txResponse.result.meta => TransactionMeta | string | undefined
txResponse.result.meta_blob => TransactionMetadata | string | undefined
  • after
const txResponse = await testContext.client.request({
  command: 'tx',
  transaction: hash,
  binary: true,
})

txResponse.result.tx_json =>  Not Defined
txResponse.result.tx_blob => string
txResponse.result.meta => string | undefined
txResponse.result.meta_blob => string | undefined

APIVersion=1 and binary=false

  • before
const txResponse = await testContext.client.request({
  command: 'tx',
  transaction: hash,
  api_version: 1,
})


txResponse.result.Fee=> Defined (Transaction Field)
txResponse.result.tx_json => Not Defined
txResponse.result.tx_blob => Not Defined
txResponse.result.meta => TransactionMeta | string | undefined
txResponse.result.meta_blob => undefined
  • after
const txResponse = await testContext.client.request({
  command: 'tx',
  transaction: hash,
})

txResponse.result.Fee=> Defined (Transaction Field)
txResponse.result.tx_json =>  Not Defined
txResponse.result.tx_blob => Not Defined
txResponse.result.meta => TransactionMeta | undefined
txResponse.result.meta_blob => Not Defined

APIVersion=1 and binary=true

  • before
const txResponse = await testContext.client.request({
  command: 'tx',
  transaction: hash,
  api_version: 1,
  binary: true,
})

txResponse.result.Fee=> Defined (Transaction Field)
txResponse.result.tx_json => Not Defined
txResponse.result.tx_blob => Not Defined
txResponse.result.tx => Not Defined
txResponse.result.meta => TransactionMeta | string | undefined
txResponse.result.meta_blob => undefined
  • after
const txResponse = await testContext.client.request({
  command: 'tx',
  transaction: hash,
  binary: true,
})

txResponse.result.Fee=> Not Defined (Transaction Field)
txResponse.result.tx_json =>  Not Defined
txResponse.result.tx_blob => Not Defined
txResponse.result.tx => string
txResponse.result.meta => string | undefined
txResponse.result.meta_blob => undefined

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)

Did you update HISTORY.md?

  • No (this is a types-only change)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Client.request generics now infer API version from a request's api_version; BaseRequest.api_version now uses APIVersion; tx types split JSON vs binary requests/responses with a binary discriminant and format-specific result types; integration tests updated/added to validate shapes across API versions and formats.

Changes

Cohort / File(s) Summary
Type Definition Foundation
packages/xrpl/src/models/methods/baseMethod.ts
Changed BaseRequest.api_version from number to APIVersion and adjusted imports.
Client Generic Inference
packages/xrpl/src/client/index.ts
Updated Client.request signature so generic V is inferred from req.api_version when present, otherwise falls back to DEFAULT_API_VERSION.
Request-Response Mapping
packages/xrpl/src/models/methods/index.ts
Adjusted RequestResponseMap to distinguish TxBinaryRequest vs TxJsonRequest; added corresponding tx imports.
Tx Method Type Restructuring
packages/xrpl/src/models/methods/tx.ts
Refactored tx typings: introduced TxRequestBase, TxJsonRequest, TxBinaryRequest; replaced generic version-dependent BaseTxResult with format/version-specific result interfaces; added boolean B generic to select binary vs JSON result shapes.
Integration Tests
packages/xrpl/test/integration/requests/tx.test.ts, packages/xrpl/test/integration/submitAndWait.test.ts
Updated tx tests to assert JSON vs binary response shapes for api_version 1 and 2; added submitAndWait test validating non-binary TxResponse shape and absence of meta_blob.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • ckeshava
  • kuan121
  • ckniffen

Poem

🐰 I hopped through generics, soft and spry,

I split each tx where binary meets sky.
Versions hummed as I drew the line,
JSON and blobs now dance in kind.
A nibble for tidy types and rhyme. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'type: TxResponse narrowing' directly and concisely describes the main change—improving TypeScript type safety for TxResponse based on request parameters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description comprehensively covers the high-level overview, context, type of change, and test additions with detailed before/after examples.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (3)
packages/xrpl/src/models/methods/baseMethod.ts (1)

15-16: Stale JSDoc: default version.

The comment states "use version 1" if omitted, but DEFAULT_API_VERSION is RIPPLED_API_V2 (2). Consider updating the doc while touching this line.

📝 Proposed doc fix
-  /** The API version to use. If omitted, use version 1. */
+  /** The API version to use. If omitted, the client's default API version is used (currently 2). */
   api_version?: APIVersion
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/xrpl/src/models/methods/baseMethod.ts` around lines 15 - 16, The
JSDoc for the optional api_version property is stale (it says "use version 1") —
update the comment to reflect the actual default (DEFAULT_API_VERSION, which is
RIPPLED_API_V2 / version 2) or make it generic; locate the api_version?:
APIVersion declaration in baseMethod.ts and change the docstring to state that
omitting api_version will use DEFAULT_API_VERSION (RIPPLED_API_V2) or indicate
the current default version number.
packages/xrpl/src/models/methods/tx.ts (1)

108-120: RemoveIndexSignature reinvents a common utility; consider a simpler form.

The conditional-type wrapper (T extends unknown ? ... : never) is only needed if you want distribution over unions, but the chained string extends K ? never : number extends K ? never : symbol extends K ? never : K can be expressed more concisely. Also, standard KnownKeys<T> patterns exist.

♻️ Proposed simplification
-type RemoveIndexSignature<T> = T extends unknown
-  ? {
-      // Drop BaseTransaction's Record<string, unknown> index signature so
-      // unknown transaction fields are not treated as valid response fields.
-      [K in keyof T as string extends K
-        ? never
-        : number extends K
-          ? never
-          : symbol extends K
-            ? never
-            : K]: T[K]
-    }
-  : never
+// Drop BaseTransaction's Record<string, unknown> index signature so
+// unknown transaction fields are not treated as valid response fields.
+type RemoveIndexSignature<T> = T extends unknown
+  ? {
+      [K in keyof T as {} extends Record<K, unknown> ? never : K]: T[K]
+    }
+  : never

Not strictly required — the current implementation is correct. Feel free to ignore if you prefer the explicit form.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/xrpl/src/models/methods/tx.ts` around lines 108 - 120,
RemoveIndexSignature currently uses an unnecessary distributive conditional and
an overly verbose key-exclusion chain; simplify it by removing the `T extends
unknown ? ... : never` wrapper and remapping keys with a concise conditional
(for example use `K extends string ? K : never`) or adopt a standard KnownKeys
pattern so only real property names remain; update the type alias
RemoveIndexSignature<T> accordingly and keep the intent of dropping index
signatures from BaseTransaction.
packages/xrpl/src/models/methods/index.ts (1)

597-599: Consider re-exporting TxBinaryRequest and TxJsonRequest.

For consistency with LedgerEntryBinaryRequest / LedgerEntryJsonRequest (lines 581-582) and to allow users to explicitly type binary vs JSON tx requests, consider re-exporting the new request variants from the package barrel.

📝 Proposed export addition
   TransactionEntryRequest,
   TransactionEntryResponse,
   TxRequest,
+  TxBinaryRequest,
+  TxJsonRequest,
   TxResponse,
   TxV1Response,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/xrpl/src/models/methods/index.ts` around lines 597 - 599, The barrel
currently exports TxRequest, TxResponse, and TxV1Response but omits the new
TxBinaryRequest and TxJsonRequest; to fix, add re-exports for TxBinaryRequest
and TxJsonRequest alongside the existing Tx* exports in the methods index (same
area where LedgerEntryBinaryRequest / LedgerEntryJsonRequest are exported) so
consumers can explicitly type binary vs JSON transaction requests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/xrpl/src/models/methods/tx.ts`:
- Around line 122-134: The JSDoc says meta_blob/meta can be undefined but the
types declare them as required strings; update the interfaces TxBinaryResult
(meta_blob) and TxBinaryResultV1 (meta) to make those properties optional (e.g.,
change to meta_blob?: string and meta?: string) so the types match the
documentation and mirror the JSON path optional meta.
- Around line 44-69: The exported TxRequest type currently uses a boolean union
(binary?: boolean) and therefore doesn't distribute through the conditional in
RequestResponseMap, causing explicit TxRequest annotations to lose their
specific response typing; fix this by making TxRequest a discriminated union of
the concrete variants (i.e. define TxRequest as TxJsonRequest | TxBinaryRequest
or otherwise map TxRequest in RequestResponseMap to
TxVersionResponseMap<Version>), updating the existing TxRequest declaration to
reference the unique symbols TxJsonRequest and TxBinaryRequest so TypeScript
will properly narrow client.request(req) to the correct TxVersionResponseMap
based on the binary discriminator.

In `@packages/xrpl/test/integration/requests/tx.test.ts`:
- Around line 151-156: The test asserts that txBinaryResponse.result.meta_blob
is defined despite the comment and type TxBinaryResultV1 showing meta is a
string and meta_blob is absent; update the assertion to
assert.isUndefined(txBinaryResponse.result.meta_blob) (and keep the existing
`@ts-expect-error` removed or adjusted since accessing meta_blob is a type error
for TxBinaryResultV1) so the runtime expectation matches the V1 type — change
the assertion around txBinaryResponse.result.meta_blob accordingly in the
tx.test.ts test where txBinaryResponse (binary response) is validated.

In `@packages/xrpl/test/integration/submitAndWait.test.ts`:
- Around line 149-164: The test for submitAndWait is missing the ledger-closure
helper and explicit timeout, which can cause it to hang; update the test so the
call to testContext.client.submitAndWait(signedAccountSet) is executed alongside
the ledger closer by using Promise.all([ testContext.client.submitAndWait(...),
delayedLedgerAccept() ]) and pass the TIMEOUT constant as the third argument to
it(...) to match the other tests; locate the test block that constructs
accountSet and calls submitAndWait and add delayedLedgerAccept() and TIMEOUT
accordingly.

---

Nitpick comments:
In `@packages/xrpl/src/models/methods/baseMethod.ts`:
- Around line 15-16: The JSDoc for the optional api_version property is stale
(it says "use version 1") — update the comment to reflect the actual default
(DEFAULT_API_VERSION, which is RIPPLED_API_V2 / version 2) or make it generic;
locate the api_version?: APIVersion declaration in baseMethod.ts and change the
docstring to state that omitting api_version will use DEFAULT_API_VERSION
(RIPPLED_API_V2) or indicate the current default version number.

In `@packages/xrpl/src/models/methods/index.ts`:
- Around line 597-599: The barrel currently exports TxRequest, TxResponse, and
TxV1Response but omits the new TxBinaryRequest and TxJsonRequest; to fix, add
re-exports for TxBinaryRequest and TxJsonRequest alongside the existing Tx*
exports in the methods index (same area where LedgerEntryBinaryRequest /
LedgerEntryJsonRequest are exported) so consumers can explicitly type binary vs
JSON transaction requests.

In `@packages/xrpl/src/models/methods/tx.ts`:
- Around line 108-120: RemoveIndexSignature currently uses an unnecessary
distributive conditional and an overly verbose key-exclusion chain; simplify it
by removing the `T extends unknown ? ... : never` wrapper and remapping keys
with a concise conditional (for example use `K extends string ? K : never`) or
adopt a standard KnownKeys pattern so only real property names remain; update
the type alias RemoveIndexSignature<T> accordingly and keep the intent of
dropping index signatures from BaseTransaction.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 107ed799-ca21-4ac0-8ec2-e020f6c183d6

📥 Commits

Reviewing files that changed from the base of the PR and between 0d53664 and a105733.

📒 Files selected for processing (6)
  • packages/xrpl/src/client/index.ts
  • packages/xrpl/src/models/methods/baseMethod.ts
  • packages/xrpl/src/models/methods/index.ts
  • packages/xrpl/src/models/methods/tx.ts
  • packages/xrpl/test/integration/requests/tx.test.ts
  • packages/xrpl/test/integration/submitAndWait.test.ts

Comment thread packages/xrpl/src/models/methods/tx.ts Outdated
Comment thread packages/xrpl/src/models/methods/tx.ts
Comment thread packages/xrpl/test/integration/requests/tx.test.ts Outdated
Comment thread packages/xrpl/test/integration/submitAndWait.test.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/xrpl/src/models/methods/tx.ts (1)

1-6: ⚠️ Potential issue | 🔴 Critical

Drop unused RIPPLED_API_V2 import — CI is failing (TS6133).

The CI log reports that RIPPLED_API_V2 is declared but never read. Now that only RIPPLED_API_V1 is branched on in TxVersionResponseMap (line 184), RIPPLED_API_V2 is no longer referenced in this module.

🐛 Proposed fix
 import {
   APIVersion,
   DEFAULT_API_VERSION,
   RIPPLED_API_V1,
-  RIPPLED_API_V2,
 } from '../common'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/xrpl/src/models/methods/tx.ts` around lines 1 - 6, Remove the unused
import RIPPLED_API_V2 from the import list at the top of the file (currently
imported alongside APIVersion, DEFAULT_API_VERSION, and RIPPLED_API_V1) so the
symbol is no longer declared but unused; ensure only APIVersion,
DEFAULT_API_VERSION, and RIPPLED_API_V1 remain imported to match the usage in
TxVersionResponseMap and elsewhere in this module.
♻️ Duplicate comments (1)
packages/xrpl/src/models/methods/tx.ts (1)

44-69: ⚠️ Potential issue | 🟠 Major

TxRequest (binary?: boolean) still doesn’t distribute into the narrowed response in RequestResponseMap.

TxBinaryRequest uses binary: true and TxJsonRequest uses binary?: false. A value explicitly typed TxRequest (where binary?: boolean) matches neither variant and therefore falls through to the generic fallback in RequestResponseMap, losing the new narrowing.

Object-literal calls to client.request({ command: 'tx', ... }) are fine (TS infers the variant from the literal), but const req: TxRequest = {...}; client.request(req) regresses. Consider either:

  1. Redefining TxRequest = TxJsonRequest | TxBinaryRequest so it distributes, or
  2. Adding a TxRequest branch in RequestResponseMap that maps to TxVersionResponseMap<Version>.
#!/bin/bash
# Confirm TxRequest is still binary?: boolean and is not mapped in RequestResponseMap.
rg -nP -C3 'TxRequest\b' packages/xrpl/src/models/methods/
rg -nP -C5 'RequestResponseMap' packages/xrpl/src/models/methods/index.ts
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/xrpl/src/models/methods/tx.ts` around lines 44 - 69, TxRequest is
currently typed as binary?: boolean which prevents distributive narrowing into
TxBinaryRequest/TxJsonRequest and causes RequestResponseMap to fall back to the
generic case; fix by either making TxRequest a union alias (export type
TxRequest = TxJsonRequest | TxBinaryRequest) so the union distributes into
RequestResponseMap, or add an explicit TxRequest entry in RequestResponseMap
that maps to TxVersionResponseMap<Version> (using the same response mapping used
for the narrowed variants); update references to TxRequest, TxBinaryRequest,
TxJsonRequest, RequestResponseMap and TxVersionResponseMap accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/xrpl/src/models/methods/tx.ts`:
- Around line 1-6: Remove the unused import RIPPLED_API_V2 from the import list
at the top of the file (currently imported alongside APIVersion,
DEFAULT_API_VERSION, and RIPPLED_API_V1) so the symbol is no longer declared but
unused; ensure only APIVersion, DEFAULT_API_VERSION, and RIPPLED_API_V1 remain
imported to match the usage in TxVersionResponseMap and elsewhere in this
module.

---

Duplicate comments:
In `@packages/xrpl/src/models/methods/tx.ts`:
- Around line 44-69: TxRequest is currently typed as binary?: boolean which
prevents distributive narrowing into TxBinaryRequest/TxJsonRequest and causes
RequestResponseMap to fall back to the generic case; fix by either making
TxRequest a union alias (export type TxRequest = TxJsonRequest |
TxBinaryRequest) so the union distributes into RequestResponseMap, or add an
explicit TxRequest entry in RequestResponseMap that maps to
TxVersionResponseMap<Version> (using the same response mapping used for the
narrowed variants); update references to TxRequest, TxBinaryRequest,
TxJsonRequest, RequestResponseMap and TxVersionResponseMap accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f59c0776-9fb0-4aa8-9f96-a4e34e704cc1

📥 Commits

Reviewing files that changed from the base of the PR and between a105733 and 61d0fb9.

📒 Files selected for processing (2)
  • packages/xrpl/src/models/methods/tx.ts
  • packages/xrpl/test/integration/requests/tx.test.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/xrpl/src/models/methods/tx.ts`:
- Around line 41-57: Fix the duplicated/misleading JSDoc on the TxBinaryRequest
and TxJsonRequest interfaces: update the comment for TxBinaryRequest.binary to
remove "The default is false." (since binary is required true there) and fix the
broken sentence in both interfaces by replacing "return transaction data and
metadata as.\n   * JSON." with "return transaction data and metadata as JSON."
Ensure you edit the JSDoc above TxBinaryRequest.binary and TxJsonRequest.binary
to reflect these changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b25232f-9c24-47cf-b8c8-79c702696f16

📥 Commits

Reviewing files that changed from the base of the PR and between 61d0fb9 and d7f2f77.

📒 Files selected for processing (1)
  • packages/xrpl/src/models/methods/tx.ts

Comment thread packages/xrpl/src/models/methods/tx.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/xrpl/test/integration/requests/tx.test.ts`:
- Around line 53-59: The inline TypeScript expect-error comment is referencing
the wrong property: update the comment above the assertion for tx_blob so it
correctly says "tx_blob is only defined for binary responses" (the assertion
uses txResponse.result.tx_blob); leave the subsequent meta_blob
comment/assertion untouched and ensure both comments accurately refer to the
property being asserted (tx_blob for tx_blob assertion, meta_blob for meta_blob
assertion).
- Around line 82-93: The binary-path assertions for txBinaryResponse are flaky
because the test submits the transaction via testContext.client.submit (not
submitAndWait), so meta_blob/meta may legitimately be undefined until
validation; update the test to either (A) use submitAndWait to ensure the
transaction is validated before calling testContext.client.request('tx') so
txBinaryResponse.result.meta_blob and txBinaryResponse.result.meta can be
asserted as defined, or (B) mirror the non-binary assertions and expect
txBinaryResponse.result.meta_blob and txBinaryResponse.result.meta to be
undefined (while still asserting txBinaryResponse.result.tx_blob is defined);
locate the assertions referencing txBinaryResponse, testContext.client.request,
tx_blob, meta_blob and meta and apply one of these two changes for consistency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 55e87598-6275-4c56-9ba7-3cb6f74e46df

📥 Commits

Reviewing files that changed from the base of the PR and between d7f2f77 and ff8d622.

📒 Files selected for processing (2)
  • packages/xrpl/test/integration/requests/tx.test.ts
  • packages/xrpl/test/integration/submitAndWait.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/xrpl/test/integration/submitAndWait.test.ts

Comment thread packages/xrpl/test/integration/requests/tx.test.ts
Comment thread packages/xrpl/test/integration/requests/tx.test.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/xrpl/src/models/methods/tx.ts (1)

45-53: Public API change: TxRequest went from interface to type union.

Changing TxRequest from an exported interface to an exported type alias of a union is technically a breaking change for downstream consumers. Code like interface MyTxRequest extends TxRequest { ... } will no longer compile — consumers will need to switch to an intersection (type MyTxRequest = TxRequest & { ... }). This is expected given the PR intent, but is worth flagging in HISTORY.md / release notes since the PR description notes HISTORY wasn't updated.

Also, a very small readability nit: the TxRequest union alias on line 45 is declared before the TxBinaryRequest / TxJsonRequest interfaces it references on lines 47–53. TypeScript hoists type declarations so this works, but defining the constituent interfaces first reads more naturally.

✏️ Optional reorder
-export type TxRequest = TxJsonRequest | TxBinaryRequest
-
 export interface TxBinaryRequest extends TxRequestBase {
   binary: true
 }

 export interface TxJsonRequest extends TxRequestBase {
   binary?: false
 }
+
+export type TxRequest = TxJsonRequest | TxBinaryRequest
#!/bin/bash
# Check if TxRequest is extended as an interface anywhere in the repo
# (which would break with the interface → type change).
rg -nP --type=ts -C2 '\binterface\s+\w+\s+extends\s+TxRequest\b'

# Also check monorepo docs / history to confirm the change is documented.
fd -t f -i 'HISTORY.md' | xargs rg -n 'TxRequest' 2>/dev/null || echo "No HISTORY.md mention of TxRequest"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/xrpl/src/models/methods/tx.ts` around lines 45 - 53, TxRequest was
changed from an exported interface to a type union which is a breaking API
change for consumers who extend it; either revert TxRequest to an exported
interface or, if keeping the union-type is intended, add an explicit note to
HISTORY.md/release notes describing the breaking change and migration (e.g.,
interface MyTxRequest → type MyTxRequest = TxRequest & { ... }); additionally,
for readability reorder the declarations so TxBinaryRequest and TxJsonRequest
are declared before the TxRequest union (symbols: TxRequest, TxBinaryRequest,
TxJsonRequest, HISTORY.md).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/xrpl/src/models/methods/tx.ts`:
- Around line 45-53: TxRequest was changed from an exported interface to a type
union which is a breaking API change for consumers who extend it; either revert
TxRequest to an exported interface or, if keeping the union-type is intended,
add an explicit note to HISTORY.md/release notes describing the breaking change
and migration (e.g., interface MyTxRequest → type MyTxRequest = TxRequest & {
... }); additionally, for readability reorder the declarations so
TxBinaryRequest and TxJsonRequest are declared before the TxRequest union
(symbols: TxRequest, TxBinaryRequest, TxJsonRequest, HISTORY.md).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f06c7327-962e-4c6b-8416-e936e1e9ac22

📥 Commits

Reviewing files that changed from the base of the PR and between ff8d622 and 6b2e7da.

📒 Files selected for processing (2)
  • packages/xrpl/src/models/methods/tx.ts
  • packages/xrpl/test/integration/requests/tx.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/xrpl/test/integration/requests/tx.test.ts

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