export type AddContractFunctionDto = {contractId: string, functionSignature: string, fixedFunctionParams: {[key: string]: string}, abiVersion: string}; export type CreateApiV1ContractsAddContractFunctionArgs = {body: AddContractFunctionDto}; export type CreateApiV1ContractsAddContractFunctionOptions = {baseUrl: string, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add contract function * * POST /v1/contracts/add-contract-function */ export const createApiV1ContractsAddContractFunction = async (args: CreateApiV1ContractsAddContractFunctionArgs, options: CreateApiV1ContractsAddContractFunctionOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/contracts/add-contract-function${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 };