@elsoul/erpc-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/index.cjs +1286 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +785 -0
- package/dist/index.d.ts +785 -0
- package/dist/index.js +1257 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/transport/rest.ts","../src/account.ts","../src/config.ts","../src/price.ts","../src/rpc/client.ts","../src/rpc/ethereum.ts","../src/rpc/solana.ts","../src/transport/websocket.ts","../src/subscriptions.ts","../src/transport/http.ts","../src/client.ts"],"names":["controlledSignal","isObject"],"mappings":";AAEA,IAAM,QAAA,GAAW,YAAA;AAEjB,IAAM,kBAAA,GAAqB,CAAC,UAAA,KAA0C;AACpE,EAAA,MAAM,YAAA,GAAe,IAAI,eAAA,CAAgB,EAAE,KAAA,EAAO,UAAA,EAAY,CAAA,CAC3D,QAAA,EAAS,CACT,KAAA,CAAM,QAAA,CAAS,MAAM,CAAA;AACxB,EAAA,IAAI,gBAAA;AACJ,EAAA,IAAI;AACF,IAAA,gBAAA,GAAmB,mBAAmB,UAAU,CAAA;AAAA,EAClD,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,CAAC,mBAAG,IAAI,GAAA,CAAI,CAAC,YAAY,gBAAA,EAAkB,YAAY,CAAC,CAAC,CAAA,CAC7D,MAAA,CAAO,CAAC,KAAA,KAA2B,OAAA,CAAQ,KAAK,CAAC,CAAA,CACjD,IAAA,CAAK,CAAC,IAAA,EAAM,KAAA,KAAU,KAAA,CAAM,MAAA,GAAS,IAAA,CAAK,MAAM,CAAA;AACrD,CAAA;AAEA,IAAM,YAAA,GAAe,CAAC,KAAA,EAAe,QAAA,KAAwC;AAC3E,EAAA,IAAI,QAAA,GAAW,KAAA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,QAAA,CAAS,QAAQ,MAAM,CAAA;AAAA,IACjE,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,GAAI,SAAS,SAAA,KAAc,MAAA,GACvB,EAAC,GACD,EAAE,SAAA,EAAW,QAAA,CAAS,SAAA;AAAU,GACrC,CAAA;AAED,EAAA,MAAM,cAAA,GAAiB,IAAI,aAAA,CAAc;AAAA,IACvC,GAAG,eAAA;AAAA,IACH,UAAU,QAAA,CAAS;AAAA,GACpB,CAAA;AACD,EAAA,MAAM,gBAAA,GAAmB,IAAI,aAAA,CAAc;AAAA,IACzC,GAAG,eAAA;AAAA,IACH,UAAU,QAAA,CAAS;AAAA,GACpB,CAAA;AAED,EAAA,MAAM,MAAA,GAA2B;AAAA,IAC/B,GAAG,mBAAmB,eAAe,CAAA;AAAA,IACrC,aAAA,EAAe,IAAI,mBAAA,CAAoB,eAAe;AAAA,GACxD;AACA,EAAA,MAAM,QAAA,GAA+B;AAAA,IACnC,GAAG,qBAAqB,iBAAiB,CAAA;AAAA,IACzC,aAAA,EAAe,IAAI,qBAAA,CAAsB,iBAAiB;AAAA,GAC5D;AAEA,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA,EAAO,IAAI,WAAA,CAAY,cAAc,CAAA;AAAA,IACrC,OAAA,EAAS,IAAI,aAAA,CAAc,gBAAgB,CAAA;AAAA,IAC3C,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,cAAc,KAAA,EAAM;AAC3B,MAAA,QAAA,CAAS,cAAc,KAAA,EAAM;AAAA,IAC/B;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import type { JsonRpcErrorObject } from './rpc/types'\n\nconst REDACTED = '[REDACTED]'\n\nconst credentialVariants = (credential: string): readonly string[] => {\n const queryEncoded = new URLSearchParams({ value: credential })\n .toString()\n .slice('value='.length)\n let componentEncoded: string | undefined\n try {\n componentEncoded = encodeURIComponent(credential)\n } catch {\n // URLSearchParams still provides a safe encoded representation.\n }\n return [...new Set([credential, componentEncoded, queryEncoded])]\n .filter((value): value is string => Boolean(value))\n .sort((left, right) => right.length - left.length)\n}\n\nconst redactString = (value: string, variants: readonly string[]): string => {\n let redacted = value\n for (const variant of variants) redacted = redacted.replaceAll(variant, REDACTED)\n return redacted\n}\n\nconst redactValue = (\n value: unknown,\n variants: readonly string[],\n seen: WeakSet<object>,\n depth: number,\n): unknown => {\n if (typeof value === 'string') return redactString(value, variants)\n if (typeof value !== 'object' || value === null) return value\n if (depth >= 32 || seen.has(value)) return REDACTED\n\n seen.add(value)\n if (Array.isArray(value)) {\n return value.map((item) => redactValue(item, variants, seen, depth + 1))\n }\n\n const result: Record<string, unknown> = {}\n for (const [key, item] of Object.entries(value)) {\n Object.defineProperty(result, key, {\n configurable: true,\n enumerable: true,\n value: redactValue(item, variants, seen, depth + 1),\n writable: true,\n })\n }\n return result\n}\n\nexport const redactJsonRpcError = (\n error: JsonRpcErrorObject,\n credential: string | undefined,\n): JsonRpcErrorObject => {\n if (!credential) return error\n const variants = credentialVariants(credential)\n const result: {\n code: number\n data?: unknown\n message: string\n } = {\n code: error.code,\n message: redactString(error.message, variants),\n }\n if (error.data !== undefined) {\n result.data = redactValue(error.data, variants, new WeakSet(), 0)\n }\n return result\n}\n\nexport type ErpcErrorCode =\n | 'ERPC_ABORTED'\n | 'ERPC_BATCH_POLICY'\n | 'ERPC_CONFIG'\n | 'ERPC_HTTP'\n | 'ERPC_INVALID_RESPONSE'\n | 'ERPC_RPC'\n | 'ERPC_TIMEOUT'\n | 'ERPC_TRANSPORT'\n\nexport class ErpcError extends Error {\n readonly code: ErpcErrorCode\n\n constructor(code: ErpcErrorCode, message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = 'ErpcError'\n this.code = code\n }\n}\n\nexport class ErpcConfigError extends ErpcError {\n constructor(message: string) {\n super('ERPC_CONFIG', message)\n this.name = 'ErpcConfigError'\n }\n}\n\nexport class ErpcTransportError extends ErpcError {\n constructor(message: string, options?: ErrorOptions) {\n super('ERPC_TRANSPORT', message, options)\n this.name = 'ErpcTransportError'\n }\n}\n\nexport class ErpcHttpError extends ErpcError {\n readonly status: number\n\n constructor(status: number, message = `ERPC request failed with HTTP ${status}`) {\n super('ERPC_HTTP', message)\n this.name = 'ErpcHttpError'\n this.status = status\n }\n}\n\nexport class ErpcTimeoutError extends ErpcError {\n readonly timeoutMs: number\n\n constructor(timeoutMs: number) {\n super('ERPC_TIMEOUT', `ERPC request timed out after ${timeoutMs}ms`)\n this.name = 'ErpcTimeoutError'\n this.timeoutMs = timeoutMs\n }\n}\n\nexport class ErpcAbortedError extends ErpcError {\n constructor() {\n super('ERPC_ABORTED', 'ERPC request was aborted')\n this.name = 'ErpcAbortedError'\n }\n}\n\nexport class ErpcInvalidResponseError extends ErpcError {\n constructor(message = 'ERPC returned an invalid response') {\n super('ERPC_INVALID_RESPONSE', message)\n this.name = 'ErpcInvalidResponseError'\n }\n}\n\nexport class ErpcJsonRpcError extends ErpcError {\n readonly rpcCode: number\n readonly data?: unknown\n\n constructor(error: JsonRpcErrorObject) {\n super('ERPC_RPC', error.message)\n this.name = 'ErpcJsonRpcError'\n this.rpcCode = error.code\n if (error.data !== undefined) this.data = error.data\n }\n}\n\nexport class ErpcBatchPolicyError extends ErpcError {\n constructor(message: string) {\n super('ERPC_BATCH_POLICY', message)\n this.name = 'ErpcBatchPolicyError'\n }\n}\n","import {\n ErpcAbortedError,\n ErpcHttpError,\n ErpcInvalidResponseError,\n ErpcTimeoutError,\n ErpcTransportError,\n} from '../errors'\nimport type { RpcSendOptions } from '../rpc/types'\n\nexport type QueryValue =\n | boolean\n | number\n | readonly string[]\n | string\n | undefined\n\nexport type Query = Readonly<Record<string, QueryValue>>\n\nexport interface RestTransportConfig {\n readonly apiKey: string\n readonly endpoint: URL\n readonly fetch: typeof globalThis.fetch\n readonly headers: Readonly<Record<string, string>>\n readonly timeoutMs: number\n}\n\nexport interface RestStreamResponse {\n readonly response: Response\n close(): void\n normalizeError(error: unknown): Error\n}\n\ninterface ControlledSignal {\n readonly cleanup: () => void\n readonly signal: AbortSignal\n readonly stopTimeout: () => void\n readonly timeoutMs: number\n readonly timedOut: () => boolean\n}\n\nconst controlledSignal = (\n timeoutMs: number,\n external?: AbortSignal,\n): ControlledSignal => {\n const controller = new AbortController()\n let didTimeOut = false\n let timeout: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {\n didTimeOut = true\n controller.abort()\n }, timeoutMs)\n\n const abort = () => controller.abort()\n if (external?.aborted) controller.abort()\n else external?.addEventListener('abort', abort, { once: true })\n\n const stopTimeout = () => {\n if (timeout === undefined) return\n clearTimeout(timeout)\n timeout = undefined\n }\n\n return {\n signal: controller.signal,\n stopTimeout,\n timeoutMs,\n timedOut: () => didTimeOut,\n cleanup: () => {\n stopTimeout()\n external?.removeEventListener('abort', abort)\n },\n }\n}\n\nconst normalizeError = (\n error: unknown,\n controlled: ControlledSignal,\n external?: AbortSignal,\n): Error => {\n if (\n error instanceof ErpcAbortedError ||\n error instanceof ErpcHttpError ||\n error instanceof ErpcInvalidResponseError ||\n error instanceof ErpcTimeoutError ||\n error instanceof ErpcTransportError\n ) {\n return error\n }\n if (controlled.timedOut()) {\n return new ErpcTimeoutError(controlled.timeoutMs)\n }\n if (external?.aborted) return new ErpcAbortedError()\n return new ErpcTransportError('Unable to reach ERPC')\n}\n\nconst applyQuery = (url: URL, query?: Query): void => {\n if (!query) return\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue\n if (Array.isArray(value)) {\n for (const item of value) url.searchParams.append(key, item)\n } else {\n url.searchParams.set(key, String(value))\n }\n }\n}\n\nexport class RestTransport {\n readonly endpoint: string\n\n readonly #apiKey: string\n readonly #endpoint: URL\n readonly #fetch: typeof globalThis.fetch\n readonly #headers: Readonly<Record<string, string>>\n readonly #timeoutMs: number\n\n constructor(config: RestTransportConfig) {\n this.#apiKey = config.apiKey\n this.#endpoint = new URL(config.endpoint)\n this.#fetch = config.fetch\n this.#headers = config.headers\n this.#timeoutMs = config.timeoutMs\n const endpoint = new URL(config.endpoint)\n endpoint.search = ''\n endpoint.hash = ''\n this.endpoint = endpoint.toString()\n }\n\n url(path: string, query?: Query): URL {\n const url = new URL(this.#endpoint)\n const base = url.pathname === '/' ? '' : url.pathname.replace(/\\/+$/, '')\n url.pathname = `${base}/${path.replace(/^\\/+/, '')}`.replace(/\\/{2,}/g, '/')\n applyQuery(url, query)\n return url\n }\n\n async get<TResult>(\n path: string,\n query?: Query,\n options: RpcSendOptions = {},\n ): Promise<TResult> {\n const controlled = controlledSignal(this.#timeoutMs, options.signal)\n try {\n const response = await this.#get(path, query, controlled.signal)\n if (!response.ok) throw new ErpcHttpError(response.status)\n const text = await response.text()\n try {\n return JSON.parse(text) as TResult\n } catch {\n throw new ErpcInvalidResponseError('ERPC returned malformed JSON')\n }\n } catch (error) {\n throw normalizeError(error, controlled, options.signal)\n } finally {\n controlled.cleanup()\n }\n }\n\n async stream(\n path: string,\n query?: Query,\n options: RpcSendOptions = {},\n ): Promise<RestStreamResponse> {\n const controlled = controlledSignal(this.#timeoutMs, options.signal)\n try {\n const response = await this.#get(path, query, controlled.signal)\n if (!response.ok) throw new ErpcHttpError(response.status)\n\n // Long-lived streams use the timeout for connection establishment only.\n // The caller's AbortSignal remains attached until close() is called.\n controlled.stopTimeout()\n return {\n response,\n close: controlled.cleanup,\n normalizeError: (error) =>\n normalizeError(error, controlled, options.signal),\n }\n } catch (error) {\n controlled.cleanup()\n throw normalizeError(error, controlled, options.signal)\n }\n }\n\n #get(path: string, query: Query | undefined, signal: AbortSignal) {\n return this.#fetch(this.url(path, query), {\n method: 'GET',\n headers: {\n ...this.#headers,\n authorization: `Bearer ${this.#apiKey}`,\n accept: 'application/json',\n },\n signal,\n })\n }\n}\n","import type { RpcSendOptions } from './rpc/types'\nimport { RestTransport } from './transport/rest'\n\nexport type ErpcPlan = 'business' | 'developer' | 'free' | 'pro'\n\nexport interface TokenBalance {\n readonly max_tokens: number\n readonly next_refill_at: string | null\n readonly plan: ErpcPlan\n readonly remaining_tokens: number\n}\n\nexport class AccountClient {\n readonly #transport: RestTransport\n\n constructor(transport: RestTransport) {\n this.#transport = transport\n }\n\n getTokenBalance(options?: RpcSendOptions): Promise<TokenBalance> {\n return this.#transport.get('/v3/erpc/token-balance', undefined, options)\n }\n}\n","import { ErpcConfigError } from './errors'\n\nexport const DEFAULT_ENDPOINT = 'https://edge.erpc.global'\nexport const DEFAULT_ACCOUNT_ENDPOINT = 'https://solana-rpc.erpc.global'\nexport const DEFAULT_TIMEOUT_MS = 30_000\n\nexport interface ErpcClientConfig {\n readonly accountEndpoint?: string\n readonly apiKey: string\n readonly endpoint?: string\n readonly fetch?: typeof globalThis.fetch\n readonly headers?: Readonly<Record<string, string>>\n readonly timeoutMs?: number\n readonly webSocket?: typeof globalThis.WebSocket\n}\n\nexport interface ResolvedErpcClientConfig {\n readonly accountEndpoint: URL\n readonly apiKey: string\n readonly endpoint: URL\n readonly fetch: typeof globalThis.fetch\n readonly headers: Readonly<Record<string, string>>\n readonly timeoutMs: number\n readonly webSocket?: typeof globalThis.WebSocket\n}\n\nconst requireFetch = (provided?: typeof globalThis.fetch) => {\n const implementation = provided ?? globalThis.fetch\n if (typeof implementation !== 'function') {\n throw new ErpcConfigError(\n 'A Fetch API implementation is required in this runtime',\n )\n }\n return implementation\n}\n\nexport const resolveConfig = (\n config: ErpcClientConfig,\n): ResolvedErpcClientConfig => {\n const apiKey = config.apiKey.trim()\n if (!apiKey) throw new ErpcConfigError('apiKey must not be empty')\n\n let endpoint: URL\n let accountEndpoint: URL\n try {\n endpoint = new URL(config.endpoint ?? DEFAULT_ENDPOINT)\n accountEndpoint = new URL(\n config.accountEndpoint ?? DEFAULT_ACCOUNT_ENDPOINT,\n )\n } catch {\n throw new ErpcConfigError('endpoint must be an absolute HTTP(S) URL')\n }\n\n if (endpoint.protocol !== 'https:' && endpoint.protocol !== 'http:') {\n throw new ErpcConfigError('endpoint must use HTTP or HTTPS')\n }\n if (\n accountEndpoint.protocol !== 'https:' &&\n accountEndpoint.protocol !== 'http:'\n ) {\n throw new ErpcConfigError('accountEndpoint must use HTTP or HTTPS')\n }\n\n endpoint.search = ''\n endpoint.hash = ''\n endpoint.pathname = endpoint.pathname.replace(/\\/+$/, '') || '/'\n accountEndpoint.search = ''\n accountEndpoint.hash = ''\n accountEndpoint.pathname =\n accountEndpoint.pathname.replace(/\\/+$/, '') || '/'\n\n const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw new ErpcConfigError('timeoutMs must be a positive finite number')\n }\n\n return {\n accountEndpoint,\n apiKey,\n endpoint,\n fetch: requireFetch(config.fetch),\n headers: config.headers ?? {},\n timeoutMs,\n ...(config.webSocket === undefined\n ? {}\n : { webSocket: config.webSocket }),\n }\n}\n\nexport const endpointWithPath = (endpoint: URL, path: string): URL => {\n const url = new URL(endpoint)\n const base = endpoint.pathname === '/' ? '' : endpoint.pathname\n url.pathname = `${base}/${path.replace(/^\\/+/, '')}`.replace(/\\/{2,}/g, '/')\n return url\n}\n\nexport const websocketUrl = (\n endpoint: URL,\n apiKey: string,\n path = '',\n): URL => {\n const url = endpointWithPath(endpoint, path)\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:'\n url.searchParams.set('api-key', apiKey)\n return url\n}\n","import { ErpcInvalidResponseError } from './errors'\nimport type { RpcSendOptions } from './rpc/types'\nimport type { Query } from './transport/rest'\nimport { RestTransport } from './transport/rest'\n\nexport type PriceEncoding = 'base64' | 'hex'\nexport type PriceAssetType = 'crypto' | 'equity' | 'fx' | 'metal' | 'rates'\n\nexport interface PriceFeedMetadata {\n readonly attributes?: Readonly<Record<string, string>>\n readonly id: string\n}\n\nexport interface PricePoint {\n readonly conf: string\n readonly expo: number\n readonly price: string\n readonly publish_time: number\n}\n\nexport interface ParsedPriceUpdate {\n readonly ema_price: PricePoint\n readonly id: string\n readonly metadata?: {\n readonly prev_publish_time?: number\n readonly proof_available_time?: number\n readonly slot?: number\n }\n readonly price: PricePoint\n}\n\nexport interface BinaryUpdate {\n readonly data: readonly string[]\n readonly encoding: string\n}\n\nexport interface PriceUpdateResponse {\n readonly binary: BinaryUpdate\n readonly parsed?: readonly ParsedPriceUpdate[]\n}\n\nexport interface PriceUpdateOptions {\n readonly encoding?: PriceEncoding\n readonly ids: readonly string[]\n readonly ignoreInvalidPriceIds?: boolean\n readonly parsed?: boolean\n}\n\nexport interface PriceStreamOptions extends PriceUpdateOptions {\n readonly allowUnordered?: boolean\n readonly benchmarksOnly?: boolean\n}\n\nexport interface PublisherStakeCap {\n readonly cap: number\n readonly publisher: string\n}\n\nexport interface PublisherStakeCapsResponse {\n readonly binary: BinaryUpdate\n readonly parsed?: readonly {\n readonly publisher_stake_caps: readonly PublisherStakeCap[]\n }[]\n}\n\nexport interface PriceStreamEvent {\n readonly data: PriceUpdateResponse\n readonly event?: string\n readonly id?: string\n}\n\nconst updateQuery = (options: PriceUpdateOptions): Query => ({\n 'ids[]': options.ids,\n encoding: options.encoding,\n parsed: options.parsed,\n ignore_invalid_price_ids: options.ignoreInvalidPriceIds,\n})\n\nconst parseSseBlock = (block: string): PriceStreamEvent | null => {\n const data: string[] = []\n let event: string | undefined\n let id: string | undefined\n\n for (const line of block.split(/\\r?\\n/)) {\n if (!line || line.startsWith(':')) continue\n const separator = line.indexOf(':')\n const field = separator === -1 ? line : line.slice(0, separator)\n const raw = separator === -1 ? '' : line.slice(separator + 1)\n const value = raw.startsWith(' ') ? raw.slice(1) : raw\n if (field === 'data') data.push(value)\n else if (field === 'event') event = value\n else if (field === 'id') id = value\n }\n\n if (data.length === 0) return null\n let parsed: PriceUpdateResponse\n try {\n parsed = JSON.parse(data.join('\\n')) as PriceUpdateResponse\n } catch {\n throw new ErpcInvalidResponseError('ERPC returned malformed stream data')\n }\n const result: {\n data: PriceUpdateResponse\n event?: string\n id?: string\n } = { data: parsed }\n if (event !== undefined) result.event = event\n if (id !== undefined) result.id = id\n return result\n}\n\nexport class PriceClient {\n readonly #transport: RestTransport\n\n constructor(transport: RestTransport) {\n this.#transport = transport\n }\n\n getPriceFeeds(\n options: {\n readonly assetType?: PriceAssetType\n readonly query?: string\n } = {},\n sendOptions?: RpcSendOptions,\n ): Promise<readonly PriceFeedMetadata[]> {\n return this.#transport.get(\n '/v2/price_feeds',\n { query: options.query, asset_type: options.assetType },\n sendOptions,\n )\n }\n\n getLatestPriceUpdates(\n options: PriceUpdateOptions,\n sendOptions?: RpcSendOptions,\n ): Promise<PriceUpdateResponse> {\n return this.#transport.get(\n '/v2/updates/price/latest',\n updateQuery(options),\n sendOptions,\n )\n }\n\n getPriceUpdatesAtTimestamp(\n publishTime: number | string,\n options: PriceUpdateOptions,\n sendOptions?: RpcSendOptions,\n ): Promise<PriceUpdateResponse> {\n return this.#transport.get(\n `/v2/updates/price/${encodeURIComponent(String(publishTime))}`,\n updateQuery(options),\n sendOptions,\n )\n }\n\n getLatestPublisherStakeCaps(\n options: { readonly encoding?: PriceEncoding; readonly parsed?: boolean } = {},\n sendOptions?: RpcSendOptions,\n ): Promise<PublisherStakeCapsResponse> {\n return this.#transport.get(\n '/v2/updates/publisher_stake_caps/latest',\n options,\n sendOptions,\n )\n }\n\n async *streamPriceUpdates(\n options: PriceStreamOptions,\n sendOptions?: RpcSendOptions,\n ): AsyncGenerator<PriceStreamEvent, void, undefined> {\n const stream = await this.#transport.stream(\n '/v2/updates/price/stream',\n {\n ...updateQuery(options),\n allow_unordered: options.allowUnordered,\n benchmarks_only: options.benchmarksOnly,\n },\n sendOptions,\n )\n const response = stream.response\n if (!response.body) {\n stream.close()\n throw new ErpcInvalidResponseError('ERPC returned an empty stream')\n }\n\n const reader = response.body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n try {\n while (true) {\n const { done, value } = await reader.read()\n buffer += decoder.decode(value, { stream: !done })\n let boundary = buffer.search(/\\r?\\n\\r?\\n/)\n while (boundary !== -1) {\n const separatorLength = buffer.slice(boundary).startsWith('\\r\\n')\n ? 4\n : 2\n const block = buffer.slice(0, boundary)\n buffer = buffer.slice(boundary + separatorLength)\n const event = parseSseBlock(block)\n if (event) yield event\n boundary = buffer.search(/\\r?\\n\\r?\\n/)\n }\n if (done) break\n }\n const finalEvent = parseSseBlock(buffer)\n if (finalEvent) yield finalEvent\n } catch (error) {\n throw stream.normalizeError(error)\n } finally {\n try {\n await reader.cancel()\n } catch {\n // Preserve the original stream result or error.\n } finally {\n reader.releaseLock()\n stream.close()\n }\n }\n }\n}\n","import type {\n JsonRpcParams,\n RpcBatchCall,\n RpcMethodSpec,\n RpcParams,\n RpcResult,\n RpcSendOptions,\n} from './types'\n\nexport interface JsonRpcTransport {\n readonly endpoint: string\n readonly maxBatchSize: number\n\n batch<TResult extends readonly unknown[]>(\n calls: readonly RpcBatchCall[],\n options?: RpcSendOptions,\n ): Promise<TResult>\n\n request<TResult>(\n method: string,\n params?: JsonRpcParams,\n options?: RpcSendOptions,\n ): Promise<TResult>\n}\n\nexport class PendingRpcRequest<TResult> {\n readonly #send: (options?: RpcSendOptions) => Promise<TResult>\n\n constructor(send: (options?: RpcSendOptions) => Promise<TResult>) {\n this.#send = send\n }\n\n send(options?: RpcSendOptions): Promise<TResult> {\n return this.#send(options)\n }\n}\n\nexport class PendingRpcBatchRequest<TResult extends readonly unknown[]> {\n readonly #send: (options?: RpcSendOptions) => Promise<TResult>\n\n constructor(send: (options?: RpcSendOptions) => Promise<TResult>) {\n this.#send = send\n }\n\n send(options?: RpcSendOptions): Promise<TResult> {\n return this.#send(options)\n }\n}\n\ntype SchemaConstraint<TSchema> = {\n readonly [TMethod in keyof TSchema]: RpcMethodSpec<\n JsonRpcParams | undefined,\n unknown\n >\n}\n\ntype MethodName<TSchema> = Extract<keyof TSchema, string>\n\ntype MethodFunction<TSpec> = TSpec extends RpcMethodSpec<\n infer TParams,\n infer TResult\n>\n ? TParams extends readonly unknown[]\n ? (...params: TParams) => PendingRpcRequest<TResult>\n : TParams extends object\n ? (params: TParams) => PendingRpcRequest<TResult>\n : () => PendingRpcRequest<TResult>\n : never\n\ntype BatchCall<TSchema> = {\n readonly [TMethod in MethodName<TSchema>]: RpcParams<\n TSchema[TMethod]\n > extends undefined\n ? { readonly method: TMethod; readonly params?: undefined }\n : {\n readonly method: TMethod\n readonly params: RpcParams<TSchema[TMethod]>\n }\n}[MethodName<TSchema>]\n\ntype BatchResults<\n TSchema,\n TCalls extends readonly BatchCall<TSchema>[],\n> = {\n readonly [TIndex in keyof TCalls]: TCalls[TIndex] extends {\n readonly method: infer TMethod\n }\n ? TMethod extends MethodName<TSchema>\n ? RpcResult<TSchema[TMethod]>\n : never\n : never\n}\n\nexport interface RpcNamespaceBase<TSchema> {\n readonly endpoint: string\n\n batch<const TCalls extends readonly BatchCall<TSchema>[]>(\n calls: TCalls,\n ): PendingRpcBatchRequest<BatchResults<TSchema, TCalls>>\n\n raw<TResult = unknown>(\n method: string,\n params?: JsonRpcParams,\n ): PendingRpcRequest<TResult>\n\n request<TMethod extends MethodName<TSchema>>(\n method: TMethod,\n ...params: RpcParams<TSchema[TMethod]> extends undefined\n ? []\n : [params: RpcParams<TSchema[TMethod]>]\n ): PendingRpcRequest<RpcResult<TSchema[TMethod]>>\n}\n\nexport type RpcNamespace<TSchema extends SchemaConstraint<TSchema>> =\n RpcNamespaceBase<TSchema> & {\n readonly [TMethod in MethodName<TSchema>]: MethodFunction<TSchema[TMethod]>\n }\n\nexport interface CreateRpcNamespaceConfig {\n readonly parameterMode: 'named' | 'positional'\n readonly transport: JsonRpcTransport\n readonly validateBatch?: (calls: readonly RpcBatchCall[]) => void\n}\n\nconst methodParams = (\n mode: CreateRpcNamespaceConfig['parameterMode'],\n args: readonly unknown[],\n): JsonRpcParams | undefined => {\n if (mode === 'positional') return args\n if (args.length === 0) return undefined\n return args[0] as object\n}\n\nexport const createRpcNamespace = <\n TSchema extends SchemaConstraint<TSchema>,\n>(config: CreateRpcNamespaceConfig): RpcNamespace<TSchema> => {\n const base: RpcNamespaceBase<TSchema> = {\n endpoint: config.transport.endpoint,\n batch: <const TCalls extends readonly BatchCall<TSchema>[]>(calls: TCalls) => {\n const wireCalls = calls as readonly RpcBatchCall[]\n config.validateBatch?.(wireCalls)\n return new PendingRpcBatchRequest((options) =>\n config.transport.batch<BatchResults<TSchema, TCalls>>(\n wireCalls,\n options,\n ),\n )\n },\n raw: <TResult>(method: string, params?: JsonRpcParams) =>\n new PendingRpcRequest<TResult>((options) =>\n config.transport.request<TResult>(method, params, options),\n ),\n request: <TMethod extends MethodName<TSchema>>(\n method: TMethod,\n ...params: RpcParams<TSchema[TMethod]> extends undefined\n ? []\n : [params: RpcParams<TSchema[TMethod]>]\n ) =>\n new PendingRpcRequest<RpcResult<TSchema[TMethod]>>((options) =>\n config.transport.request<RpcResult<TSchema[TMethod]>>(\n method,\n params[0] as JsonRpcParams | undefined,\n options,\n ),\n ),\n }\n\n return new Proxy(base as RpcNamespace<TSchema>, {\n get(target, property, receiver) {\n if (typeof property !== 'string' || property in target) {\n return Reflect.get(target, property, receiver) as unknown\n }\n if (property === 'then') return undefined\n return (...args: readonly unknown[]) =>\n new PendingRpcRequest((options) =>\n config.transport.request(\n property,\n methodParams(config.parameterMode, args),\n options,\n ),\n )\n },\n })\n}\n","import type { HttpJsonRpcTransport } from '../transport/http'\nimport { createRpcNamespace, type RpcNamespace } from './client'\nimport type { JsonValue, RpcMethodSpec } from './types'\n\nexport type Hex = `0x${string}`\nexport type EthereumAddress = Hex\nexport type EthereumBlockTag =\n | 'earliest'\n | 'finalized'\n | 'latest'\n | 'pending'\n | 'safe'\n | Hex\n\nexport type EthereumObject = Readonly<Record<string, unknown>>\nexport type EthereumTransactionRequest = EthereumObject\nexport type EthereumFilter = EthereumObject\n\nexport interface EthereumRpcSchema {\n readonly eth_accounts: RpcMethodSpec<readonly [], readonly EthereumAddress[]>\n readonly eth_baseFee: RpcMethodSpec<readonly [], Hex>\n readonly eth_blobBaseFee: RpcMethodSpec<readonly [], Hex>\n readonly eth_blockNumber: RpcMethodSpec<readonly [], Hex>\n readonly eth_call: RpcMethodSpec<\n readonly [\n transaction: EthereumTransactionRequest,\n block?: EthereumBlockTag,\n stateOverride?: EthereumObject,\n ],\n Hex\n >\n readonly eth_callMany: RpcMethodSpec<\n readonly [\n calls: readonly EthereumObject[],\n simulationContext?: EthereumObject,\n stateOverride?: EthereumObject,\n timeout?: number,\n ],\n JsonValue\n >\n readonly eth_capabilities: RpcMethodSpec<readonly [], JsonValue>\n readonly eth_chainId: RpcMethodSpec<readonly [], Hex>\n readonly eth_createAccessList: RpcMethodSpec<\n readonly [\n transaction: EthereumTransactionRequest,\n block?: EthereumBlockTag,\n ],\n JsonValue\n >\n readonly eth_estimateGas: RpcMethodSpec<\n readonly [\n transaction: EthereumTransactionRequest,\n block?: EthereumBlockTag,\n stateOverride?: EthereumObject,\n ],\n Hex\n >\n readonly eth_feeHistory: RpcMethodSpec<\n readonly [\n blockCount: Hex,\n newestBlock: EthereumBlockTag,\n rewardPercentiles: readonly number[],\n ],\n JsonValue\n >\n readonly eth_gasPrice: RpcMethodSpec<readonly [], Hex>\n readonly eth_getAccount: RpcMethodSpec<\n readonly [address: EthereumAddress, block: EthereumBlockTag],\n JsonValue\n >\n readonly eth_getBalance: RpcMethodSpec<\n readonly [address: EthereumAddress, block?: EthereumBlockTag],\n Hex\n >\n readonly eth_getBlockByHash: RpcMethodSpec<\n readonly [hash: Hex, includeTransactions: boolean],\n JsonValue | null\n >\n readonly eth_getBlockByNumber: RpcMethodSpec<\n readonly [block: EthereumBlockTag, includeTransactions: boolean],\n JsonValue | null\n >\n readonly eth_getBlockReceipts: RpcMethodSpec<\n readonly [block: EthereumBlockTag],\n JsonValue | null\n >\n readonly eth_getBlockTransactionCountByHash: RpcMethodSpec<\n readonly [hash: Hex],\n Hex | null\n >\n readonly eth_getBlockTransactionCountByNumber: RpcMethodSpec<\n readonly [block: EthereumBlockTag],\n Hex | null\n >\n readonly eth_getCode: RpcMethodSpec<\n readonly [address: EthereumAddress, block?: EthereumBlockTag],\n Hex\n >\n readonly eth_getFilterChanges: RpcMethodSpec<readonly [filterId: Hex], JsonValue>\n readonly eth_getFilterLogs: RpcMethodSpec<readonly [filterId: Hex], JsonValue>\n readonly eth_getLogs: RpcMethodSpec<\n readonly [filter?: EthereumFilter],\n JsonValue\n >\n readonly eth_getProof: RpcMethodSpec<\n readonly [\n address: EthereumAddress,\n storageKeys: readonly Hex[],\n block: EthereumBlockTag,\n ],\n JsonValue\n >\n readonly eth_getRawTransactionByHash: RpcMethodSpec<\n readonly [hash: Hex],\n Hex | null\n >\n readonly eth_getStorageAt: RpcMethodSpec<\n readonly [\n address: EthereumAddress,\n position: Hex,\n block?: EthereumBlockTag,\n ],\n Hex\n >\n readonly eth_getTransactionByBlockHashAndIndex: RpcMethodSpec<\n readonly [blockHash: Hex, index: Hex],\n JsonValue | null\n >\n readonly eth_getTransactionByBlockNumberAndIndex: RpcMethodSpec<\n readonly [block: EthereumBlockTag, index: Hex],\n JsonValue | null\n >\n readonly eth_getTransactionByHash: RpcMethodSpec<\n readonly [hash: Hex],\n JsonValue | null\n >\n readonly eth_getTransactionBySenderAndNonce: RpcMethodSpec<\n readonly [sender: EthereumAddress, nonce: Hex],\n JsonValue | null\n >\n readonly eth_getTransactionCount: RpcMethodSpec<\n readonly [address: EthereumAddress, block?: EthereumBlockTag],\n Hex\n >\n readonly eth_getTransactionReceipt: RpcMethodSpec<\n readonly [hash: Hex],\n JsonValue | null\n >\n readonly eth_getUncleCountByBlockHash: RpcMethodSpec<\n readonly [hash: Hex],\n Hex\n >\n readonly eth_getUncleCountByBlockNumber: RpcMethodSpec<\n readonly [block: EthereumBlockTag],\n Hex\n >\n readonly eth_maxPriorityFeePerGas: RpcMethodSpec<readonly [], Hex>\n readonly eth_newBlockFilter: RpcMethodSpec<readonly [], Hex>\n readonly eth_newFilter: RpcMethodSpec<\n readonly [filter?: EthereumFilter],\n Hex\n >\n readonly eth_newPendingTransactionFilter: RpcMethodSpec<readonly [], Hex>\n readonly eth_sendRawTransaction: RpcMethodSpec<\n readonly [transaction: Hex],\n Hex\n >\n readonly eth_signTransaction: RpcMethodSpec<\n readonly [transaction: EthereumTransactionRequest],\n Hex\n >\n readonly eth_simulateV1: RpcMethodSpec<\n readonly [simulation: EthereumObject, block?: EthereumBlockTag],\n JsonValue\n >\n readonly eth_submitWork: RpcMethodSpec<\n readonly [nonce: Hex, proofOfWorkHash: Hex, digest: Hex],\n boolean\n >\n readonly eth_syncing: RpcMethodSpec<readonly [], boolean | JsonValue>\n readonly eth_uninstallFilter: RpcMethodSpec<readonly [filterId: Hex], boolean>\n readonly net_listening: RpcMethodSpec<readonly [], boolean>\n readonly net_peerCount: RpcMethodSpec<readonly [], Hex>\n readonly net_version: RpcMethodSpec<readonly [], string>\n readonly txpool_content: RpcMethodSpec<readonly [], JsonValue>\n readonly txpool_contentFrom: RpcMethodSpec<\n readonly [address: EthereumAddress],\n JsonValue\n >\n readonly txpool_inspect: RpcMethodSpec<readonly [], JsonValue>\n readonly txpool_status: RpcMethodSpec<readonly [], JsonValue>\n readonly web3_clientVersion: RpcMethodSpec<readonly [], string>\n readonly web3_sha3: RpcMethodSpec<readonly [data: Hex], Hex>\n}\n\nexport interface EthereumSubscriptionSchema {\n readonly eth_subscribe: RpcMethodSpec<\n readonly [subscription: string, ...options: readonly unknown[]],\n string\n >\n readonly eth_unsubscribe: RpcMethodSpec<\n readonly [subscriptionId: string],\n boolean\n >\n}\n\nexport const ETHEREUM_RPC_METHODS = [\n 'eth_accounts',\n 'eth_baseFee',\n 'eth_blobBaseFee',\n 'eth_blockNumber',\n 'eth_call',\n 'eth_callMany',\n 'eth_capabilities',\n 'eth_chainId',\n 'eth_createAccessList',\n 'eth_estimateGas',\n 'eth_feeHistory',\n 'eth_gasPrice',\n 'eth_getAccount',\n 'eth_getBalance',\n 'eth_getBlockByHash',\n 'eth_getBlockByNumber',\n 'eth_getBlockReceipts',\n 'eth_getBlockTransactionCountByHash',\n 'eth_getBlockTransactionCountByNumber',\n 'eth_getCode',\n 'eth_getFilterChanges',\n 'eth_getFilterLogs',\n 'eth_getLogs',\n 'eth_getProof',\n 'eth_getRawTransactionByHash',\n 'eth_getStorageAt',\n 'eth_getTransactionByBlockHashAndIndex',\n 'eth_getTransactionByBlockNumberAndIndex',\n 'eth_getTransactionByHash',\n 'eth_getTransactionBySenderAndNonce',\n 'eth_getTransactionCount',\n 'eth_getTransactionReceipt',\n 'eth_getUncleCountByBlockHash',\n 'eth_getUncleCountByBlockNumber',\n 'eth_maxPriorityFeePerGas',\n 'eth_newBlockFilter',\n 'eth_newFilter',\n 'eth_newPendingTransactionFilter',\n 'eth_sendRawTransaction',\n 'eth_signTransaction',\n 'eth_simulateV1',\n 'eth_submitWork',\n 'eth_syncing',\n 'eth_uninstallFilter',\n 'net_listening',\n 'net_peerCount',\n 'net_version',\n 'txpool_content',\n 'txpool_contentFrom',\n 'txpool_inspect',\n 'txpool_status',\n 'web3_clientVersion',\n 'web3_sha3',\n] as const satisfies readonly (keyof EthereumRpcSchema)[]\n\nexport const ETHEREUM_SUBSCRIPTION_METHODS = [\n 'eth_subscribe',\n 'eth_unsubscribe',\n] as const satisfies readonly (keyof EthereumSubscriptionSchema)[]\n\nexport interface EthereumClient {\n readonly rpc: RpcNamespace<EthereumRpcSchema>\n}\n\nexport const createEthereumClient = (\n transport: HttpJsonRpcTransport,\n): EthereumClient => ({\n rpc: createRpcNamespace<EthereumRpcSchema>({\n transport,\n parameterMode: 'positional',\n }),\n})\n","import { ErpcBatchPolicyError } from '../errors'\nimport type { HttpJsonRpcTransport } from '../transport/http'\nimport { createRpcNamespace, type RpcNamespace } from './client'\nimport type {\n JsonObject,\n JsonValue,\n RpcBatchCall,\n RpcMethodSpec,\n} from './types'\n\nexport type SolanaCommitment = 'confirmed' | 'finalized' | 'processed'\nexport type SolanaEncoding = 'base58' | 'base64' | 'base64+zstd' | 'jsonParsed'\nexport type SolanaConfig = Readonly<Record<string, unknown>>\n\nexport interface SolanaContext {\n readonly apiVersion?: string\n readonly slot: number\n}\n\nexport interface SolanaContextResult<TValue> {\n readonly context: SolanaContext\n readonly value: TValue\n}\n\nexport interface PriorityFeeEstimate {\n readonly priorityFeeEstimate: number\n readonly [key: string]: unknown\n}\n\nexport interface SolanaRpcSchema {\n readonly getAccountInfo: RpcMethodSpec<\n readonly [address: string, config?: SolanaConfig],\n SolanaContextResult<JsonValue | null>\n >\n readonly getBalance: RpcMethodSpec<\n readonly [address: string, config?: SolanaConfig],\n SolanaContextResult<number>\n >\n readonly getBlock: RpcMethodSpec<\n readonly [slot: number, config?: SolanaConfig],\n JsonValue | null\n >\n readonly getBlockCommitment: RpcMethodSpec<\n readonly [slot: number],\n JsonValue\n >\n readonly getBlockHeight: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n number\n >\n readonly getBlockProduction: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n JsonValue\n >\n readonly getBlockTime: RpcMethodSpec<\n readonly [slot: number],\n number | null\n >\n readonly getBlocks: RpcMethodSpec<\n readonly [startSlot: number, endSlot?: number, commitment?: SolanaCommitment],\n readonly number[]\n >\n readonly getBlocksWithLimit: RpcMethodSpec<\n readonly [startSlot: number, limit: number, commitment?: SolanaCommitment],\n readonly number[]\n >\n readonly getClusterNodes: RpcMethodSpec<readonly [], JsonValue>\n readonly getEpochInfo: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n JsonValue\n >\n readonly getEpochSchedule: RpcMethodSpec<readonly [], JsonValue>\n readonly getFeeForMessage: RpcMethodSpec<\n readonly [message: string, config?: SolanaConfig],\n SolanaContextResult<number | null>\n >\n readonly getFirstAvailableBlock: RpcMethodSpec<readonly [], number>\n readonly getGenesisHash: RpcMethodSpec<readonly [], string>\n readonly getHealth: RpcMethodSpec<readonly [], string>\n readonly getHighestSnapshotSlot: RpcMethodSpec<readonly [], JsonValue>\n readonly getIdentity: RpcMethodSpec<readonly [], JsonValue>\n readonly getInflationGovernor: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n JsonValue\n >\n readonly getInflationRate: RpcMethodSpec<readonly [], JsonValue>\n readonly getInflationReward: RpcMethodSpec<\n readonly [addresses: readonly string[], config?: SolanaConfig],\n JsonValue\n >\n readonly getLargestAccounts: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n JsonValue\n >\n readonly getLatestBlockhash: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n JsonValue\n >\n readonly getLeaderSchedule: RpcMethodSpec<\n readonly [slot?: number | null, config?: SolanaConfig],\n JsonValue | null\n >\n readonly getMaxRetransmitSlot: RpcMethodSpec<readonly [], number>\n readonly getMaxShredInsertSlot: RpcMethodSpec<readonly [], number>\n readonly getMinimumBalanceForRentExemption: RpcMethodSpec<\n readonly [dataLength: number, config?: SolanaConfig],\n number\n >\n readonly getMultipleAccounts: RpcMethodSpec<\n readonly [addresses: readonly string[], config?: SolanaConfig],\n SolanaContextResult<JsonValue>\n >\n readonly getParsedTransaction: RpcMethodSpec<\n readonly [signature: string, config?: SolanaConfig],\n JsonValue | null\n >\n readonly getPriorityFeeEstimate: RpcMethodSpec<\n readonly [request: SolanaConfig],\n PriorityFeeEstimate\n >\n readonly getProgramAccounts: RpcMethodSpec<\n readonly [programAddress: string, config?: SolanaConfig],\n JsonValue\n >\n readonly getProgramAccountsV2: RpcMethodSpec<\n readonly [programAddress: string, config: SolanaConfig],\n JsonValue\n >\n readonly getRecentPerformanceSamples: RpcMethodSpec<\n readonly [limit?: number],\n JsonValue\n >\n readonly getRecentPrioritizationFees: RpcMethodSpec<\n readonly [addresses?: readonly string[]],\n JsonValue\n >\n readonly getSignatureStatuses: RpcMethodSpec<\n readonly [signatures: readonly string[], config?: SolanaConfig],\n JsonValue\n >\n readonly getSignaturesForAddress: RpcMethodSpec<\n readonly [address: string, config?: SolanaConfig],\n JsonValue\n >\n readonly getSlot: RpcMethodSpec<readonly [config?: SolanaConfig], number>\n readonly getSlotLeader: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n string\n >\n readonly getSlotLeaders: RpcMethodSpec<\n readonly [startSlot: number, limit: number],\n readonly string[]\n >\n readonly getStakeMinimumDelegation: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n SolanaContextResult<number>\n >\n readonly getSupply: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n JsonValue\n >\n readonly getTokenAccountBalance: RpcMethodSpec<\n readonly [address: string, config?: SolanaConfig],\n JsonValue\n >\n readonly getTokenAccountsByDelegate: RpcMethodSpec<\n readonly [delegate: string, filter: SolanaConfig, config?: SolanaConfig],\n JsonValue\n >\n readonly getTokenAccountsByOwner: RpcMethodSpec<\n readonly [owner: string, filter: SolanaConfig, config?: SolanaConfig],\n JsonValue\n >\n readonly getTokenLargestAccounts: RpcMethodSpec<\n readonly [mint: string, config?: SolanaConfig],\n JsonValue\n >\n readonly getTokenSupply: RpcMethodSpec<\n readonly [mint: string, config?: SolanaConfig],\n JsonValue\n >\n readonly getTransaction: RpcMethodSpec<\n readonly [signature: string, config?: SolanaConfig],\n JsonValue | null\n >\n readonly getTransactionCount: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n number\n >\n readonly getVersion: RpcMethodSpec<readonly [], JsonObject>\n readonly getVoteAccounts: RpcMethodSpec<\n readonly [config?: SolanaConfig],\n JsonValue\n >\n readonly isBlockhashValid: RpcMethodSpec<\n readonly [blockhash: string, config?: SolanaConfig],\n SolanaContextResult<boolean>\n >\n readonly minimumLedgerSlot: RpcMethodSpec<readonly [], number>\n readonly requestAirdrop: RpcMethodSpec<\n readonly [address: string, lamports: number, config?: SolanaConfig],\n string\n >\n readonly sendTransaction: RpcMethodSpec<\n readonly [transaction: string, config?: SolanaConfig],\n string\n >\n readonly simulateTransaction: RpcMethodSpec<\n readonly [transaction: string, config?: SolanaConfig],\n JsonValue\n >\n}\n\nexport interface AssetRequest {\n readonly id: string\n readonly displayOptions?: Readonly<Record<string, boolean>>\n}\n\nexport interface AssetBatchRequest {\n readonly ids: readonly string[]\n readonly displayOptions?: Readonly<Record<string, boolean>>\n}\n\nexport interface AssetListRequest {\n readonly cursor?: string\n readonly limit?: number\n readonly page?: number\n readonly [key: string]: unknown\n}\n\nexport type IndexedAsset = Readonly<Record<string, unknown>>\nexport type IndexedAssetProof = Readonly<Record<string, unknown>>\n\nexport interface IndexedAssetList<TItem = IndexedAsset> {\n readonly cursor?: string\n readonly items: readonly TItem[]\n readonly limit?: number\n readonly page?: number\n readonly total?: number\n readonly [key: string]: unknown\n}\n\nexport interface SolanaDasSchema {\n readonly getAsset: RpcMethodSpec<AssetRequest, IndexedAsset | null>\n readonly getAssetBatch: RpcMethodSpec<\n AssetBatchRequest,\n readonly (IndexedAsset | null)[]\n >\n readonly getAssetProof: RpcMethodSpec<AssetRequest, IndexedAssetProof | null>\n readonly getAssetProofBatch: RpcMethodSpec<\n AssetBatchRequest,\n readonly (IndexedAssetProof | null)[]\n >\n readonly getAssetsByAuthority: RpcMethodSpec<\n AssetListRequest & { readonly authorityAddress: string },\n IndexedAssetList\n >\n readonly getAssetsByCreator: RpcMethodSpec<\n AssetListRequest & {\n readonly creatorAddress: string\n readonly onlyVerified?: boolean\n },\n IndexedAssetList\n >\n readonly getAssetsByGroup: RpcMethodSpec<\n AssetListRequest & {\n readonly groupKey: string\n readonly groupValue: string\n },\n IndexedAssetList\n >\n readonly getAssetsByOwner: RpcMethodSpec<\n AssetListRequest & { readonly ownerAddress: string },\n IndexedAssetList\n >\n readonly getNftEditions: RpcMethodSpec<\n AssetListRequest & { readonly mint: string },\n Readonly<Record<string, unknown>>\n >\n readonly getSignaturesForAsset: RpcMethodSpec<\n AssetListRequest & { readonly id: string },\n Readonly<Record<string, unknown>>\n >\n readonly getTokenAccounts: RpcMethodSpec<\n AssetListRequest,\n Readonly<Record<string, unknown>>\n >\n readonly getTokensByDelegate: RpcMethodSpec<\n AssetListRequest & { readonly delegate: string },\n Readonly<Record<string, unknown>>\n >\n readonly getTokensByOwner: RpcMethodSpec<\n AssetListRequest & { readonly owner: string },\n Readonly<Record<string, unknown>>\n >\n readonly searchAssets: RpcMethodSpec<AssetListRequest, IndexedAssetList>\n}\n\nexport interface NumericFilter {\n readonly eq?: number\n readonly gt?: number\n readonly gte?: number\n readonly lt?: number\n readonly lte?: number\n}\n\nexport interface AddressTransactionsOptions {\n readonly before?: string\n readonly commitment?: SolanaCommitment\n readonly encoding?: 'base58' | 'base64' | 'json'\n readonly filters?: Readonly<Record<string, unknown>>\n readonly limit?: number\n readonly maxSupportedTransactionVersion?: number\n readonly paginationToken?: string\n readonly sortOrder?: 'asc' | 'desc'\n readonly transactionDetails?: 'full' | 'signatures'\n readonly until?: string\n}\n\nexport interface AddressTransaction {\n readonly blockTime: number | null\n readonly confirmationStatus: SolanaCommitment\n readonly err: unknown\n readonly memo: string | null\n readonly meta?: unknown\n readonly signature: string\n readonly slot: number\n readonly transaction?: unknown\n readonly transactionIndex: number\n readonly version?: unknown\n readonly [key: string]: unknown\n}\n\nexport interface AddressTransactionPage {\n readonly data: readonly AddressTransaction[]\n readonly paginationToken: string | null\n readonly windowStart: number | null\n}\n\nexport interface AddressTransfersOptions {\n readonly commitment?: SolanaCommitment\n readonly direction?: 'any' | 'in' | 'out'\n readonly filters?: {\n readonly amount?: NumericFilter\n readonly blockTime?: NumericFilter\n readonly slot?: NumericFilter\n }\n readonly limit?: number\n readonly mint?: string\n readonly paginationToken?: string\n readonly solMode?: 'merged' | 'separate'\n readonly sortOrder?: 'asc' | 'desc'\n readonly with?: string\n}\n\nexport interface AddressTransfer {\n readonly amount: string\n readonly blockTime: number | null\n readonly confirmationStatus: 'finalized'\n readonly decimals: number\n readonly feeAmount: string | null\n readonly feeUiAmount: string | null\n readonly fromTokenAccount: string | null\n readonly fromUserAccount: string | null\n readonly innerInstructionIdx: number\n readonly instructionIdx: number\n readonly mint: string | null\n readonly signature: string\n readonly slot: number\n readonly toTokenAccount: string | null\n readonly toUserAccount: string | null\n readonly transactionIdx: number\n readonly type:\n | 'burn'\n | 'changeOwner'\n | 'mint'\n | 'transfer'\n | 'unwrap'\n | 'withdrawWithheldFee'\n | 'wrap'\n readonly uiAmount: string\n readonly [key: string]: unknown\n}\n\nexport interface AddressTransferPage {\n readonly data: readonly AddressTransfer[]\n readonly paginationToken: string | null\n readonly windowStart: number | null\n}\n\nexport interface SolanaHistorySchema {\n readonly getTransactionsForAddress: RpcMethodSpec<\n readonly [address: string, options?: AddressTransactionsOptions],\n AddressTransactionPage | null\n >\n readonly getTransfersByAddress: RpcMethodSpec<\n readonly [address: string, options?: AddressTransfersOptions],\n AddressTransferPage\n >\n}\n\nexport interface PingMeasurement {\n readonly city: string | null\n readonly country: string | null\n readonly fromIp: string | null\n readonly icmpReplied: boolean\n readonly lat: number | null\n readonly lon: number | null\n readonly measuredAt: string | null\n readonly ms: number | null\n readonly org: string | null\n readonly postal: string | null\n readonly region: string | null\n readonly timezone: string | null\n readonly [key: string]: unknown\n}\n\nexport interface LeaderSlot {\n readonly epoch: number\n readonly featureSet: string | null\n readonly gossipPort: number | null\n readonly gossipUpdatedAt: string | null\n readonly identity: string\n readonly ipAddress: string | null\n readonly leaderCity: string | null\n readonly leaderCountry: string | null\n readonly leaderLat: number | null\n readonly leaderLon: number | null\n readonly leaderOrg: string | null\n readonly leaderRegion: string | null\n readonly leaderTimezone: string | null\n readonly pingToLeaders: readonly PingMeasurement[]\n readonly rpcAddress: string | null\n readonly slot: string\n readonly stakeWeight: number\n readonly tpuPort: number | null\n readonly tpuQuicPort: number | null\n readonly version: string | null\n readonly [key: string]: unknown\n}\n\nexport interface LeaderSlotsResult {\n readonly data: readonly LeaderSlot[]\n readonly message: string\n readonly success: boolean\n readonly total: number\n readonly [key: string]: unknown\n}\n\nexport interface ValidatorInformation\n extends Omit<LeaderSlot, 'epoch' | 'slot'> {\n readonly gossipNodeId: number | null\n readonly slotCount: number\n}\n\nexport interface ValidatorsInformationOptions {\n readonly country?: string\n readonly limit?: number\n readonly region?: string\n}\n\nexport interface ValidatorsInformationResult {\n readonly data: readonly ValidatorInformation[]\n readonly epoch: number\n readonly message: string\n readonly success: boolean\n readonly total: number\n readonly totalValidators: number\n readonly [key: string]: unknown\n}\n\nexport interface SolanaLeaderSchema {\n readonly getLeaderSlots: RpcMethodSpec<\n readonly [slot: number],\n LeaderSlotsResult\n >\n readonly getValidatorsInformation: RpcMethodSpec<\n readonly [options: ValidatorsInformationOptions],\n ValidatorsInformationResult\n >\n}\n\nexport type AnalyticsTimeBound = number | string\n\nexport interface TopProgramsOptions {\n readonly includeVotes?: boolean\n readonly limit?: number\n readonly since?: AnalyticsTimeBound\n readonly until?: AnalyticsTimeBound\n}\n\nexport interface TopProgramRow {\n readonly errors: string\n readonly invocations: string\n readonly program: string\n readonly total_cus: string\n readonly [key: string]: unknown\n}\n\nexport type SlotStatsOptions =\n | { readonly slot: number }\n | { readonly fromSlot: number; readonly toSlot: number }\n\nexport interface SlotStatsRow {\n readonly block_time: number\n readonly non_vote_transaction_count: number\n readonly slot: number\n readonly transaction_count: number\n readonly vote_transaction_count: number\n readonly [key: string]: unknown\n}\n\nexport interface TpsTimeseriesOptions {\n readonly bucketSec?: number\n readonly from: AnalyticsTimeBound\n readonly to: AnalyticsTimeBound\n}\n\nexport interface TpsBucket {\n readonly bucket: number\n readonly non_vote_tps: number\n readonly total_tps: number\n readonly [key: string]: unknown\n}\n\nexport interface EpochSummary {\n readonly distinct_programs: string\n readonly epoch: number\n readonly first_block_time: number\n readonly last_block_time: number\n readonly non_vote_txs: string\n readonly program_invocations: string\n readonly slots: string\n readonly total_txs: string\n readonly vote_txs: string\n readonly [key: string]: unknown\n}\n\nexport interface ProgramStatsOptions {\n readonly bucketSec?: number\n readonly programIdBase58: string\n readonly since?: AnalyticsTimeBound\n readonly until?: AnalyticsTimeBound\n}\n\nexport interface ProgramStatsBucket {\n readonly bucket: number\n readonly errors: string\n readonly invocations: string\n readonly total_cus: string\n readonly [key: string]: unknown\n}\n\nexport interface SolanaAnalyticsSchema {\n readonly jetEpochSummary: RpcMethodSpec<\n readonly [options: { readonly epoch: number }],\n EpochSummary | null\n >\n readonly jetProgramStats: RpcMethodSpec<\n readonly [options: ProgramStatsOptions],\n readonly ProgramStatsBucket[]\n >\n readonly jetSlotStats: RpcMethodSpec<\n readonly [options: SlotStatsOptions],\n readonly SlotStatsRow[]\n >\n readonly jetTopPrograms: RpcMethodSpec<\n readonly [options: TopProgramsOptions],\n readonly TopProgramRow[]\n >\n readonly jetTpsTimeseries: RpcMethodSpec<\n readonly [options: TpsTimeseriesOptions],\n readonly TpsBucket[]\n >\n}\n\nexport const SOLANA_RPC_METHODS = [\n 'getAccountInfo',\n 'getBalance',\n 'getBlock',\n 'getBlockCommitment',\n 'getBlockHeight',\n 'getBlockProduction',\n 'getBlockTime',\n 'getBlocks',\n 'getBlocksWithLimit',\n 'getClusterNodes',\n 'getEpochInfo',\n 'getEpochSchedule',\n 'getFeeForMessage',\n 'getFirstAvailableBlock',\n 'getGenesisHash',\n 'getHealth',\n 'getHighestSnapshotSlot',\n 'getIdentity',\n 'getInflationGovernor',\n 'getInflationRate',\n 'getInflationReward',\n 'getLargestAccounts',\n 'getLatestBlockhash',\n 'getLeaderSchedule',\n 'getMaxRetransmitSlot',\n 'getMaxShredInsertSlot',\n 'getMinimumBalanceForRentExemption',\n 'getMultipleAccounts',\n 'getParsedTransaction',\n 'getPriorityFeeEstimate',\n 'getProgramAccounts',\n 'getProgramAccountsV2',\n 'getRecentPerformanceSamples',\n 'getRecentPrioritizationFees',\n 'getSignatureStatuses',\n 'getSignaturesForAddress',\n 'getSlot',\n 'getSlotLeader',\n 'getSlotLeaders',\n 'getStakeMinimumDelegation',\n 'getSupply',\n 'getTokenAccountBalance',\n 'getTokenAccountsByDelegate',\n 'getTokenAccountsByOwner',\n 'getTokenLargestAccounts',\n 'getTokenSupply',\n 'getTransaction',\n 'getTransactionCount',\n 'getVersion',\n 'getVoteAccounts',\n 'isBlockhashValid',\n 'minimumLedgerSlot',\n 'requestAirdrop',\n 'sendTransaction',\n 'simulateTransaction',\n] as const satisfies readonly (keyof SolanaRpcSchema)[]\n\nexport const SOLANA_DAS_METHODS = [\n 'getAsset',\n 'getAssetBatch',\n 'getAssetProof',\n 'getAssetProofBatch',\n 'getAssetsByAuthority',\n 'getAssetsByCreator',\n 'getAssetsByGroup',\n 'getAssetsByOwner',\n 'getNftEditions',\n 'getSignaturesForAsset',\n 'getTokenAccounts',\n 'getTokensByDelegate',\n 'getTokensByOwner',\n 'searchAssets',\n] as const satisfies readonly (keyof SolanaDasSchema)[]\n\nexport const SOLANA_HISTORY_METHODS = [\n 'getTransactionsForAddress',\n 'getTransfersByAddress',\n] as const satisfies readonly (keyof SolanaHistorySchema)[]\n\nexport const SOLANA_LEADER_METHODS = [\n 'getLeaderSlots',\n 'getValidatorsInformation',\n] as const satisfies readonly (keyof SolanaLeaderSchema)[]\n\nexport const SOLANA_ANALYTICS_METHODS = [\n 'jetEpochSummary',\n 'jetProgramStats',\n 'jetSlotStats',\n 'jetTopPrograms',\n 'jetTpsTimeseries',\n] as const satisfies readonly (keyof SolanaAnalyticsSchema)[]\n\nconst heavyRpcMethods = new Set<string>([\n 'getPriorityFeeEstimate',\n 'getProgramAccounts',\n 'getProgramAccountsV2',\n 'getTokenLargestAccounts',\n])\n\nconst validateStandardBatch = (calls: readonly RpcBatchCall[]) => {\n let containsHeavy = false\n let containsStandard = false\n for (const call of calls) {\n if (heavyRpcMethods.has(call.method)) containsHeavy = true\n else containsStandard = true\n }\n if (containsHeavy && containsStandard) {\n throw new ErpcBatchPolicyError(\n 'Solana indexed and standard RPC methods cannot share a batch',\n )\n }\n}\n\nconst rejectLeaderBatch = (calls: readonly RpcBatchCall[]) => {\n if (calls.length > 0) {\n throw new ErpcBatchPolicyError('Leader RPC methods do not support batching')\n }\n}\n\nexport interface SolanaClient {\n readonly analytics: RpcNamespace<SolanaAnalyticsSchema>\n readonly das: RpcNamespace<SolanaDasSchema>\n readonly history: RpcNamespace<SolanaHistorySchema>\n readonly leaders: RpcNamespace<SolanaLeaderSchema>\n readonly rpc: RpcNamespace<SolanaRpcSchema>\n}\n\nexport const createSolanaClient = (\n transport: HttpJsonRpcTransport,\n): SolanaClient => ({\n rpc: createRpcNamespace<SolanaRpcSchema>({\n transport,\n parameterMode: 'positional',\n validateBatch: validateStandardBatch,\n }),\n das: createRpcNamespace<SolanaDasSchema>({\n transport,\n parameterMode: 'named',\n }),\n history: createRpcNamespace<SolanaHistorySchema>({\n transport,\n parameterMode: 'positional',\n }),\n leaders: createRpcNamespace<SolanaLeaderSchema>({\n transport,\n parameterMode: 'positional',\n validateBatch: rejectLeaderBatch,\n }),\n analytics: createRpcNamespace<SolanaAnalyticsSchema>({\n transport,\n parameterMode: 'positional',\n }),\n})\n","import {\n ErpcAbortedError,\n ErpcConfigError,\n ErpcInvalidResponseError,\n ErpcJsonRpcError,\n ErpcTimeoutError,\n ErpcTransportError,\n redactJsonRpcError,\n} from '../errors'\nimport type { JsonRpcTransport } from '../rpc/client'\nimport type {\n JsonRpcErrorObject,\n JsonRpcId,\n JsonRpcParams,\n RpcBatchCall,\n RpcSendOptions,\n} from '../rpc/types'\n\nexport interface RpcNotification {\n readonly jsonrpc: '2.0'\n readonly method: string\n readonly params: unknown\n}\n\nexport type RpcNotificationListener = (notification: RpcNotification) => void\n\nexport interface WebSocketTransportConfig {\n readonly endpoint: URL\n readonly maxBatchSize?: number\n readonly timeoutMs: number\n readonly webSocket?: typeof globalThis.WebSocket\n}\n\ninterface PendingResponse {\n readonly cleanup: () => void\n readonly reject: (reason: unknown) => void\n readonly resolve: (value: unknown) => void\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst isRpcError = (value: unknown): value is JsonRpcErrorObject =>\n isObject(value) &&\n typeof value.code === 'number' &&\n typeof value.message === 'string'\n\nconst publicEndpoint = (endpoint: URL): string => {\n const url = new URL(endpoint)\n url.search = ''\n url.hash = ''\n return url.toString()\n}\n\nexport class WebSocketJsonRpcTransport implements JsonRpcTransport {\n readonly endpoint: string\n readonly maxBatchSize: number\n\n readonly #connectionUrl: string\n readonly #credential: string | undefined\n readonly #listeners = new Set<RpcNotificationListener>()\n readonly #pending = new Map<JsonRpcId, PendingResponse>()\n readonly #timeoutMs: number\n readonly #webSocket?: typeof globalThis.WebSocket\n #connectPromise: Promise<void> | undefined\n #nextId = 1\n #socket: WebSocket | undefined\n\n constructor(config: WebSocketTransportConfig) {\n const implementation = config.webSocket ?? globalThis.WebSocket\n if (typeof implementation === 'function') this.#webSocket = implementation\n this.#credential = config.endpoint.searchParams.get('api-key') ?? undefined\n this.#connectionUrl = config.endpoint.toString()\n this.endpoint = publicEndpoint(config.endpoint)\n this.maxBatchSize = config.maxBatchSize ?? 256\n this.#timeoutMs = config.timeoutMs\n }\n\n async connect(): Promise<void> {\n if (this.#socket?.readyState === 1) return\n if (this.#connectPromise) return this.#connectPromise\n if (!this.#webSocket) {\n throw new ErpcConfigError(\n 'A WebSocket implementation is required for subscriptions',\n )\n }\n\n this.#connectPromise = new Promise<void>((resolve, reject) => {\n const socket = new this.#webSocket!(this.#connectionUrl)\n this.#socket = socket\n\n const timeout = setTimeout(() => {\n socket.close()\n reject(new ErpcTimeoutError(this.#timeoutMs))\n }, this.#timeoutMs)\n\n socket.addEventListener(\n 'open',\n () => {\n clearTimeout(timeout)\n resolve()\n },\n { once: true },\n )\n socket.addEventListener(\n 'error',\n () => {\n clearTimeout(timeout)\n reject(new ErpcTransportError('Unable to connect to ERPC WebSocket'))\n },\n { once: true },\n )\n socket.addEventListener('message', (event: MessageEvent<unknown>) => {\n void this.#onMessage(event.data)\n })\n socket.addEventListener('close', () => {\n this.#socket = undefined\n this.#connectPromise = undefined\n const error = new ErpcTransportError('ERPC WebSocket connection closed')\n for (const pending of this.#pending.values()) pending.reject(error)\n this.#pending.clear()\n })\n }).catch((error: unknown) => {\n this.#connectPromise = undefined\n throw error\n })\n\n return this.#connectPromise\n }\n\n close(code = 1000, reason = 'Client closed connection'): void {\n this.#socket?.close(code, reason)\n this.#socket = undefined\n this.#connectPromise = undefined\n }\n\n onNotification(listener: RpcNotificationListener): () => void {\n this.#listeners.add(listener)\n return () => this.#listeners.delete(listener)\n }\n\n async request<TResult>(\n method: string,\n params?: JsonRpcParams,\n options: RpcSendOptions = {},\n ): Promise<TResult> {\n await this.connect()\n const id = this.#id()\n const promise = this.#waitFor<TResult>(id, options)\n const request: Record<string, unknown> = { jsonrpc: '2.0', id, method }\n if (params !== undefined) request.params = params\n this.#send(request, id)\n return promise\n }\n\n async batch<TResult extends readonly unknown[]>(\n calls: readonly RpcBatchCall[],\n options: RpcSendOptions = {},\n ): Promise<TResult> {\n if (calls.length === 0) return [] as unknown as TResult\n if (calls.length > this.maxBatchSize) {\n throw new ErpcInvalidResponseError(\n `A batch may contain at most ${this.maxBatchSize} calls`,\n )\n }\n\n await this.connect()\n const requests = calls.map((call) => {\n const id = this.#id()\n const request: Record<string, unknown> = {\n jsonrpc: '2.0',\n id,\n method: call.method,\n }\n if (call.params !== undefined) request.params = call.params\n return { id, request, response: this.#waitFor(id, options) }\n })\n\n try {\n this.#socket?.send(JSON.stringify(requests.map(({ request }) => request)))\n } catch (error) {\n for (const { id } of requests) this.#reject(id, error)\n }\n return Promise.all(requests.map(({ response }) => response)) as unknown as Promise<TResult>\n }\n\n #id(): number {\n const id = this.#nextId\n this.#nextId = id >= Number.MAX_SAFE_INTEGER ? 1 : id + 1\n return id\n }\n\n #send(request: unknown, id: JsonRpcId): void {\n try {\n this.#socket?.send(JSON.stringify(request))\n } catch (error) {\n this.#reject(id, error)\n }\n }\n\n #waitFor<TResult>(\n id: JsonRpcId,\n options: RpcSendOptions,\n ): Promise<TResult> {\n return new Promise<TResult>((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.#pending.delete(id)\n reject(new ErpcTimeoutError(this.#timeoutMs))\n }, this.#timeoutMs)\n\n const abort = () => {\n clearTimeout(timeout)\n this.#pending.delete(id)\n reject(new ErpcAbortedError())\n }\n options.signal?.addEventListener('abort', abort, { once: true })\n\n const cleanup = () => {\n clearTimeout(timeout)\n options.signal?.removeEventListener('abort', abort)\n }\n this.#pending.set(id, {\n resolve: (value) => resolve(value as TResult),\n reject,\n cleanup,\n })\n if (options.signal?.aborted) abort()\n })\n }\n\n #reject(id: JsonRpcId, _reason: unknown): void {\n const pending = this.#pending.get(id)\n if (!pending) return\n pending.cleanup()\n this.#pending.delete(id)\n // A custom WebSocket implementation may include its connection URL in a\n // thrown error, so never retain the original error as a public cause.\n pending.reject(\n new ErpcTransportError('Unable to send ERPC WebSocket request'),\n )\n }\n\n async #onMessage(data: unknown): Promise<void> {\n const text = await this.#messageText(data)\n if (text === null) return\n\n let parsed: unknown\n try {\n parsed = JSON.parse(text) as unknown\n } catch {\n return\n }\n\n if (Array.isArray(parsed)) {\n for (const item of parsed) this.#dispatch(item)\n } else {\n this.#dispatch(parsed)\n }\n }\n\n async #messageText(data: unknown): Promise<string | null> {\n if (typeof data === 'string') return data\n if (data instanceof ArrayBuffer) return new TextDecoder().decode(data)\n if (ArrayBuffer.isView(data)) {\n return new TextDecoder().decode(\n new Uint8Array(data.buffer, data.byteOffset, data.byteLength),\n )\n }\n if (typeof Blob !== 'undefined' && data instanceof Blob) return data.text()\n return null\n }\n\n #dispatch(message: unknown): void {\n if (!isObject(message)) return\n const id = message.id\n if (typeof id === 'number' || typeof id === 'string') {\n const pending = this.#pending.get(id)\n if (!pending) return\n pending.cleanup()\n this.#pending.delete(id)\n if (isRpcError(message.error)) {\n pending.reject(\n new ErpcJsonRpcError(\n redactJsonRpcError(message.error, this.#credential),\n ),\n )\n }\n else if ('result' in message) pending.resolve(message.result)\n else pending.reject(new ErpcInvalidResponseError())\n return\n }\n\n if (\n message.jsonrpc === '2.0' &&\n typeof message.method === 'string' &&\n 'params' in message\n ) {\n const notification: RpcNotification = {\n jsonrpc: '2.0',\n method: message.method,\n params: message.params,\n }\n for (const listener of this.#listeners) listener(notification)\n }\n }\n}\n","import { createRpcNamespace, type RpcNamespace } from './rpc/client'\nimport type { EthereumSubscriptionSchema } from './rpc/ethereum'\nimport type { RpcMethodSpec } from './rpc/types'\nimport {\n WebSocketJsonRpcTransport,\n type RpcNotification,\n type RpcNotificationListener,\n} from './transport/websocket'\n\nexport type SubscriptionId = number | string\nexport type SubscriptionListener<TResult> = (result: TResult) => void\n\ninterface NotificationParams {\n readonly result: unknown\n readonly subscription: SubscriptionId\n}\n\nconst notificationParams = (\n notification: RpcNotification,\n): NotificationParams | null => {\n if (typeof notification.params !== 'object' || notification.params === null) {\n return null\n }\n const params = notification.params as Record<string, unknown>\n if (\n (typeof params.subscription !== 'number' &&\n typeof params.subscription !== 'string') ||\n !('result' in params)\n ) {\n return null\n }\n return {\n subscription: params.subscription,\n result: params.result,\n }\n}\n\nexport class RpcSubscription<TId extends SubscriptionId = SubscriptionId> {\n readonly id: TId\n readonly #unsubscribe: () => Promise<boolean>\n #closed = false\n\n constructor(id: TId, unsubscribe: () => Promise<boolean>) {\n this.id = id\n this.#unsubscribe = unsubscribe\n }\n\n async unsubscribe(): Promise<boolean> {\n if (this.#closed) return true\n const result = await this.#unsubscribe()\n if (result) this.#closed = true\n return result\n }\n}\n\nexport class EthereumSubscriptions {\n readonly rpc: RpcNamespace<EthereumSubscriptionSchema>\n readonly #transport: WebSocketJsonRpcTransport\n\n constructor(transport: WebSocketJsonRpcTransport) {\n this.#transport = transport\n this.rpc = createRpcNamespace<EthereumSubscriptionSchema>({\n transport,\n parameterMode: 'positional',\n })\n }\n\n close(): void {\n this.#transport.close()\n }\n\n onNotification(listener: RpcNotificationListener): () => void {\n return this.#transport.onNotification(listener)\n }\n\n async subscribe<TResult = unknown>(\n subscription: string,\n listener: SubscriptionListener<TResult>,\n ...options: readonly unknown[]\n ): Promise<RpcSubscription<string>> {\n let id: string | undefined\n const removeListener = this.#transport.onNotification((notification) => {\n const params = notificationParams(notification)\n if (params && params.subscription === id) listener(params.result as TResult)\n })\n\n try {\n id = await this.#transport.request<string>('eth_subscribe', [\n subscription,\n ...options,\n ])\n } catch (error) {\n removeListener()\n throw error\n }\n\n return new RpcSubscription(id, async () => {\n const result = await this.#transport.request<boolean>('eth_unsubscribe', [\n id,\n ])\n if (result) removeListener()\n return result\n })\n }\n}\n\nexport interface SolanaEnhancedSubscriptionSchema {\n readonly accountSubscribe: RpcMethodSpec<\n readonly [address: string, options?: Readonly<Record<string, unknown>>],\n number\n >\n readonly accountUnsubscribe: RpcMethodSpec<\n readonly [subscriptionId: number],\n boolean\n >\n readonly transactionSubscribe: RpcMethodSpec<\n readonly [\n filter: Readonly<Record<string, unknown>>,\n options?: Readonly<Record<string, unknown>>,\n ],\n number\n >\n readonly transactionUnsubscribe: RpcMethodSpec<\n readonly [subscriptionId: number],\n boolean\n >\n}\n\nexport const SOLANA_ENHANCED_SUBSCRIPTION_METHODS = [\n 'accountSubscribe',\n 'accountUnsubscribe',\n 'transactionSubscribe',\n 'transactionUnsubscribe',\n] as const satisfies readonly (keyof SolanaEnhancedSubscriptionSchema)[]\n\nexport class SolanaSubscriptions {\n readonly rpc: RpcNamespace<SolanaEnhancedSubscriptionSchema>\n readonly #transport: WebSocketJsonRpcTransport\n\n constructor(transport: WebSocketJsonRpcTransport) {\n this.#transport = transport\n this.rpc = createRpcNamespace<SolanaEnhancedSubscriptionSchema>({\n transport,\n parameterMode: 'positional',\n })\n }\n\n close(): void {\n this.#transport.close()\n }\n\n onNotification(listener: RpcNotificationListener): () => void {\n return this.#transport.onNotification(listener)\n }\n\n accountSubscribe<TResult = unknown>(\n address: string,\n listener: SubscriptionListener<TResult>,\n options?: Readonly<Record<string, unknown>>,\n ): Promise<RpcSubscription<number>> {\n const params = options === undefined ? [address] : [address, options]\n return this.#subscribe<number, TResult>(\n 'accountSubscribe',\n params,\n 'accountUnsubscribe',\n listener,\n )\n }\n\n transactionSubscribe<TResult = unknown>(\n filter: Readonly<Record<string, unknown>>,\n listener: SubscriptionListener<TResult>,\n options?: Readonly<Record<string, unknown>>,\n ): Promise<RpcSubscription<number>> {\n const params = options === undefined ? [filter] : [filter, options]\n return this.#subscribe<number, TResult>(\n 'transactionSubscribe',\n params,\n 'transactionUnsubscribe',\n listener,\n )\n }\n\n async rawSubscribe<TResult = unknown>(\n subscribeMethod: string,\n params: readonly unknown[],\n unsubscribeMethod: string,\n listener: SubscriptionListener<TResult>,\n ): Promise<RpcSubscription> {\n return this.#subscribe(\n subscribeMethod,\n params,\n unsubscribeMethod,\n listener,\n )\n }\n\n async #subscribe<TId extends SubscriptionId, TResult>(\n subscribeMethod: string,\n params: readonly unknown[],\n unsubscribeMethod: string,\n listener: SubscriptionListener<TResult>,\n ): Promise<RpcSubscription<TId>> {\n let id: TId | undefined\n const removeListener = this.#transport.onNotification((notification) => {\n const value = notificationParams(notification)\n if (value && value.subscription === id) listener(value.result as TResult)\n })\n\n try {\n id = await this.#transport.request<TId>(subscribeMethod, params)\n } catch (error) {\n removeListener()\n throw error\n }\n\n return new RpcSubscription(id, async () => {\n const result = await this.#transport.request<boolean>(unsubscribeMethod, [\n id,\n ])\n if (result) removeListener()\n return result\n })\n }\n}\n","import {\n ErpcAbortedError,\n ErpcHttpError,\n ErpcInvalidResponseError,\n ErpcJsonRpcError,\n ErpcTimeoutError,\n ErpcTransportError,\n redactJsonRpcError,\n} from '../errors'\nimport type {\n JsonRpcFailure,\n JsonRpcId,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n RpcBatchCall,\n RpcSendOptions,\n} from '../rpc/types'\n\nexport interface HttpTransportConfig {\n readonly apiKey: string\n readonly endpoint: URL\n readonly fetch: typeof globalThis.fetch\n readonly headers: Readonly<Record<string, string>>\n readonly maxBatchSize?: number\n readonly timeoutMs: number\n}\n\ninterface ControlledSignal {\n readonly cleanup: () => void\n readonly signal: AbortSignal\n readonly timedOut: () => boolean\n}\n\nconst controlledSignal = (\n timeoutMs: number,\n external?: AbortSignal,\n): ControlledSignal => {\n const controller = new AbortController()\n let didTimeOut = false\n\n const timeout = setTimeout(() => {\n didTimeOut = true\n controller.abort()\n }, timeoutMs)\n\n const abort = () => controller.abort()\n if (external?.aborted) controller.abort()\n else external?.addEventListener('abort', abort, { once: true })\n\n return {\n signal: controller.signal,\n timedOut: () => didTimeOut,\n cleanup: () => {\n clearTimeout(timeout)\n external?.removeEventListener('abort', abort)\n },\n }\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst isFailure = (value: unknown): value is JsonRpcFailure =>\n isObject(value) &&\n isObject(value.error) &&\n typeof value.error.code === 'number' &&\n typeof value.error.message === 'string'\n\nconst parseJson = (text: string): unknown => {\n try {\n return JSON.parse(text) as unknown\n } catch {\n throw new ErpcInvalidResponseError('ERPC returned malformed JSON')\n }\n}\n\nexport class HttpJsonRpcTransport {\n readonly endpoint: string\n readonly maxBatchSize: number\n\n readonly #apiKey: string\n readonly #fetch: typeof globalThis.fetch\n readonly #headers: Readonly<Record<string, string>>\n readonly #timeoutMs: number\n #nextId = 1\n\n constructor(config: HttpTransportConfig) {\n this.#apiKey = config.apiKey\n this.#fetch = config.fetch\n this.#headers = config.headers\n this.#timeoutMs = config.timeoutMs\n this.maxBatchSize = config.maxBatchSize ?? 256\n\n const endpoint = new URL(config.endpoint)\n endpoint.search = ''\n endpoint.hash = ''\n this.endpoint = endpoint.toString()\n }\n\n async request<TResult>(\n method: string,\n params?: JsonRpcParams,\n options: RpcSendOptions = {},\n ): Promise<TResult> {\n const id = this.#id()\n const request = this.#request(id, method, params)\n const response = await this.#post(request, options)\n return this.#unwrap<TResult>(response, id)\n }\n\n async batch<TResult extends readonly unknown[]>(\n calls: readonly RpcBatchCall[],\n options: RpcSendOptions = {},\n ): Promise<TResult> {\n if (calls.length === 0) return [] as unknown as TResult\n if (calls.length > this.maxBatchSize) {\n throw new ErpcInvalidResponseError(\n `A batch may contain at most ${this.maxBatchSize} calls`,\n )\n }\n\n const requests = calls.map((call) => {\n const id = this.#id()\n return this.#request(id, call.method, call.params)\n })\n const raw = await this.#post(requests, options)\n if (!Array.isArray(raw)) {\n if (isFailure(raw)) {\n throw new ErpcJsonRpcError(redactJsonRpcError(raw.error, this.#apiKey))\n }\n throw new ErpcInvalidResponseError('ERPC returned a non-array batch response')\n }\n\n const byId = new Map<JsonRpcId, unknown>()\n for (const response of raw) {\n if (!isObject(response) || !('id' in response)) {\n throw new ErpcInvalidResponseError('ERPC returned an invalid batch item')\n }\n const id = response.id\n if (typeof id !== 'number' && typeof id !== 'string') {\n throw new ErpcInvalidResponseError('ERPC returned an invalid batch id')\n }\n byId.set(id, response)\n }\n\n const results = requests.map((request) => {\n const response = byId.get(request.id)\n if (response === undefined) {\n throw new ErpcInvalidResponseError(\n `ERPC omitted batch response id ${String(request.id)}`,\n )\n }\n return this.#unwrap(response, request.id)\n })\n return results as unknown as TResult\n }\n\n #id(): number {\n const id = this.#nextId\n this.#nextId = id >= Number.MAX_SAFE_INTEGER ? 1 : id + 1\n return id\n }\n\n #request(\n id: JsonRpcId,\n method: string,\n params?: JsonRpcParams,\n ): JsonRpcRequest<JsonRpcParams> {\n const request: {\n jsonrpc: '2.0'\n id: JsonRpcId\n method: string\n params?: JsonRpcParams\n } = { jsonrpc: '2.0', id, method }\n if (params !== undefined) request.params = params\n return request\n }\n\n async #post(\n body: unknown,\n options: RpcSendOptions,\n ): Promise<unknown> {\n const url = new URL(this.endpoint)\n url.searchParams.set('api-key', this.#apiKey)\n const controlled = controlledSignal(this.#timeoutMs, options.signal)\n\n try {\n const response = await this.#fetch(url, {\n method: 'POST',\n headers: {\n ...this.#headers,\n 'content-type': 'application/json',\n },\n body: JSON.stringify(body),\n signal: controlled.signal,\n })\n const text = await response.text()\n if (!response.ok) throw new ErpcHttpError(response.status)\n return parseJson(text)\n } catch (error) {\n if (error instanceof ErpcHttpError || error instanceof ErpcInvalidResponseError) {\n throw error\n }\n if (controlled.timedOut()) throw new ErpcTimeoutError(this.#timeoutMs)\n if (options.signal?.aborted) throw new ErpcAbortedError()\n // Do not retain the underlying fetch error: custom runtimes may include\n // the credential-bearing request URL or headers in its message.\n throw new ErpcTransportError('Unable to reach ERPC')\n } finally {\n controlled.cleanup()\n }\n }\n\n #unwrap<TResult>(response: unknown, expectedId: JsonRpcId): TResult {\n if (!isObject(response)) throw new ErpcInvalidResponseError()\n if (response.id !== expectedId) {\n throw new ErpcInvalidResponseError('ERPC returned an unexpected response id')\n }\n if (isFailure(response)) {\n throw new ErpcJsonRpcError(\n redactJsonRpcError(response.error, this.#apiKey),\n )\n }\n if (!('result' in response)) throw new ErpcInvalidResponseError()\n return (response as unknown as JsonRpcResponse<TResult> & { result: TResult })\n .result\n }\n}\n","import { AccountClient } from './account'\nimport {\n endpointWithPath,\n resolveConfig,\n websocketUrl,\n type ErpcClientConfig,\n} from './config'\nimport { PriceClient } from './price'\nimport {\n createEthereumClient,\n type EthereumClient,\n} from './rpc/ethereum'\nimport { createSolanaClient, type SolanaClient } from './rpc/solana'\nimport {\n EthereumSubscriptions,\n SolanaSubscriptions,\n} from './subscriptions'\nimport { HttpJsonRpcTransport } from './transport/http'\nimport { RestTransport } from './transport/rest'\nimport { WebSocketJsonRpcTransport } from './transport/websocket'\n\nexport interface ErpcSolanaClient extends SolanaClient {\n readonly subscriptions: SolanaSubscriptions\n}\n\nexport interface ErpcEthereumClient extends EthereumClient {\n readonly subscriptions: EthereumSubscriptions\n}\n\nexport interface ErpcClient {\n readonly account: AccountClient\n readonly ethereum: ErpcEthereumClient\n readonly price: PriceClient\n readonly solana: ErpcSolanaClient\n close(): void\n}\n\nexport const createErpcClient = (config: ErpcClientConfig): ErpcClient => {\n const resolved = resolveConfig(config)\n const sharedTransport = {\n apiKey: resolved.apiKey,\n fetch: resolved.fetch,\n headers: resolved.headers,\n timeoutMs: resolved.timeoutMs,\n }\n\n const solanaTransport = new HttpJsonRpcTransport({\n ...sharedTransport,\n endpoint: resolved.endpoint,\n })\n const ethereumEndpoint = endpointWithPath(resolved.endpoint, '/eth')\n const ethereumTransport = new HttpJsonRpcTransport({\n ...sharedTransport,\n endpoint: ethereumEndpoint,\n })\n\n const solanaWebSocket = new WebSocketJsonRpcTransport({\n endpoint: websocketUrl(resolved.endpoint, resolved.apiKey),\n timeoutMs: resolved.timeoutMs,\n ...(resolved.webSocket === undefined\n ? {}\n : { webSocket: resolved.webSocket }),\n })\n const ethereumWebSocket = new WebSocketJsonRpcTransport({\n endpoint: websocketUrl(resolved.endpoint, resolved.apiKey, '/eth'),\n timeoutMs: resolved.timeoutMs,\n ...(resolved.webSocket === undefined\n ? {}\n : { webSocket: resolved.webSocket }),\n })\n\n const priceTransport = new RestTransport({\n ...sharedTransport,\n endpoint: resolved.endpoint,\n })\n const accountTransport = new RestTransport({\n ...sharedTransport,\n endpoint: resolved.accountEndpoint,\n })\n\n const solana: ErpcSolanaClient = {\n ...createSolanaClient(solanaTransport),\n subscriptions: new SolanaSubscriptions(solanaWebSocket),\n }\n const ethereum: ErpcEthereumClient = {\n ...createEthereumClient(ethereumTransport),\n subscriptions: new EthereumSubscriptions(ethereumWebSocket),\n }\n\n return {\n solana,\n ethereum,\n price: new PriceClient(priceTransport),\n account: new AccountClient(accountTransport),\n close: () => {\n solana.subscriptions.close()\n ethereum.subscriptions.close()\n },\n }\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elsoul/erpc-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Type-safe TypeScript SDK for ERPC",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"erpc",
|
|
7
|
+
"ethereum",
|
|
8
|
+
"json-rpc",
|
|
9
|
+
"rpc",
|
|
10
|
+
"sdk",
|
|
11
|
+
"solana"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "ELSOUL LABO B.V.",
|
|
15
|
+
"homepage": "https://erpc.global",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/elsoul/erpc-sdk.git",
|
|
19
|
+
"directory": "packages/typescript"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/elsoul/erpc-sdk/issues"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"main": "./dist/index.cjs",
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"import": "./dist/index.js",
|
|
42
|
+
"require": "./dist/index.cjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup",
|
|
50
|
+
"check": "tsc --noEmit",
|
|
51
|
+
"prepublishOnly": "corepack pnpm release:check",
|
|
52
|
+
"release:check": "corepack pnpm check && corepack pnpm test && corepack pnpm build && node scripts/verify-package.mjs",
|
|
53
|
+
"test": "vitest run",
|
|
54
|
+
"test:live": "vitest run test/live.smoke.test.ts",
|
|
55
|
+
"test:watch": "vitest",
|
|
56
|
+
"pack:check": "node scripts/verify-package.mjs && corepack pnpm pack --dry-run"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^26.4.0",
|
|
60
|
+
"tsup": "^8.5.1",
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"vitest": "^4.1.11"
|
|
63
|
+
}
|
|
64
|
+
}
|