import type { Account } from '../../accounts/types.js' import type { Client } from '../../clients/createClient.js' import type { Transport } from '../../clients/transports/createTransport.js' import type { ErrorType } from '../../errors/utils.js' import type { Chain } from '../../types/chain.js' import type { Hash } from '../../types/misc.js' import type { Filter } from '../../types/utils.js' import type { RequestErrorType } from '../../utils/buildRequest.js' import { ZircuitRpcMethods } from '../constants.js' import type { Quarantine } from '../types/quarantine.js' import type { ZircuitRpcSchema } from '../types/rpc.js' import { mapRpcQurantineToQuarantine } from '../utils.js' export type IsQuarantinedParameters = { /** The transaction hash. */ hash: Hash } export type IsQuarantinedReturnType = { isQuarantined: boolean quarantine: Quarantine | undefined } export type IsQuarantinedErrorType = RequestErrorType | ErrorType /** * Returns if the transaction is quarantined. * * - Docs: https://docs.zircuit.com/info/architecture/sls-deep-dive#building-with-sls * * @param client - Client to use * @param parameters - {@link IsQuarantinedParameters} * @returns If the transaction is quarantined. {@link IsQuarantinedReturnType} * * @example * import { createPublicClient, http } from 'viem' * import { mainnet } from 'viem/chains' * import { IsQuarantined } from 'viem/public' * * const client = createPublicClient({ * chain: mainnet, * transport: http(), * }) * const isQuarantined = await IsQuarantined(client, { * hash: '0x930501e8ed46247678636cc5267aac46852c9767bd4fc3555975883344c6d167', * }) */ export async function isQuarantined< chain extends Chain | undefined, account extends Account | undefined, >( client: Client, { hash }: IsQuarantinedParameters, ): Promise { type ZircuitIsQuarantinedSchema = Filter< ZircuitRpcSchema, { Method: typeof ZircuitRpcMethods.IS_QUARANTINED } >[0] const result = await client.request( { method: ZircuitRpcMethods.IS_QUARANTINED, params: [hash], }, { dedupe: true, }, ) return { isQuarantined: result.IsQuarantined, quarantine: result.Quarantine ? mapRpcQurantineToQuarantine(result.Quarantine) : undefined, } }