From b83b97e602773883eabf165bf3daf4340a296122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Bardaj=C3=AD=20Puig?= Date: Thu, 12 Sep 2024 20:45:56 +0200 Subject: [PATCH] Update args --- src/stacks-api/smart-contracts/read-only.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/stacks-api/smart-contracts/read-only.ts b/src/stacks-api/smart-contracts/read-only.ts index ac3dfb3..7dad039 100644 --- a/src/stacks-api/smart-contracts/read-only.ts +++ b/src/stacks-api/smart-contracts/read-only.ts @@ -2,13 +2,13 @@ import { error, safePromise, success, type Result } from "../../utils/safe.js"; import type { ApiRequestOptions } from "../types.js"; import * as v from "valibot"; -export type Options = { +export type Args = { sender: string; arguments: string[]; contractAddress: string; contractName: string; functionName: string; -}; +} & ApiRequestOptions; export const readOnlyResponseSchema = v.variant("okay", [ v.object({ @@ -22,19 +22,16 @@ export const readOnlyResponseSchema = v.variant("okay", [ ]); export type ReadOnlyResponse = v.InferOutput; -export async function readOnly( - opts: Options, - apiOpts: ApiRequestOptions, -): Promise> { +export async function readOnly(args: Args): Promise> { const init: RequestInit = {}; - if (apiOpts.apiKeyConfig) { + if (args.apiKeyConfig) { init.headers = { - [apiOpts.apiKeyConfig.header]: apiOpts.apiKeyConfig.key, + [args.apiKeyConfig.header]: args.apiKeyConfig.key, }; } const res = await fetch( - `${apiOpts.baseUrl}/v2/contracts/call-read/${opts.contractAddress}/${opts.contractName}/${opts.functionName}`, + `${args.baseUrl}/v2/contracts/call-read/${args.contractAddress}/${args.contractName}/${args.functionName}`, init, );