export type SerializedTopicPost = {accept?: boolean | undefined, block?: boolean | undefined, topic?: string | undefined, peerAddress?: string | undefined, signature?: string | undefined}; export type SerializedRegistrationPost = {ownerAddress?: string | undefined, signedPublicKey?: string | undefined, registrations?: Array | undefined}; export type CreateApiXmtpTopicsBlockArgs = {body: SerializedRegistrationPost}; export type CreateApiXmtpTopicsBlockOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Block an XMTP conversation * * POST /xmtp/topics/block */ export const createApiXmtpTopicsBlock = async (args: CreateApiXmtpTopicsBlockArgs, options?: CreateApiXmtpTopicsBlockOptions) => { const {baseUrl = "https://api.unstoppabledomains.com/messaging", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/xmtp/topics/block${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };