import type { Address } from 'abitype' 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 { RpcSchema } from '../../types/eip1193.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 { ZircuitRpcSchema } from '../types/rpc.js' import { mapRpcQurantineToQuarantine } from '../utils.js' export type GetQuarantinedParameters = { /** The account address. */ from?: Address } export type GetQuarantinedReturnType = { transactionHash: Hash quarantinedAt: Date expiresOn: Date releasedReason: string quarantinedBy: string quarantinedReason: string releasedBy: string }[] export type GetQuarantinedErrorType = RequestErrorType | ErrorType /** * Returns the transactions from an account that have been quarantined. * * - Docs: Docs: https://docs.zircuit.com/info/architecture/sls-deep-dive#building-with-sls * * @param client - Client to use * @param parameters - {@link GetQuarantinedParameters} * @returns If the transaction is quarantined. {@link GetQuarantinedReturnType} * * @example * import { createPublicClient, http } from 'viem' * import { mainnet } from 'viem/chains' * import { GetQuarantined } from 'viem/public' * * const client = createPublicClient({ * chain: mainnet, * transport: http(), * }) * const GetQuarantined = await getQuarantined(client, { * from: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', * }) */ export async function getQuarantined< chain extends Chain | undefined, account extends Account | undefined, rpcSchema extends RpcSchema | undefined, >( client: Client, { from }: GetQuarantinedParameters, ): Promise { type ZircuitGetQuarantinedSchema = Filter< ZircuitRpcSchema, { Method: typeof ZircuitRpcMethods.GET_QUARANTINED } >[0] const quarantined = await client.request( { method: ZircuitRpcMethods.GET_QUARANTINED, params: [from], }, { dedupe: true, }, ) return quarantined.map(mapRpcQurantineToQuarantine) }