@secondlayer/stacks 5.1.1 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,7 +27,7 @@ function getContract(params) {
27
27
  const fn = fnByName.get(fnName);
28
28
  if (!fn || fn.access !== "read-only")
29
29
  return;
30
- return async (args) => {
30
+ return async (args = {}) => {
31
31
  const clarityArgs = buildFunctionArgs(fn, args);
32
32
  const result = await readContract(client, {
33
33
  contract: contractId,
@@ -51,7 +51,7 @@ function getContract(params) {
51
51
  const fn = fnByName.get(fnName);
52
52
  if (!fn || fn.access !== "public")
53
53
  return;
54
- return async (args, options) => {
54
+ return async (args = {}, options) => {
55
55
  const clarityArgs = buildFunctionArgs(fn, args);
56
56
  return callContract(client, {
57
57
  contract: contractId,
@@ -68,7 +68,7 @@ function getContract(params) {
68
68
  const fn = fnByName.get(fnName);
69
69
  if (!fn || fn.access !== "public")
70
70
  return;
71
- return async (args, options) => {
71
+ return async (args = {}, options) => {
72
72
  const publicKey = options?.publicKey ?? client.account?.publicKey;
73
73
  if (!publicKey) {
74
74
  throw new Error("buildCall requires a publicKey (pass options.publicKey or configure a client account)");
@@ -129,7 +129,7 @@ function resolveNetworkContract(client, contracts) {
129
129
  }
130
130
  return contracts[client.chain.network];
131
131
  }
132
- function buildFunctionArgs(fn, args) {
132
+ function buildFunctionArgs(fn, args = {}) {
133
133
  return fn.args.map((arg) => {
134
134
  const camelKey = toCamelCase(arg.name);
135
135
  const hasOriginal = arg.name in args;
@@ -160,5 +160,5 @@ class ContractResponseError extends Error {
160
160
  }
161
161
  }
162
162
 
163
- //# debugId=5F76A42B59F187E564756E2164756E21
164
- //# sourceMappingURL=stacks-w9t61fra.cjs.map
163
+ //# debugId=81FCE32BF632C55964756E2164756E21
164
+ //# sourceMappingURL=stacks-f35mnrmg.cjs.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/actions/getContract.ts"],
4
+ "sourcesContent": [
5
+ "import type {\n\tAbiContract,\n\tAbiFunction,\n\tAbiMap,\n\tAbiType,\n\tAbiTypesOf,\n\tContractTypes,\n\tExtractFunctionArgs,\n\tExtractFunctionOutput,\n\tExtractMapKey,\n\tExtractMapNames,\n\tExtractMapValue,\n\tExtractPublicFunctions,\n\tExtractReadOnlyFunctions,\n} from \"../clarity/abi/index.ts\";\nimport { type ToCamelCase, toCamelCase } from \"../clarity/abi/utils.ts\";\nimport {\n\tclarityValueToJSUntyped,\n\tjsToClarityValue,\n} from \"../clarity/bridge.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../postconditions/types.ts\";\nimport { buildContractCall } from \"../transactions/build.ts\";\nimport type { StacksTransaction } from \"../transactions/types.ts\";\nimport { publicKeyToAddress } from \"../utils/address.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\nimport { getMapEntry } from \"./public/getMapEntry.ts\";\nimport { getNonce } from \"./public/getNonce.ts\";\nimport { readContract } from \"./public/readContract.ts\";\nimport { callContract } from \"./wallet/callContract.ts\";\nimport { resolveFee, setUnsignedFee } from \"./wallet/utils.ts\";\n\n// --- Type helpers for unwrapping response types ---\n\n/**\n * Unwrap `(response ok err)` → just the `ok` branch type. Distributes over the\n * `{ ok } | { err }` union: the `err` branch maps to `never` (it throws\n * `ContractResponseError` at runtime, so it never reaches the caller).\n */\nexport type UnwrapResponse<T> = T extends { ok: infer O }\n\t? O\n\t: T extends { err: unknown }\n\t\t? never\n\t\t: T;\n\n/**\n * True for a structural empty mapped type (`{}`) and for codegen's\n * `Record<string, never>`. `keyof Record<string, never>` is `string`, so the\n * first check alone is not enough.\n */\ntype IsEmptyArgs<A> = [keyof A & string] extends [never]\n\t? true\n\t: Record<string, never> extends A\n\t\t? true\n\t\t: false;\n\n/** No-arg ABI functions may omit the dummy `{}`. Functions with args stay required. */\ntype ContractMethod<\n\tA,\n\tR,\n\tExtra extends unknown[] = [],\n> = IsEmptyArgs<A> extends true\n\t? (args?: A, ...extra: Extra) => R\n\t: (args: A, ...extra: Extra) => R;\n\ntype ReadMethodReturn<\n\tC extends AbiContract,\n\tN extends ExtractReadOnlyFunctions<C>,\n> = UnwrapResponse<ExtractFunctionOutput<C, N>>;\n\n// --- Public type for the contract instance ---\n\n/**\n * When the ABI carries a codegen brand (`TypedAbi`), method types resolve to\n * the generated named aliases — cleaner hovers and error messages. Un-branded\n * ABIs fall back to structural inference over the as-const literal.\n */\ntype TypedReadMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"read-only\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<UnwrapResponse<T[\"functions\"][K][\"ret\"]>>\n\t>;\n};\n\ntype TypedCallMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"public\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<string>,\n\t\t[options?: ContractCallOptions]\n\t>;\n};\n\ntype TypedMapMethods<T extends ContractTypes> = {\n\t[K in keyof NonNullable<T[\"maps\"]>]: (\n\t\tkey: NonNullable<T[\"maps\"]>[K][\"key\"],\n\t) => Promise<NonNullable<T[\"maps\"]>[K][\"value\"] | null>;\n};\n\ntype ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<ReadMethodReturn<C, N>>\n\t\t\t>;\n\t\t}\n\t: TypedReadMethods<AbiTypesOf<C>>;\n\ntype CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<string>,\n\t\t\t\t[options?: ContractCallOptions]\n\t\t\t>;\n\t\t}\n\t: TypedCallMethods<AbiTypesOf<C>>;\n\ntype MapMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractMapNames<C> as ToCamelCase<N>]: (\n\t\t\t\tkey: ExtractMapKey<C, N>,\n\t\t\t) => Promise<ExtractMapValue<C, N> | null>;\n\t\t}\n\t: TypedMapMethods<AbiTypesOf<C>>;\n\nexport type ContractCallOptions = {\n\tfee?: IntegerType;\n\tnonce?: IntegerType;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n};\n\n/**\n * Options for `buildCall.*`, building an unsigned transaction for\n * wallet-signs-later flows. `publicKey` defaults to the client account's\n * public key. When omitted, `nonce` is the confirmed on-chain nonce read\n * straight from the node (the client's nonce manager is never consumed for\n * a transaction that may never be sent) and `fee` is the mid estimate,\n * falling back to the relay floor only on `NoEstimateAvailable`.\n */\nexport type ContractBuildCallOptions = ContractCallOptions & {\n\tpublicKey?: string;\n\tsponsored?: boolean;\n};\n\ntype TypedBuildCallMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"public\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<StacksTransaction>,\n\t\t[options?: ContractBuildCallOptions]\n\t>;\n};\n\ntype BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<StacksTransaction>,\n\t\t\t\t[options?: ContractBuildCallOptions]\n\t\t\t>;\n\t\t}\n\t: TypedBuildCallMethods<AbiTypesOf<C>>;\n\nexport type ContractInstance<C extends AbiContract> = {\n\tread: ReadMethods<C>;\n\tcall: CallMethods<C>;\n\t/** Build unsigned transactions (wallet-signs-later) — never broadcasts. */\n\tbuildCall: BuildCallMethods<C>;\n\tmaps: MapMethods<C>;\n};\n\nexport type GetContractParams<C extends AbiContract> = {\n\tclient: Client;\n\taddress: string;\n\tname: string;\n\tabi: C;\n};\n\nexport function getContract<const TAbi extends AbiContract>(\n\tparams: GetContractParams<TAbi>,\n): ContractInstance<TAbi> {\n\tconst { client, address, name: contractName, abi } = params;\n\tconst contractId = `${address}.${contractName}`;\n\n\t// Index functions/maps by name for fast lookup\n\tconst fnByName = new Map<string, AbiFunction>();\n\tfor (const fn of abi.functions) {\n\t\tfnByName.set(fn.name, fn as AbiFunction);\n\t}\n\n\tconst mapByName = new Map<string, AbiMap>();\n\tif (abi.maps) {\n\t\tfor (const m of abi.maps) {\n\t\t\tmapByName.set(m.name, m as AbiMap);\n\t\t}\n\t}\n\n\t// Build kebab→camel reverse map for function/map names\n\tconst camelToKebab = new Map<string, string>();\n\tfor (const fn of abi.functions) {\n\t\tcamelToKebab.set(toCamelCase(fn.name), fn.name);\n\t}\n\tif (abi.maps) {\n\t\tfor (const m of abi.maps) {\n\t\t\tcamelToKebab.set(toCamelCase(m.name), m.name);\n\t\t}\n\t}\n\n\tconst read = new Proxy({} as ReadMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"read-only\") return undefined;\n\n\t\t\treturn async (args: Record<string, unknown> = {}) => {\n\t\t\t\tconst clarityArgs = buildFunctionArgs(fn, args);\n\t\t\t\tconst result = await readContract(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\targs: clarityArgs,\n\t\t\t\t});\n\n\t\t\t\tconst jsValue = clarityValueToJSUntyped(fn.outputs as AbiType, result);\n\n\t\t\t\t// Auto-unwrap: if output is response type, unwrap ok / throw on err\n\t\t\t\tif (isResponseOutput(fn.outputs as AbiType)) {\n\t\t\t\t\tconst resp = jsValue as { ok?: unknown; err?: unknown };\n\t\t\t\t\tif (\"ok\" in resp) return resp.ok;\n\t\t\t\t\tthrow new ContractResponseError(\n\t\t\t\t\t\t`${contractId}::${fn.name} returned (err ${formatErrValue(resp.err)})`,\n\t\t\t\t\t\tresp.err,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn jsValue;\n\t\t\t};\n\t\t},\n\t});\n\n\tconst call = new Proxy({} as CallMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"public\") return undefined;\n\n\t\t\treturn async (\n\t\t\t\targs: Record<string, unknown> = {},\n\t\t\t\toptions?: ContractCallOptions,\n\t\t\t) => {\n\t\t\t\tconst clarityArgs = buildFunctionArgs(fn, args);\n\t\t\t\treturn callContract(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\tfunctionArgs: clarityArgs,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\t\t},\n\t});\n\n\tconst buildCall = new Proxy({} as BuildCallMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"public\") return undefined;\n\n\t\t\treturn async (\n\t\t\t\targs: Record<string, unknown> = {},\n\t\t\t\toptions?: ContractBuildCallOptions,\n\t\t\t) => {\n\t\t\t\tconst publicKey = options?.publicKey ?? client.account?.publicKey;\n\t\t\t\tif (!publicKey) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"buildCall requires a publicKey (pass options.publicKey or configure a client account)\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst functionArgs = buildFunctionArgs(fn, args);\n\t\t\t\tconst network = client.chain?.network ?? \"mainnet\";\n\t\t\t\tconst nonce =\n\t\t\t\t\toptions?.nonce ??\n\t\t\t\t\t(await getNonce(client, {\n\t\t\t\t\t\taddress: publicKeyToAddress(publicKey, network),\n\t\t\t\t\t}));\n\n\t\t\t\tconst unsigned = buildContractCall({\n\t\t\t\t\tcontractAddress: address,\n\t\t\t\t\tcontractName,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\tfunctionArgs,\n\t\t\t\t\tfee: options?.fee ?? 0n,\n\t\t\t\t\tnonce,\n\t\t\t\t\tpublicKey,\n\t\t\t\t\tchain: client.chain,\n\t\t\t\t\tpostConditionMode: options?.postConditionMode,\n\t\t\t\t\tpostConditions: options?.postConditions,\n\t\t\t\t\tsponsored: options?.sponsored,\n\t\t\t\t});\n\n\t\t\t\tif (options?.fee === undefined) {\n\t\t\t\t\tconst { fee } = await resolveFee(client, unsigned, undefined);\n\t\t\t\t\tsetUnsignedFee(unsigned, fee);\n\t\t\t\t}\n\n\t\t\t\treturn unsigned;\n\t\t\t};\n\t\t},\n\t});\n\n\tconst maps = new Proxy({} as MapMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst mapName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst map = mapByName.get(mapName);\n\t\t\tif (!map) return undefined;\n\n\t\t\treturn async (key: unknown) => {\n\t\t\t\tconst clarityKey = jsToClarityValue(map.key as AbiType, key);\n\t\t\t\tconst result = await getMapEntry(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tmapName: map.name,\n\t\t\t\t\tkey: clarityKey,\n\t\t\t\t});\n\n\t\t\t\t// Map entries come back as (optional ...). If none, return null.\n\t\t\t\tif (result.type === \"none\") return null;\n\t\t\t\tif (result.type === \"some\") {\n\t\t\t\t\treturn clarityValueToJSUntyped(map.value as AbiType, result.value);\n\t\t\t\t}\n\t\t\t\t// Direct value (shouldn't normally happen, but handle gracefully)\n\t\t\t\treturn clarityValueToJSUntyped(map.value as AbiType, result);\n\t\t\t};\n\t\t},\n\t});\n\n\treturn { read, call, buildCall, maps };\n}\n\n/**\n * Resolve a network-keyed contract config for the client's chain. The contracts\n * map is keyed by network (\"mainnet\" | \"testnet\"), so selection is a direct\n * index — no per-call ternary. Throws if the client has no chain configured.\n */\nexport function resolveNetworkContract<\n\tT extends Record<\"mainnet\" | \"testnet\", { address: string }>,\n>(client: Client, contracts: T): T[\"mainnet\"] | T[\"testnet\"] {\n\tif (!client.chain) {\n\t\tthrow new Error(\"Client must have a chain configured\");\n\t}\n\treturn contracts[client.chain.network];\n}\n\n// --- Helpers ---\n\n/**\n * Encode an ABI function's named args into positional ClarityValues. Exported\n * so a caller that needs the raw ClarityValue result (to cache or re-serialize\n * it) can reuse the same encoding this module's read methods use, instead of\n * maintaining a second one that drifts.\n */\nexport function buildFunctionArgs(\n\tfn: AbiFunction,\n\targs: Record<string, unknown> = {},\n): ClarityValue[] {\n\treturn fn.args.map((arg) => {\n\t\tconst camelKey = toCamelCase(arg.name);\n\t\tconst hasOriginal = arg.name in args;\n\t\tconst hasCamel = camelKey in args;\n\t\tconst value = hasOriginal\n\t\t\t? args[arg.name]\n\t\t\t: hasCamel\n\t\t\t\t? args[camelKey]\n\t\t\t\t: undefined;\n\t\tif (value === undefined) throw new Error(`Missing argument: ${arg.name}`);\n\t\treturn jsToClarityValue(arg.type as AbiType, value);\n\t});\n}\n\n/** True when an ABI output is a `(response ok err)` and needs unwrapping. */\nexport function isResponseOutput(type: AbiType): boolean {\n\treturn typeof type === \"object\" && type !== null && \"response\" in type;\n}\n\nfunction formatErrValue(value: unknown): string {\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (typeof value === \"string\") return `\"${value}\"`;\n\treturn String(value);\n}\n\nexport class ContractResponseError extends Error {\n\toverride name = \"ContractResponseError\";\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly errorValue: unknown,\n\t) {\n\t\tsuper(message);\n\t}\n}\n"
6
+ ],
7
+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AAAA;AAQ/B,SAAS,sBAEf,CAAC,QAAgB,WAA2C;AAAA,EAC5D,IAAI,CAAC,OAAO,OAAO;AAAA,IAClB,MAAM,IAAI,MAAM,qCAAqC;AAAA,EACtD;AAAA,EACA,OAAO,UAAU,OAAO,MAAM;AAAA;AAWxB,SAAS,iBAAiB,CAChC,IACA,OAAgC,CAAC,GAChB;AAAA,EACjB,OAAO,GAAG,KAAK,IAAI,CAAC,QAAQ;AAAA,IAC3B,MAAM,WAAW,YAAY,IAAI,IAAI;AAAA,IACrC,MAAM,cAAc,IAAI,QAAQ;AAAA,IAChC,MAAM,WAAW,YAAY;AAAA,IAC7B,MAAM,QAAQ,cACX,KAAK,IAAI,QACT,WACC,KAAK,YACL;AAAA,IACJ,IAAI,UAAU;AAAA,MAAW,MAAM,IAAI,MAAM,qBAAqB,IAAI,MAAM;AAAA,IACxE,OAAO,iBAAiB,IAAI,MAAiB,KAAK;AAAA,GAClD;AAAA;AAIK,SAAS,gBAAgB,CAAC,MAAwB;AAAA,EACxD,OAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,cAAc;AAAA;AAGnE,SAAS,cAAc,CAAC,OAAwB;AAAA,EAC/C,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,MAAM,SAAS;AAAA,EACrD,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,IAAI;AAAA,EAC1C,OAAO,OAAO,KAAK;AAAA;AAAA;AAGb,MAAM,8BAA8B,MAAM;AAAA,EAI/B;AAAA,EAHR,OAAO;AAAA,EAChB,WAAW,CACV,SACgB,YACf;AAAA,IACD,MAAM,OAAO;AAAA,IAFG;AAAA;AAIlB;",
8
+ "debugId": "81FCE32BF632C55964756E2164756E21",
9
+ "names": []
10
+ }
@@ -49,7 +49,7 @@ function getContract(params) {
49
49
  const fn = fnByName.get(fnName);
50
50
  if (!fn || fn.access !== "read-only")
51
51
  return;
52
- return async (args) => {
52
+ return async (args = {}) => {
53
53
  const clarityArgs = buildFunctionArgs(fn, args);
54
54
  const result = await readContract(client, {
55
55
  contract: contractId,
@@ -73,7 +73,7 @@ function getContract(params) {
73
73
  const fn = fnByName.get(fnName);
74
74
  if (!fn || fn.access !== "public")
75
75
  return;
76
- return async (args, options) => {
76
+ return async (args = {}, options) => {
77
77
  const clarityArgs = buildFunctionArgs(fn, args);
78
78
  return callContract(client, {
79
79
  contract: contractId,
@@ -90,7 +90,7 @@ function getContract(params) {
90
90
  const fn = fnByName.get(fnName);
91
91
  if (!fn || fn.access !== "public")
92
92
  return;
93
- return async (args, options) => {
93
+ return async (args = {}, options) => {
94
94
  const publicKey = options?.publicKey ?? client.account?.publicKey;
95
95
  if (!publicKey) {
96
96
  throw new Error("buildCall requires a publicKey (pass options.publicKey or configure a client account)");
@@ -151,7 +151,7 @@ function resolveNetworkContract(client, contracts) {
151
151
  }
152
152
  return contracts[client.chain.network];
153
153
  }
154
- function buildFunctionArgs(fn, args) {
154
+ function buildFunctionArgs(fn, args = {}) {
155
155
  return fn.args.map((arg) => {
156
156
  const camelKey = toCamelCase(arg.name);
157
157
  const hasOriginal = arg.name in args;
@@ -184,5 +184,5 @@ class ContractResponseError extends Error {
184
184
 
185
185
  export { getContract, resolveNetworkContract, buildFunctionArgs, isResponseOutput, ContractResponseError };
186
186
 
187
- //# debugId=68BE202E22097C6C64756E2164756E21
188
- //# sourceMappingURL=stacks-gyp5ax89.js.map
187
+ //# debugId=AAFF67F8FCC109A664756E2164756E21
188
+ //# sourceMappingURL=stacks-fd4rx56e.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/actions/getContract.ts"],
4
+ "sourcesContent": [
5
+ "import type {\n\tAbiContract,\n\tAbiFunction,\n\tAbiMap,\n\tAbiType,\n\tAbiTypesOf,\n\tContractTypes,\n\tExtractFunctionArgs,\n\tExtractFunctionOutput,\n\tExtractMapKey,\n\tExtractMapNames,\n\tExtractMapValue,\n\tExtractPublicFunctions,\n\tExtractReadOnlyFunctions,\n} from \"../clarity/abi/index.ts\";\nimport { type ToCamelCase, toCamelCase } from \"../clarity/abi/utils.ts\";\nimport {\n\tclarityValueToJSUntyped,\n\tjsToClarityValue,\n} from \"../clarity/bridge.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../postconditions/types.ts\";\nimport { buildContractCall } from \"../transactions/build.ts\";\nimport type { StacksTransaction } from \"../transactions/types.ts\";\nimport { publicKeyToAddress } from \"../utils/address.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\nimport { getMapEntry } from \"./public/getMapEntry.ts\";\nimport { getNonce } from \"./public/getNonce.ts\";\nimport { readContract } from \"./public/readContract.ts\";\nimport { callContract } from \"./wallet/callContract.ts\";\nimport { resolveFee, setUnsignedFee } from \"./wallet/utils.ts\";\n\n// --- Type helpers for unwrapping response types ---\n\n/**\n * Unwrap `(response ok err)` → just the `ok` branch type. Distributes over the\n * `{ ok } | { err }` union: the `err` branch maps to `never` (it throws\n * `ContractResponseError` at runtime, so it never reaches the caller).\n */\nexport type UnwrapResponse<T> = T extends { ok: infer O }\n\t? O\n\t: T extends { err: unknown }\n\t\t? never\n\t\t: T;\n\n/**\n * True for a structural empty mapped type (`{}`) and for codegen's\n * `Record<string, never>`. `keyof Record<string, never>` is `string`, so the\n * first check alone is not enough.\n */\ntype IsEmptyArgs<A> = [keyof A & string] extends [never]\n\t? true\n\t: Record<string, never> extends A\n\t\t? true\n\t\t: false;\n\n/** No-arg ABI functions may omit the dummy `{}`. Functions with args stay required. */\ntype ContractMethod<\n\tA,\n\tR,\n\tExtra extends unknown[] = [],\n> = IsEmptyArgs<A> extends true\n\t? (args?: A, ...extra: Extra) => R\n\t: (args: A, ...extra: Extra) => R;\n\ntype ReadMethodReturn<\n\tC extends AbiContract,\n\tN extends ExtractReadOnlyFunctions<C>,\n> = UnwrapResponse<ExtractFunctionOutput<C, N>>;\n\n// --- Public type for the contract instance ---\n\n/**\n * When the ABI carries a codegen brand (`TypedAbi`), method types resolve to\n * the generated named aliases — cleaner hovers and error messages. Un-branded\n * ABIs fall back to structural inference over the as-const literal.\n */\ntype TypedReadMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"read-only\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<UnwrapResponse<T[\"functions\"][K][\"ret\"]>>\n\t>;\n};\n\ntype TypedCallMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"public\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<string>,\n\t\t[options?: ContractCallOptions]\n\t>;\n};\n\ntype TypedMapMethods<T extends ContractTypes> = {\n\t[K in keyof NonNullable<T[\"maps\"]>]: (\n\t\tkey: NonNullable<T[\"maps\"]>[K][\"key\"],\n\t) => Promise<NonNullable<T[\"maps\"]>[K][\"value\"] | null>;\n};\n\ntype ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<ReadMethodReturn<C, N>>\n\t\t\t>;\n\t\t}\n\t: TypedReadMethods<AbiTypesOf<C>>;\n\ntype CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<string>,\n\t\t\t\t[options?: ContractCallOptions]\n\t\t\t>;\n\t\t}\n\t: TypedCallMethods<AbiTypesOf<C>>;\n\ntype MapMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractMapNames<C> as ToCamelCase<N>]: (\n\t\t\t\tkey: ExtractMapKey<C, N>,\n\t\t\t) => Promise<ExtractMapValue<C, N> | null>;\n\t\t}\n\t: TypedMapMethods<AbiTypesOf<C>>;\n\nexport type ContractCallOptions = {\n\tfee?: IntegerType;\n\tnonce?: IntegerType;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n};\n\n/**\n * Options for `buildCall.*`, building an unsigned transaction for\n * wallet-signs-later flows. `publicKey` defaults to the client account's\n * public key. When omitted, `nonce` is the confirmed on-chain nonce read\n * straight from the node (the client's nonce manager is never consumed for\n * a transaction that may never be sent) and `fee` is the mid estimate,\n * falling back to the relay floor only on `NoEstimateAvailable`.\n */\nexport type ContractBuildCallOptions = ContractCallOptions & {\n\tpublicKey?: string;\n\tsponsored?: boolean;\n};\n\ntype TypedBuildCallMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"public\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<StacksTransaction>,\n\t\t[options?: ContractBuildCallOptions]\n\t>;\n};\n\ntype BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<StacksTransaction>,\n\t\t\t\t[options?: ContractBuildCallOptions]\n\t\t\t>;\n\t\t}\n\t: TypedBuildCallMethods<AbiTypesOf<C>>;\n\nexport type ContractInstance<C extends AbiContract> = {\n\tread: ReadMethods<C>;\n\tcall: CallMethods<C>;\n\t/** Build unsigned transactions (wallet-signs-later) — never broadcasts. */\n\tbuildCall: BuildCallMethods<C>;\n\tmaps: MapMethods<C>;\n};\n\nexport type GetContractParams<C extends AbiContract> = {\n\tclient: Client;\n\taddress: string;\n\tname: string;\n\tabi: C;\n};\n\nexport function getContract<const TAbi extends AbiContract>(\n\tparams: GetContractParams<TAbi>,\n): ContractInstance<TAbi> {\n\tconst { client, address, name: contractName, abi } = params;\n\tconst contractId = `${address}.${contractName}`;\n\n\t// Index functions/maps by name for fast lookup\n\tconst fnByName = new Map<string, AbiFunction>();\n\tfor (const fn of abi.functions) {\n\t\tfnByName.set(fn.name, fn as AbiFunction);\n\t}\n\n\tconst mapByName = new Map<string, AbiMap>();\n\tif (abi.maps) {\n\t\tfor (const m of abi.maps) {\n\t\t\tmapByName.set(m.name, m as AbiMap);\n\t\t}\n\t}\n\n\t// Build kebab→camel reverse map for function/map names\n\tconst camelToKebab = new Map<string, string>();\n\tfor (const fn of abi.functions) {\n\t\tcamelToKebab.set(toCamelCase(fn.name), fn.name);\n\t}\n\tif (abi.maps) {\n\t\tfor (const m of abi.maps) {\n\t\t\tcamelToKebab.set(toCamelCase(m.name), m.name);\n\t\t}\n\t}\n\n\tconst read = new Proxy({} as ReadMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"read-only\") return undefined;\n\n\t\t\treturn async (args: Record<string, unknown> = {}) => {\n\t\t\t\tconst clarityArgs = buildFunctionArgs(fn, args);\n\t\t\t\tconst result = await readContract(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\targs: clarityArgs,\n\t\t\t\t});\n\n\t\t\t\tconst jsValue = clarityValueToJSUntyped(fn.outputs as AbiType, result);\n\n\t\t\t\t// Auto-unwrap: if output is response type, unwrap ok / throw on err\n\t\t\t\tif (isResponseOutput(fn.outputs as AbiType)) {\n\t\t\t\t\tconst resp = jsValue as { ok?: unknown; err?: unknown };\n\t\t\t\t\tif (\"ok\" in resp) return resp.ok;\n\t\t\t\t\tthrow new ContractResponseError(\n\t\t\t\t\t\t`${contractId}::${fn.name} returned (err ${formatErrValue(resp.err)})`,\n\t\t\t\t\t\tresp.err,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn jsValue;\n\t\t\t};\n\t\t},\n\t});\n\n\tconst call = new Proxy({} as CallMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"public\") return undefined;\n\n\t\t\treturn async (\n\t\t\t\targs: Record<string, unknown> = {},\n\t\t\t\toptions?: ContractCallOptions,\n\t\t\t) => {\n\t\t\t\tconst clarityArgs = buildFunctionArgs(fn, args);\n\t\t\t\treturn callContract(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\tfunctionArgs: clarityArgs,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\t\t},\n\t});\n\n\tconst buildCall = new Proxy({} as BuildCallMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"public\") return undefined;\n\n\t\t\treturn async (\n\t\t\t\targs: Record<string, unknown> = {},\n\t\t\t\toptions?: ContractBuildCallOptions,\n\t\t\t) => {\n\t\t\t\tconst publicKey = options?.publicKey ?? client.account?.publicKey;\n\t\t\t\tif (!publicKey) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"buildCall requires a publicKey (pass options.publicKey or configure a client account)\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst functionArgs = buildFunctionArgs(fn, args);\n\t\t\t\tconst network = client.chain?.network ?? \"mainnet\";\n\t\t\t\tconst nonce =\n\t\t\t\t\toptions?.nonce ??\n\t\t\t\t\t(await getNonce(client, {\n\t\t\t\t\t\taddress: publicKeyToAddress(publicKey, network),\n\t\t\t\t\t}));\n\n\t\t\t\tconst unsigned = buildContractCall({\n\t\t\t\t\tcontractAddress: address,\n\t\t\t\t\tcontractName,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\tfunctionArgs,\n\t\t\t\t\tfee: options?.fee ?? 0n,\n\t\t\t\t\tnonce,\n\t\t\t\t\tpublicKey,\n\t\t\t\t\tchain: client.chain,\n\t\t\t\t\tpostConditionMode: options?.postConditionMode,\n\t\t\t\t\tpostConditions: options?.postConditions,\n\t\t\t\t\tsponsored: options?.sponsored,\n\t\t\t\t});\n\n\t\t\t\tif (options?.fee === undefined) {\n\t\t\t\t\tconst { fee } = await resolveFee(client, unsigned, undefined);\n\t\t\t\t\tsetUnsignedFee(unsigned, fee);\n\t\t\t\t}\n\n\t\t\t\treturn unsigned;\n\t\t\t};\n\t\t},\n\t});\n\n\tconst maps = new Proxy({} as MapMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst mapName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst map = mapByName.get(mapName);\n\t\t\tif (!map) return undefined;\n\n\t\t\treturn async (key: unknown) => {\n\t\t\t\tconst clarityKey = jsToClarityValue(map.key as AbiType, key);\n\t\t\t\tconst result = await getMapEntry(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tmapName: map.name,\n\t\t\t\t\tkey: clarityKey,\n\t\t\t\t});\n\n\t\t\t\t// Map entries come back as (optional ...). If none, return null.\n\t\t\t\tif (result.type === \"none\") return null;\n\t\t\t\tif (result.type === \"some\") {\n\t\t\t\t\treturn clarityValueToJSUntyped(map.value as AbiType, result.value);\n\t\t\t\t}\n\t\t\t\t// Direct value (shouldn't normally happen, but handle gracefully)\n\t\t\t\treturn clarityValueToJSUntyped(map.value as AbiType, result);\n\t\t\t};\n\t\t},\n\t});\n\n\treturn { read, call, buildCall, maps };\n}\n\n/**\n * Resolve a network-keyed contract config for the client's chain. The contracts\n * map is keyed by network (\"mainnet\" | \"testnet\"), so selection is a direct\n * index — no per-call ternary. Throws if the client has no chain configured.\n */\nexport function resolveNetworkContract<\n\tT extends Record<\"mainnet\" | \"testnet\", { address: string }>,\n>(client: Client, contracts: T): T[\"mainnet\"] | T[\"testnet\"] {\n\tif (!client.chain) {\n\t\tthrow new Error(\"Client must have a chain configured\");\n\t}\n\treturn contracts[client.chain.network];\n}\n\n// --- Helpers ---\n\n/**\n * Encode an ABI function's named args into positional ClarityValues. Exported\n * so a caller that needs the raw ClarityValue result (to cache or re-serialize\n * it) can reuse the same encoding this module's read methods use, instead of\n * maintaining a second one that drifts.\n */\nexport function buildFunctionArgs(\n\tfn: AbiFunction,\n\targs: Record<string, unknown> = {},\n): ClarityValue[] {\n\treturn fn.args.map((arg) => {\n\t\tconst camelKey = toCamelCase(arg.name);\n\t\tconst hasOriginal = arg.name in args;\n\t\tconst hasCamel = camelKey in args;\n\t\tconst value = hasOriginal\n\t\t\t? args[arg.name]\n\t\t\t: hasCamel\n\t\t\t\t? args[camelKey]\n\t\t\t\t: undefined;\n\t\tif (value === undefined) throw new Error(`Missing argument: ${arg.name}`);\n\t\treturn jsToClarityValue(arg.type as AbiType, value);\n\t});\n}\n\n/** True when an ABI output is a `(response ok err)` and needs unwrapping. */\nexport function isResponseOutput(type: AbiType): boolean {\n\treturn typeof type === \"object\" && type !== null && \"response\" in type;\n}\n\nfunction formatErrValue(value: unknown): string {\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (typeof value === \"string\") return `\"${value}\"`;\n\treturn String(value);\n}\n\nexport class ContractResponseError extends Error {\n\toverride name = \"ContractResponseError\";\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly errorValue: unknown,\n\t) {\n\t\tsuper(message);\n\t}\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AA4LO,SAAS,WAA2C,CAC1D,QACyB;AAAA,EACzB,QAAQ,QAAQ,SAAS,MAAM,cAAc,QAAQ;AAAA,EACrD,MAAM,aAAa,GAAG,WAAW;AAAA,EAGjC,MAAM,WAAW,IAAI;AAAA,EACrB,WAAW,MAAM,IAAI,WAAW;A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CAChC,IACA,OAAgC,CAAC,GAChB;AAAA,EACjB,OAAO,GAAG,KAAK,IAAI,CAAC,QAAQ;AAAA,IAC3B,MAAM,WAAW,YAAY,IAAI,IAAI;AAAA,IACrC,MAAM,cAAc,IAAI,QAAQ;AAAA,IAChC,MAAM,WAAW,YAAY;AAAA,IAC7B,MAAM,QAAQ,cACX,KAAK,IAAI,QACT,WACC,KAAK,YACL;AAAA,IACJ,IAAI,UAAU;AAAA,MAAW,MAAM,IAAI,MAAM,qBAAqB,IAAI,MAAM;AAAA,IACxE,OAAO,iBAAiB,IAAI,MAAiB,KAAK;AAAA,GAClD;AAAA;AAIK,SAAS,gBAAgB,CAAC,MAAwB;AAAA,EACxD,OAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,cAAc;AAAA;AAGnE,SAAS,cAAc,CAAC,OAAwB;AAAA,EAC/C,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,MAAM,SAAS;AAAA,EACrD,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,IAAI;AAAA,EAC1C,OAAO,OAAO,KAAK;AAAA;AAAA;AAGb,MAAM,8BAA8B,MAAM;AAAA,EAI/B;AAAA,EAHR,OAAO;AAAA,EAChB,WAAW,CACV,SACgB,YACf;AAAA,IACD,MAAM,OAAO;AAAA,IAFG;AAAA;AAIlB;",
8
+ "debugId": "AAFF67F8FCC109A664756E2164756E21",
9
+ "names": []
10
+ }
@@ -1286,6 +1286,18 @@ type UnwrapResponse<T> = T extends {
1286
1286
  } ? O : T extends {
1287
1287
  err: unknown
1288
1288
  } ? never : T;
1289
+ /**
1290
+ * True for a structural empty mapped type (`{}`) and for codegen's
1291
+ * `Record<string, never>`. `keyof Record<string, never>` is `string`, so the
1292
+ * first check alone is not enough.
1293
+ */
1294
+ type IsEmptyArgs<A> = [keyof A & string] extends [never] ? true : Record<string, never> extends A ? true : false;
1295
+ /** No-arg ABI functions may omit the dummy `{}`. Functions with args stay required. */
1296
+ type ContractMethod<
1297
+ A,
1298
+ R,
1299
+ Extra extends unknown[] = []
1300
+ > = IsEmptyArgs<A> extends true ? (args?: A, ...extra: Extra) => R : (args: A, ...extra: Extra) => R;
1289
1301
  type ReadMethodReturn<
1290
1302
  C extends AbiContract,
1291
1303
  N extends ExtractReadOnlyFunctions<C>
@@ -1295,11 +1307,11 @@ type ReadMethodReturn<
1295
1307
  * the generated named aliases — cleaner hovers and error messages. Un-branded
1296
1308
  * ABIs fall back to structural inference over the as-const literal.
1297
1309
  */
1298
- type TypedReadMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "read-only" ? K : never] : (args: T["functions"][K]["args"]) => Promise<UnwrapResponse<T["functions"][K]["ret"]>> };
1299
- type TypedCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : (args: T["functions"][K]["args"], options?: ContractCallOptions) => Promise<string> };
1310
+ type TypedReadMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "read-only" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<UnwrapResponse<T["functions"][K]["ret"]>>> };
1311
+ type TypedCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<string>, [options?: ContractCallOptions]> };
1300
1312
  type TypedMapMethods<T extends ContractTypes> = { [K in keyof NonNullable<T["maps"]>] : (key: NonNullable<T["maps"]>[K]["key"]) => Promise<NonNullable<T["maps"]>[K]["value"] | null> };
1301
- type ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>) => Promise<ReadMethodReturn<C, N>> } : TypedReadMethods<AbiTypesOf<C>>;
1302
- type CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractCallOptions) => Promise<string> } : TypedCallMethods<AbiTypesOf<C>>;
1313
+ type ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<ReadMethodReturn<C, N>>> } : TypedReadMethods<AbiTypesOf<C>>;
1314
+ type CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<string>, [options?: ContractCallOptions]> } : TypedCallMethods<AbiTypesOf<C>>;
1303
1315
  type MapMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractMapNames<C> as ToCamelCase<N>] : (key: ExtractMapKey<C, N>) => Promise<ExtractMapValue<C, N> | null> } : TypedMapMethods<AbiTypesOf<C>>;
1304
1316
  type ContractCallOptions = {
1305
1317
  fee?: IntegerType
@@ -1319,8 +1331,8 @@ type ContractBuildCallOptions = ContractCallOptions & {
1319
1331
  publicKey?: string
1320
1332
  sponsored?: boolean
1321
1333
  };
1322
- type TypedBuildCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : (args: T["functions"][K]["args"], options?: ContractBuildCallOptions) => Promise<StacksTransaction> };
1323
- type BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractBuildCallOptions) => Promise<StacksTransaction> } : TypedBuildCallMethods<AbiTypesOf<C>>;
1334
+ type TypedBuildCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<StacksTransaction>, [options?: ContractBuildCallOptions]> };
1335
+ type BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<StacksTransaction>, [options?: ContractBuildCallOptions]> } : TypedBuildCallMethods<AbiTypesOf<C>>;
1324
1336
  type ContractInstance<C extends AbiContract> = {
1325
1337
  read: ReadMethods<C>
1326
1338
  call: CallMethods<C>
@@ -1341,7 +1353,7 @@ declare function getContract<const TAbi extends AbiContract>(params: GetContract
1341
1353
  * it) can reuse the same encoding this module's read methods use, instead of
1342
1354
  * maintaining a second one that drifts.
1343
1355
  */
1344
- declare function buildFunctionArgs(fn: AbiFunction, args: Record<string, unknown>): ClarityValue[];
1356
+ declare function buildFunctionArgs(fn: AbiFunction, args?: Record<string, unknown>): ClarityValue[];
1345
1357
  /** True when an ABI output is a `(response ok err)` and needs unwrapping. */
1346
1358
  declare function isResponseOutput(type: AbiType): boolean;
1347
1359
  declare class ContractResponseError extends Error {
@@ -1286,6 +1286,18 @@ type UnwrapResponse<T> = T extends {
1286
1286
  } ? O : T extends {
1287
1287
  err: unknown
1288
1288
  } ? never : T;
1289
+ /**
1290
+ * True for a structural empty mapped type (`{}`) and for codegen's
1291
+ * `Record<string, never>`. `keyof Record<string, never>` is `string`, so the
1292
+ * first check alone is not enough.
1293
+ */
1294
+ type IsEmptyArgs<A> = [keyof A & string] extends [never] ? true : Record<string, never> extends A ? true : false;
1295
+ /** No-arg ABI functions may omit the dummy `{}`. Functions with args stay required. */
1296
+ type ContractMethod<
1297
+ A,
1298
+ R,
1299
+ Extra extends unknown[] = []
1300
+ > = IsEmptyArgs<A> extends true ? (args?: A, ...extra: Extra) => R : (args: A, ...extra: Extra) => R;
1289
1301
  type ReadMethodReturn<
1290
1302
  C extends AbiContract,
1291
1303
  N extends ExtractReadOnlyFunctions<C>
@@ -1295,11 +1307,11 @@ type ReadMethodReturn<
1295
1307
  * the generated named aliases — cleaner hovers and error messages. Un-branded
1296
1308
  * ABIs fall back to structural inference over the as-const literal.
1297
1309
  */
1298
- type TypedReadMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "read-only" ? K : never] : (args: T["functions"][K]["args"]) => Promise<UnwrapResponse<T["functions"][K]["ret"]>> };
1299
- type TypedCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : (args: T["functions"][K]["args"], options?: ContractCallOptions) => Promise<string> };
1310
+ type TypedReadMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "read-only" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<UnwrapResponse<T["functions"][K]["ret"]>>> };
1311
+ type TypedCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<string>, [options?: ContractCallOptions]> };
1300
1312
  type TypedMapMethods<T extends ContractTypes> = { [K in keyof NonNullable<T["maps"]>] : (key: NonNullable<T["maps"]>[K]["key"]) => Promise<NonNullable<T["maps"]>[K]["value"] | null> };
1301
- type ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>) => Promise<ReadMethodReturn<C, N>> } : TypedReadMethods<AbiTypesOf<C>>;
1302
- type CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractCallOptions) => Promise<string> } : TypedCallMethods<AbiTypesOf<C>>;
1313
+ type ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<ReadMethodReturn<C, N>>> } : TypedReadMethods<AbiTypesOf<C>>;
1314
+ type CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<string>, [options?: ContractCallOptions]> } : TypedCallMethods<AbiTypesOf<C>>;
1303
1315
  type MapMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractMapNames<C> as ToCamelCase<N>] : (key: ExtractMapKey<C, N>) => Promise<ExtractMapValue<C, N> | null> } : TypedMapMethods<AbiTypesOf<C>>;
1304
1316
  type ContractCallOptions = {
1305
1317
  fee?: IntegerType
@@ -1319,8 +1331,8 @@ type ContractBuildCallOptions = ContractCallOptions & {
1319
1331
  publicKey?: string
1320
1332
  sponsored?: boolean
1321
1333
  };
1322
- type TypedBuildCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : (args: T["functions"][K]["args"], options?: ContractBuildCallOptions) => Promise<StacksTransaction> };
1323
- type BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractBuildCallOptions) => Promise<StacksTransaction> } : TypedBuildCallMethods<AbiTypesOf<C>>;
1334
+ type TypedBuildCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : ContractMethod<T["functions"][K]["args"], Promise<StacksTransaction>, [options?: ContractBuildCallOptions]> };
1335
+ type BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : ContractMethod<ExtractFunctionArgs<C, N>, Promise<StacksTransaction>, [options?: ContractBuildCallOptions]> } : TypedBuildCallMethods<AbiTypesOf<C>>;
1324
1336
  type ContractInstance<C extends AbiContract> = {
1325
1337
  read: ReadMethods<C>
1326
1338
  call: CallMethods<C>
@@ -1341,7 +1353,7 @@ declare function getContract<const TAbi extends AbiContract>(params: GetContract
1341
1353
  * it) can reuse the same encoding this module's read methods use, instead of
1342
1354
  * maintaining a second one that drifts.
1343
1355
  */
1344
- declare function buildFunctionArgs(fn: AbiFunction, args: Record<string, unknown>): ClarityValue[];
1356
+ declare function buildFunctionArgs(fn: AbiFunction, args?: Record<string, unknown>): ClarityValue[];
1345
1357
  /** True when an ABI output is a `(response ok err)` and needs unwrapping. */
1346
1358
  declare function isResponseOutput(type: AbiType): boolean;
1347
1359
  declare class ContractResponseError extends Error {
@@ -3,7 +3,7 @@ import {
3
3
  buildFunctionArgs,
4
4
  getContract,
5
5
  isResponseOutput
6
- } from "../../shared/stacks-gyp5ax89.js";
6
+ } from "../../shared/stacks-fd4rx56e.js";
7
7
  import {
8
8
  deployContract,
9
9
  getAccountHistory,
@@ -4,7 +4,7 @@ import {
4
4
  ContractResponseError,
5
5
  getContract,
6
6
  resolveNetworkContract
7
- } from "../../shared/stacks-gyp5ax89.js";
7
+ } from "../../shared/stacks-fd4rx56e.js";
8
8
  import"../../shared/stacks-v03zef3g.js";
9
9
  import"../../shared/stacks-qex691bh.js";
10
10
  import"../../shared/stacks-x0qqwrev.js";
@@ -9,7 +9,7 @@ import"../../shared/stacks-z90xdr1x.js";
9
9
  import {
10
10
  getContract,
11
11
  resolveNetworkContract
12
- } from "../../shared/stacks-gyp5ax89.js";
12
+ } from "../../shared/stacks-fd4rx56e.js";
13
13
  import"../../shared/stacks-v03zef3g.js";
14
14
  import"../../shared/stacks-qex691bh.js";
15
15
  import"../../shared/stacks-x0qqwrev.js";
@@ -15,7 +15,7 @@ import {
15
15
  } from "../../shared/stacks-z90xdr1x.js";
16
16
  import {
17
17
  getContract
18
- } from "../../shared/stacks-gyp5ax89.js";
18
+ } from "../../shared/stacks-fd4rx56e.js";
19
19
  import {
20
20
  getBalance,
21
21
  getDataVar,
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  getContract,
9
9
  resolveNetworkContract
10
- } from "../../shared/stacks-gyp5ax89.js";
10
+ } from "../../shared/stacks-fd4rx56e.js";
11
11
  import"../../shared/stacks-v03zef3g.js";
12
12
  import"../../shared/stacks-qex691bh.js";
13
13
  import"../../shared/stacks-x0qqwrev.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../shared/stacks-kg1npstf.js";
4
4
  import {
5
5
  getContract
6
- } from "../../shared/stacks-gyp5ax89.js";
6
+ } from "../../shared/stacks-fd4rx56e.js";
7
7
  import"../../shared/stacks-v03zef3g.js";
8
8
  import"../../shared/stacks-qex691bh.js";
9
9
  import"../../shared/stacks-x0qqwrev.js";
@@ -2563,7 +2563,7 @@ function getContract(params) {
2563
2563
  const fn = fnByName.get(fnName);
2564
2564
  if (!fn || fn.access !== "read-only")
2565
2565
  return;
2566
- return async (args) => {
2566
+ return async (args = {}) => {
2567
2567
  const clarityArgs = buildFunctionArgs(fn, args);
2568
2568
  const result = await readContract(client, {
2569
2569
  contract: contractId,
@@ -2587,7 +2587,7 @@ function getContract(params) {
2587
2587
  const fn = fnByName.get(fnName);
2588
2588
  if (!fn || fn.access !== "public")
2589
2589
  return;
2590
- return async (args, options) => {
2590
+ return async (args = {}, options) => {
2591
2591
  const clarityArgs = buildFunctionArgs(fn, args);
2592
2592
  return callContract(client, {
2593
2593
  contract: contractId,
@@ -2604,7 +2604,7 @@ function getContract(params) {
2604
2604
  const fn = fnByName.get(fnName);
2605
2605
  if (!fn || fn.access !== "public")
2606
2606
  return;
2607
- return async (args, options) => {
2607
+ return async (args = {}, options) => {
2608
2608
  const publicKey = options?.publicKey ?? client.account?.publicKey;
2609
2609
  if (!publicKey) {
2610
2610
  throw new Error("buildCall requires a publicKey (pass options.publicKey or configure a client account)");
@@ -2665,7 +2665,7 @@ function resolveNetworkContract(client, contracts) {
2665
2665
  }
2666
2666
  return contracts[client.chain.network];
2667
2667
  }
2668
- function buildFunctionArgs(fn, args) {
2668
+ function buildFunctionArgs(fn, args = {}) {
2669
2669
  return fn.args.map((arg) => {
2670
2670
  const camelKey = toCamelCase(arg.name);
2671
2671
  const hasOriginal = arg.name in args;
@@ -3861,5 +3861,5 @@ var getAccountHistory2 = defaultTools.getAccountHistory;
3861
3861
  var getMempoolStats2 = defaultTools.getMempoolStats;
3862
3862
  var getNftHoldings2 = defaultTools.getNftHoldings;
3863
3863
 
3864
- //# debugId=24BD4E2DF5A24D8B64756E2164756E21
3864
+ //# debugId=DE29EDB00BA8B07A64756E2164756E21
3865
3865
  //# sourceMappingURL=index.cjs.map