Skip to content

Commit

Permalink
Make the simulate response more type-strict (#2878)
Browse files Browse the repository at this point in the history
  • Loading branch information
tequdev authored Jan 28, 2025
1 parent 78b1c20 commit 7ac75ff
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/xrpl/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ import type {
MarkerRequest,
MarkerResponse,
SubmitResponse,
SimulateResponse,
SimulateRequest,
} from '../models/methods'
import type { BookOffer, BookOfferCurrency } from '../models/methods/bookOffers'
import {
SimulateBinaryResponse,
SimulateJsonResponse,
} from '../models/methods/simulate'
import type {
EventTypes,
OnEventToListenerMap,
Expand Down Expand Up @@ -782,13 +785,16 @@ class Client extends EventEmitter<EventTypes> {
* @returns A promise that contains SimulateResponse.
* @throws RippledError if the simulate request fails.
*/
public async simulate(
// eslint-disable-next-line max-lines-per-function -- simulate needs a bit complex logic
public async simulate<Binary extends boolean = false>(
transaction: SubmittableTransaction | string,
opts?: {
// If true, return the binary-encoded representation of the results.
binary?: boolean
binary?: Binary
},
): Promise<SimulateResponse> {
): Promise<
Binary extends false ? SimulateJsonResponse : SimulateBinaryResponse
> {
// verify that the transaction isn't signed
const decodedTx =
typeof transaction === 'string'
Expand Down

0 comments on commit 7ac75ff

Please sign in to comment.