Remote.validateSearch
Validates an RPC request from URL search params against the wallet's Schema.Request discriminated union.
- parses
searchagainst the schema - asserts the decoded
methodmatches the expectedmethod - enforces strict parameter schemas (e.g. required
limits)
On failure it rejects all pending requests via remote.rejectAll(error) and re-throws so the router can render its error boundary.
Designed to be used from inside a TanStack Router (or similar) validateSearch callback so each per-method route gets a fully-typed, decoded request.
Usage
import { createFileRoute } from '@tanstack/react-router'
import { Remote } from 'accounts'
import { remote } from '../lib/config.js'
export const Route = createFileRoute('/rpc/personal_sign')({
validateSearch: (search) =>
Remote.validateSearch(remote, search, { method: 'personal_sign' }),
component: Component,
})Parameters
remote
- Type:
Remote.Remote - Required
The remote context returned from Remote.create. Used to call rejectAll(error) when validation fails so the host SDK is notified before the router error boundary renders.
import { Remote } from 'accounts'
import { remote } from '../lib/config.js'
Remote.validateSearch(
remote,
search,
{ method: 'personal_sign' },
)search
- Type:
Record<string, unknown> - Required
Raw URL search params (including the encoded _decoded/params/id fields written by the host SDK).
import { Remote } from 'accounts'
Remote.validateSearch(
remote,
search,
{ method: 'personal_sign' },
)parameters.method
- Type:
Schema.Request['method'] - Required
Expected RPC method name. The decoded request's method must equal this value or an InvalidParamsError is thrown.
import { Remote } from 'accounts'
Remote.validateSearch(remote, search, {
method: 'eth_sendTransaction',
})Returns
The validated, decoded request payload -- a discriminated union member matching the requested method, augmented with:
id: number-- coerced fromsearch.id.jsonrpc: '2.0'._decoded-- the parsedSchema.Requestmember._returnType-- phantom marker for the route's return type.
type ReturnType<method extends Schema.Request['method']> = Extract<
Schema.Request,
{ method: method }
> & {
id: number
jsonrpc: '2.0'
_decoded: Extract<Schema.Request, { method: method }>
_returnType: unknown
}