export type MinerRaceSelectionRequest = {agent_version_id: string}; export type UpdateApiV1MinerRaceSelectionArgs = {body: MinerRaceSelectionRequest}; export type UpdateApiV1MinerRaceSelectionOptions = {baseUrl: string, SessionBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Pin agent version as race candidate * * PUT /v1/miner/race-selection * * Also accepts auth: X-Hotkey + X-Timestamp + X-Nonce + X-Signature */ export const updateApiV1MinerRaceSelection = async (args: UpdateApiV1MinerRaceSelectionArgs, options: UpdateApiV1MinerRaceSelectionOptions) => { const {baseUrl, fetch: fetchFn = fetch, SessionBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (SessionBearer !== undefined) headers.set('authorization', `Bearer ${SessionBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/miner/race-selection${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };