UNPKG

@axiom-crypto/keystore-sdk

Version:

Keystore Rollup SDK

36 lines 1.69 kB
import { Client, HTTPTransport, RequestManager } from "@open-rpc/client-js"; import { formatBlockTagOrNumber, formatEstimateGasResponse, formatEstimateL1DataFeeResponse, formatGasPriceResponse, } from "../types/formatters"; import { DEFAULTS } from "../config"; import { createNodeClient } from "./nodeClient"; export function createSequencerClient(config) { const { url, pollingIntervalMs = DEFAULTS.POLLING_INTERVAL_MS, pollingRetries = DEFAULTS.POLLING_RETRIES, } = config; const transport = new HTTPTransport(url, { fetcher: globalThis.fetch, }); const client = new Client(new RequestManager([transport])); const nodeClient = createNodeClient({ url, pollingIntervalMs, pollingRetries }); const sendRawTransaction = async ({ data, }) => await client.request({ method: "keystore_sendRawTransaction", params: [data] }); const gasPrice = async () => { const res = await client.request({ method: "keystore_gasPrice", params: [] }); return formatGasPriceResponse(res); }; const estimateGas = async ({ txData }) => { const res = await client.request({ method: "keystore_estimateGas", params: [txData] }); return formatEstimateGasResponse(res); }; const estimateL1DataFee = async ({ txData, block, }) => { const res = await client.request({ method: "keystore_estimateL1DataFee", params: [txData, formatBlockTagOrNumber(block)], }); return formatEstimateL1DataFeeResponse(res); }; return { ...nodeClient, sendRawTransaction, gasPrice, estimateGas, estimateL1DataFee, }; } //# sourceMappingURL=sequencerClient.js.map