@secondlayer/stacks 2.9.1 → 2.11.0
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.
- package/dist/shared/{stacks-wyxj879g.cjs → stacks-18jv9aen.js} +83 -4
- package/dist/shared/stacks-18jv9aen.js.map +13 -0
- package/dist/shared/{stacks-0zysn74p.js → stacks-2mm20wqf.js} +3 -3
- package/dist/shared/{stacks-1qmx9kt8.js → stacks-3kmj5yre.js} +4 -4
- package/dist/shared/{stacks-ttbq8emk.js → stacks-502j0efj.js} +3 -3
- package/dist/shared/{stacks-nqae5amn.cjs → stacks-5nskdw7w.cjs} +19 -2
- package/dist/shared/stacks-5nskdw7w.cjs.map +10 -0
- package/dist/shared/{stacks-8mj5jw77.js → stacks-63xbc6cj.js} +63 -7
- package/dist/shared/stacks-63xbc6cj.js.map +10 -0
- package/dist/shared/{stacks-g7ffp8aj.js → stacks-6xt8py97.cjs} +59 -30
- package/dist/shared/stacks-6xt8py97.cjs.map +13 -0
- package/dist/shared/{stacks-53bjdb6p.js → stacks-7nvbv61d.js} +8 -8
- package/dist/shared/stacks-azp00pve.js +70 -0
- package/dist/shared/stacks-azp00pve.js.map +11 -0
- package/dist/shared/{stacks-vk8fwz0t.cjs → stacks-b9904rc2.cjs} +3 -2
- package/dist/shared/{stacks-vk8fwz0t.cjs.map → stacks-b9904rc2.cjs.map} +2 -2
- package/dist/shared/{stacks-3y058qda.cjs → stacks-fhzwsn5d.cjs} +16 -2
- package/dist/shared/{stacks-3y058qda.cjs.map → stacks-fhzwsn5d.cjs.map} +5 -4
- package/dist/shared/{stacks-wqgepfab.js → stacks-g11v9a35.js} +22 -5
- package/dist/shared/stacks-g11v9a35.js.map +10 -0
- package/dist/shared/{stacks-6xmk24yw.js → stacks-gfm3r397.cjs} +20 -7
- package/dist/shared/stacks-gfm3r397.cjs.map +11 -0
- package/dist/shared/{stacks-43cxvnr7.js → stacks-jbmcwky5.js} +3 -3
- package/dist/shared/{stacks-q1mjkt15.js → stacks-msmgyerb.js} +4 -4
- package/dist/shared/{stacks-2h8d2y27.js → stacks-qs5fzts5.js} +17 -3
- package/dist/shared/{stacks-2h8d2y27.js.map → stacks-qs5fzts5.js.map} +5 -4
- package/dist/shared/{stacks-vdfag81a.cjs → stacks-shn9zw99.cjs} +49 -3
- package/dist/shared/stacks-shn9zw99.cjs.map +10 -0
- package/dist/shared/{stacks-4trgpb5a.js → stacks-ssndnbbd.js} +48 -13
- package/dist/shared/stacks-ssndnbbd.js.map +15 -0
- package/dist/shared/{stacks-z1j5d6fd.js → stacks-v150hffx.js} +6 -6
- package/dist/shared/{stacks-ertyhttt.cjs → stacks-wamwv8q8.cjs} +41 -4
- package/dist/shared/stacks-wamwv8q8.cjs.map +15 -0
- package/dist/shared/{stacks-a36n7sjz.js → stacks-x94a1d6s.js} +3 -3
- package/dist/src/accounts/index.js +3 -5
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.d.cts +91 -10
- package/dist/src/actions/index.d.ts +91 -10
- package/dist/src/actions/index.js +13 -15
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.cjs +25 -19
- package/dist/src/bitcoin/index.cjs.map +3 -3
- package/dist/src/bitcoin/index.js +32 -29
- package/dist/src/bitcoin/index.js.map +3 -3
- package/dist/src/bns/index.cjs +4 -16
- package/dist/src/bns/index.cjs.map +3 -3
- package/dist/src/bns/index.js +17 -30
- package/dist/src/bns/index.js.map +3 -3
- package/dist/src/clarity/index.d.cts +50 -1
- package/dist/src/clarity/index.d.ts +50 -1
- package/dist/src/clarity/index.js +8 -7
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/index.d.cts +32 -2
- package/dist/src/index.d.ts +32 -2
- package/dist/src/index.js +12 -15
- package/dist/src/index.js.map +2 -2
- package/dist/src/postconditions/index.d.cts +14 -2
- package/dist/src/postconditions/index.d.ts +14 -2
- package/dist/src/postconditions/index.js +3 -3
- package/dist/src/pox/index.cjs +2 -6
- package/dist/src/pox/index.cjs.map +3 -3
- package/dist/src/pox/index.js +14 -19
- package/dist/src/pox/index.js.map +3 -3
- package/dist/src/sbtc/index.cjs +2 -6
- package/dist/src/sbtc/index.cjs.map +3 -3
- package/dist/src/sbtc/index.js +13 -18
- package/dist/src/sbtc/index.js.map +3 -3
- package/dist/src/stackingdao/index.js +11 -13
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/tools/index.cjs +199 -57
- package/dist/src/tools/index.cjs.map +13 -13
- package/dist/src/tools/index.js +199 -57
- package/dist/src/tools/index.js.map +13 -13
- package/dist/src/transactions/index.cjs +2 -1
- package/dist/src/transactions/index.cjs.map +1 -1
- package/dist/src/transactions/index.d.cts +35 -3
- package/dist/src/transactions/index.d.ts +35 -3
- package/dist/src/transactions/index.js +8 -7
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.cjs +2 -1
- package/dist/src/utils/index.cjs.map +2 -2
- package/dist/src/utils/index.d.cts +5 -1
- package/dist/src/utils/index.d.ts +5 -1
- package/dist/src/utils/index.js +12 -14
- package/dist/src/utils/index.js.map +2 -2
- package/dist/src/x402/index.d.cts +19 -1
- package/dist/src/x402/index.d.ts +19 -1
- package/dist/src/x402/index.js +9 -10
- package/dist/src/x402/index.js.map +2 -2
- package/package.json +4 -2
- package/dist/shared/stacks-4trgpb5a.js.map +0 -15
- package/dist/shared/stacks-6xmk24yw.js.map +0 -10
- package/dist/shared/stacks-8mj5jw77.js.map +0 -10
- package/dist/shared/stacks-9g0jhab3.cjs +0 -40
- package/dist/shared/stacks-9g0jhab3.cjs.map +0 -10
- package/dist/shared/stacks-ertyhttt.cjs.map +0 -15
- package/dist/shared/stacks-fcaefc5b.cjs +0 -16
- package/dist/shared/stacks-fcaefc5b.cjs.map +0 -10
- package/dist/shared/stacks-g7ffp8aj.js.map +0 -13
- package/dist/shared/stacks-nqae5amn.cjs.map +0 -10
- package/dist/shared/stacks-v9jqcpd4.js +0 -18
- package/dist/shared/stacks-v9jqcpd4.js.map +0 -10
- package/dist/shared/stacks-vdfag81a.cjs.map +0 -10
- package/dist/shared/stacks-wqgepfab.js.map +0 -10
- package/dist/shared/stacks-wyxj879g.cjs.map +0 -13
- package/dist/shared/stacks-xxn5ma6g.js +0 -22
- package/dist/shared/stacks-xxn5ma6g.js.map +0 -10
- package/dist/shared/stacks-ya3x01yd.cjs +0 -16
- package/dist/shared/stacks-ya3x01yd.cjs.map +0 -10
- /package/dist/shared/{stacks-0zysn74p.js.map → stacks-2mm20wqf.js.map} +0 -0
- /package/dist/shared/{stacks-1qmx9kt8.js.map → stacks-3kmj5yre.js.map} +0 -0
- /package/dist/shared/{stacks-ttbq8emk.js.map → stacks-502j0efj.js.map} +0 -0
- /package/dist/shared/{stacks-53bjdb6p.js.map → stacks-7nvbv61d.js.map} +0 -0
- /package/dist/shared/{stacks-43cxvnr7.js.map → stacks-jbmcwky5.js.map} +0 -0
- /package/dist/shared/{stacks-q1mjkt15.js.map → stacks-msmgyerb.js.map} +0 -0
- /package/dist/shared/{stacks-z1j5d6fd.js.map → stacks-v150hffx.js.map} +0 -0
- /package/dist/shared/{stacks-a36n7sjz.js.map → stacks-x94a1d6s.js.map} +0 -0
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Cl,
|
|
3
|
+
boolCV,
|
|
4
|
+
bufferCV,
|
|
5
|
+
intCV,
|
|
6
|
+
listCV,
|
|
7
|
+
noneCV,
|
|
8
|
+
responseErrorCV,
|
|
9
|
+
responseOkCV,
|
|
10
|
+
someCV,
|
|
11
|
+
stringAsciiCV,
|
|
12
|
+
stringUtf8CV,
|
|
13
|
+
tupleCV,
|
|
14
|
+
uintCV
|
|
15
|
+
} from "./stacks-2mm20wqf.js";
|
|
16
|
+
import {
|
|
17
|
+
MAX_I128,
|
|
18
|
+
MAX_U128,
|
|
19
|
+
MIN_I128,
|
|
20
|
+
validateStacksAddress
|
|
21
|
+
} from "./stacks-azp00pve.js";
|
|
22
|
+
|
|
1
23
|
// src/clarity/abi/types.ts
|
|
2
24
|
var CONTRACT_NAME_REGEX = /^[a-zA-Z][a-zA-Z0-9\-]{0,127}$/;
|
|
3
25
|
|
|
@@ -105,7 +127,64 @@ function toCamelCase(str) {
|
|
|
105
127
|
}
|
|
106
128
|
|
|
107
129
|
// src/clarity/bridge.ts
|
|
130
|
+
var CV_TYPE_TAGS = new Set([
|
|
131
|
+
"int",
|
|
132
|
+
"uint",
|
|
133
|
+
"true",
|
|
134
|
+
"false",
|
|
135
|
+
"address",
|
|
136
|
+
"contract",
|
|
137
|
+
"ascii",
|
|
138
|
+
"utf8",
|
|
139
|
+
"buffer",
|
|
140
|
+
"list",
|
|
141
|
+
"tuple",
|
|
142
|
+
"none",
|
|
143
|
+
"some",
|
|
144
|
+
"ok",
|
|
145
|
+
"err"
|
|
146
|
+
]);
|
|
147
|
+
function isClarityValue(value) {
|
|
148
|
+
if (typeof value !== "object" || value === null)
|
|
149
|
+
return false;
|
|
150
|
+
const type = value.type;
|
|
151
|
+
if (typeof type !== "string" || !CV_TYPE_TAGS.has(type))
|
|
152
|
+
return false;
|
|
153
|
+
if (type === "true" || type === "false" || type === "none")
|
|
154
|
+
return true;
|
|
155
|
+
return "value" in value;
|
|
156
|
+
}
|
|
157
|
+
var HEX_PAIRS_REGEX = /^(?:[0-9a-fA-F]{2})+$/;
|
|
158
|
+
function coerceBuffer(value) {
|
|
159
|
+
if (value instanceof Uint8Array)
|
|
160
|
+
return bufferCV(value);
|
|
161
|
+
if (typeof value === "object" && value !== null && "type" in value) {
|
|
162
|
+
const tagged = value;
|
|
163
|
+
if (tagged.type === "buffer" && isClarityValue(value))
|
|
164
|
+
return value;
|
|
165
|
+
if (typeof tagged.value === "string") {
|
|
166
|
+
if (tagged.type === "ascii")
|
|
167
|
+
return Cl.bufferFromAscii(tagged.value);
|
|
168
|
+
if (tagged.type === "utf8")
|
|
169
|
+
return Cl.bufferFromUtf8(tagged.value);
|
|
170
|
+
if (tagged.type === "hex")
|
|
171
|
+
return Cl.bufferFromHex(tagged.value);
|
|
172
|
+
}
|
|
173
|
+
throw new Error(`Unsupported buffer input: ${JSON.stringify(value)}`);
|
|
174
|
+
}
|
|
175
|
+
if (typeof value === "string") {
|
|
176
|
+
const hex = value.startsWith("0x") ? value.slice(2) : value;
|
|
177
|
+
if (HEX_PAIRS_REGEX.test(hex))
|
|
178
|
+
return Cl.bufferFromHex(hex);
|
|
179
|
+
return Cl.bufferFromUtf8(value);
|
|
180
|
+
}
|
|
181
|
+
throw new Error("buffer arg expects Uint8Array, hex string, { type, value }, or BufferCV");
|
|
182
|
+
}
|
|
108
183
|
function jsToClarityValue(abiType, value) {
|
|
184
|
+
if (isAbiBuffer(abiType))
|
|
185
|
+
return coerceBuffer(value);
|
|
186
|
+
if (isClarityValue(value))
|
|
187
|
+
return value;
|
|
109
188
|
if (abiType === "uint128")
|
|
110
189
|
return uintCV(value);
|
|
111
190
|
if (abiType === "int128")
|
|
@@ -118,8 +197,6 @@ function jsToClarityValue(abiType, value) {
|
|
|
118
197
|
return stringAsciiCV(value);
|
|
119
198
|
if (isAbiStringUtf8(abiType))
|
|
120
199
|
return stringUtf8CV(value);
|
|
121
|
-
if (isAbiBuffer(abiType))
|
|
122
|
-
return bufferCV(value);
|
|
123
200
|
if (isAbiList(abiType)) {
|
|
124
201
|
const arr = value;
|
|
125
202
|
return listCV(arr.map((item) => jsToClarityValue(abiType.list.type, item)));
|
|
@@ -228,5 +305,7 @@ function clarityValueToJSInner(abiType, cv) {
|
|
|
228
305
|
throw new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);
|
|
229
306
|
}
|
|
230
307
|
|
|
231
|
-
|
|
232
|
-
|
|
308
|
+
export { CONTRACT_NAME_REGEX, isUint128, isInt128, isBool, isPrincipal, isStandardPrincipal, isContractPrincipal, isTraitReference, isString, isUint8Array, isArray, isOptional, isOkResponse, isErrResponse, isResponse, isAbiList, isAbiTuple, isAbiOptional, isAbiResponse, isAbiBuffer, isAbiStringAscii, isAbiStringUtf8, isAbiTraitReference, toCamelCase, isClarityValue, jsToClarityValue, clarityValueToJS, clarityValueToJSUntyped };
|
|
309
|
+
|
|
310
|
+
//# debugId=61393ECAC463249664756E2164756E21
|
|
311
|
+
//# sourceMappingURL=stacks-18jv9aen.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/clarity/abi/types.ts", "../src/clarity/abi/guards.ts", "../src/clarity/abi/utils.ts", "../src/clarity/bridge.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { MAX_I128, MAX_U128, MIN_I128 } from \"../../utils/constants.ts\";\n\nexport { MAX_U128, MAX_I128, MIN_I128 };\n\nexport const CONTRACT_NAME_REGEX: RegExp = /^[a-zA-Z][a-zA-Z0-9\\-]{0,127}$/;\n\n// Primitive types\n\nexport type AbiUInt128 = \"uint128\";\nexport type AbiInt128 = \"int128\";\nexport type AbiBool = \"bool\";\nexport type AbiPrincipal = \"principal\";\nexport type AbiTraitReference = \"trait_reference\";\nexport type AbiNone = \"none\";\n\nexport type AbiStringAscii<L extends number = number> = {\n\t\"string-ascii\": { length: L };\n};\n\nexport type AbiStringUtf8<L extends number = number> = {\n\t\"string-utf8\": { length: L };\n};\n\nexport type AbiBuffer<L extends number = number> = {\n\tbuff: { length: L };\n};\n\nexport type AbiPrimitiveType =\n\t| AbiUInt128\n\t| AbiInt128\n\t| AbiBool\n\t| AbiPrincipal\n\t| AbiTraitReference\n\t| AbiNone\n\t| AbiStringAscii\n\t| AbiStringUtf8\n\t| AbiBuffer;\n\n// Composite types (interfaces for recursion)\n\nexport interface AbiListType {\n\tlist: { type: AbiType; length: number };\n}\n\nexport interface AbiTupleType {\n\ttuple: ReadonlyArray<{ name: string; type: AbiType }>;\n}\n\nexport interface AbiOptionalType {\n\toptional: AbiType;\n}\n\nexport interface AbiResponseType {\n\tresponse: { ok: AbiType; error: AbiType };\n}\n\n/** Discriminated union of all Clarity value types (primitives, buffers, lists, tuples, optionals, responses). */\nexport type AbiType =\n\t| AbiPrimitiveType\n\t| AbiListType\n\t| AbiTupleType\n\t| AbiOptionalType\n\t| AbiResponseType;\n\n// Generic versions for better type inference\n\nexport type AbiList<T extends AbiType = AbiType, L extends number = number> = {\n\tlist: { type: T; length: L };\n};\n\nexport type AbiTuple<T extends ReadonlyArray<{ name: string; type: AbiType }>> =\n\t{\n\t\ttuple: T;\n\t};\n\nexport type AbiOptional<T extends AbiType = AbiType> = {\n\toptional: T;\n};\n\nexport type AbiResponse<\n\tO extends AbiType = AbiType,\n\tE extends AbiType = AbiType,\n> = {\n\tresponse: { ok: O; error: E };\n};\n",
|
|
6
|
+
"import { validateStacksAddress } from \"../../utils/address.ts\";\nimport type { ResponseErr, ResponseOk } from \"./mappings.ts\";\nimport { CONTRACT_NAME_REGEX, MAX_I128, MAX_U128, MIN_I128 } from \"./types.ts\";\nimport type {\n\tAbiBuffer,\n\tAbiListType,\n\tAbiOptionalType,\n\tAbiResponseType,\n\tAbiStringAscii,\n\tAbiStringUtf8,\n\tAbiTraitReference,\n\tAbiTupleType,\n\tAbiType,\n} from \"./types.ts\";\n\n// Value guards\n\nexport function isUint128(value: unknown): value is bigint {\n\treturn typeof value === \"bigint\" && value >= 0n && value <= MAX_U128;\n}\n\nexport function isInt128(value: unknown): value is bigint {\n\treturn typeof value === \"bigint\" && value >= MIN_I128 && value <= MAX_I128;\n}\n\nexport function isBool(value: unknown): value is boolean {\n\treturn typeof value === \"boolean\";\n}\n\nexport function isPrincipal(value: unknown): value is string {\n\tif (typeof value !== \"string\") return false;\n\tconst parts = value.split(\".\");\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\tconst address = parts[0]!;\n\tconst contractName = parts[1];\n\tif (!validateStacksAddress(address)) return false;\n\tif (contractName !== undefined) {\n\t\treturn CONTRACT_NAME_REGEX.test(contractName);\n\t}\n\treturn true;\n}\n\nexport function isStandardPrincipal(value: unknown): value is string {\n\tif (typeof value !== \"string\") return false;\n\tif (value.includes(\".\")) return false;\n\treturn validateStacksAddress(value);\n}\n\nexport function isContractPrincipal(value: unknown): value is string {\n\tif (typeof value !== \"string\") return false;\n\tif (!value.includes(\".\")) return false;\n\tconst parts = value.split(\".\");\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\tconst address = parts[0]!;\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\tconst contractName = parts[1]!;\n\tif (!validateStacksAddress(address)) return false;\n\treturn CONTRACT_NAME_REGEX.test(contractName);\n}\n\nexport function isTraitReference(value: unknown): value is string {\n\treturn isContractPrincipal(value);\n}\n\nexport function isString(value: unknown): value is string {\n\treturn typeof value === \"string\";\n}\n\nexport function isUint8Array(value: unknown): value is Uint8Array {\n\treturn value instanceof Uint8Array;\n}\n\nexport function isArray<T>(\n\tvalue: unknown,\n\titemGuard: (item: unknown) => item is T,\n): value is T[] {\n\treturn Array.isArray(value) && value.every(itemGuard);\n}\n\nexport function isOptional<T>(\n\tvalue: unknown,\n\tguard: (val: unknown) => val is T,\n): value is T | null {\n\treturn value === null || guard(value);\n}\n\nexport function isOkResponse<T>(\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tresponse: { ok: T } | { err: any },\n): response is ResponseOk<T> {\n\treturn \"ok\" in response && !(\"err\" in response);\n}\n\nexport function isErrResponse<E>(\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tresponse: { ok: any } | { err: E },\n): response is ResponseErr<E> {\n\treturn \"err\" in response && !(\"ok\" in response);\n}\n\nexport function isResponse<T, E>(\n\tvalue: unknown,\n\tokGuard: (val: unknown) => val is T,\n\terrGuard: (val: unknown) => val is E,\n): value is ResponseOk<T> | ResponseErr<E> {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst obj = value as Record<string, unknown>;\n\tif (\"ok\" in value && !(\"err\" in value)) return okGuard(obj.ok);\n\tif (\"err\" in value && !(\"ok\" in value)) return errGuard(obj.err);\n\treturn false;\n}\n\n// ABI type definition guards\n\nexport function isAbiList(type: AbiType): type is AbiListType {\n\treturn typeof type === \"object\" && type !== null && \"list\" in type;\n}\n\nexport function isAbiTuple(type: AbiType): type is AbiTupleType {\n\treturn typeof type === \"object\" && type !== null && \"tuple\" in type;\n}\n\nexport function isAbiOptional(type: AbiType): type is AbiOptionalType {\n\treturn typeof type === \"object\" && type !== null && \"optional\" in type;\n}\n\nexport function isAbiResponse(type: AbiType): type is AbiResponseType {\n\treturn typeof type === \"object\" && type !== null && \"response\" in type;\n}\n\nexport function isAbiBuffer(type: AbiType): type is AbiBuffer {\n\treturn typeof type === \"object\" && type !== null && \"buff\" in type;\n}\n\nexport function isAbiStringAscii(type: AbiType): type is AbiStringAscii {\n\treturn typeof type === \"object\" && type !== null && \"string-ascii\" in type;\n}\n\nexport function isAbiStringUtf8(type: AbiType): type is AbiStringUtf8 {\n\treturn typeof type === \"object\" && type !== null && \"string-utf8\" in type;\n}\n\nexport function isAbiTraitReference(type: AbiType): type is AbiTraitReference {\n\treturn type === \"trait_reference\";\n}\n",
|
|
7
|
+
"type CamelCaseInner<S extends string> =\n\tS extends `${infer P1}-${infer P2}${infer P3}`\n\t\t? `${P1}${Capitalize<CamelCaseInner<`${P2}${P3}`>>}`\n\t\t: S;\n\nexport type ToCamelCase<S extends string> =\n\tCamelCaseInner<S> extends `${number}${string}`\n\t\t? `_${CamelCaseInner<S>}`\n\t\t: CamelCaseInner<S>;\n\nexport function toCamelCase(str: string): string {\n\treturn str\n\t\t.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n\t\t.replace(/-([A-Z])/g, (_, letter) => letter)\n\t\t.replace(/-(\\d)/g, (_, digit) => digit)\n\t\t.replace(/-/g, \"\")\n\t\t.replace(/^\\d/, \"_$&\");\n}\n",
|
|
8
|
+
"import {\n\tisAbiBuffer,\n\tisAbiList,\n\tisAbiOptional,\n\tisAbiResponse,\n\tisAbiStringAscii,\n\tisAbiStringUtf8,\n\tisAbiTuple,\n} from \"./abi/guards.ts\";\nimport type { AbiToTS } from \"./abi/mappings.ts\";\nimport type { AbiType } from \"./abi/types.ts\";\nimport { toCamelCase } from \"./abi/utils.ts\";\nimport type { ClarityValue } from \"./types.ts\";\nimport {\n\tboolCV,\n\tbufferCV,\n\tintCV,\n\tlistCV,\n\tnoneCV,\n\tresponseErrorCV,\n\tresponseOkCV,\n\tsomeCV,\n\tstringAsciiCV,\n\tstringUtf8CV,\n\ttupleCV,\n\tuintCV,\n} from \"./values.ts\";\nimport { Cl } from \"./values.ts\";\n\n/** CV type tags — mirrors the discriminants of `ClarityValue`. */\nconst CV_TYPE_TAGS = new Set([\n\t\"int\",\n\t\"uint\",\n\t\"true\",\n\t\"false\",\n\t\"address\",\n\t\"contract\",\n\t\"ascii\",\n\t\"utf8\",\n\t\"buffer\",\n\t\"list\",\n\t\"tuple\",\n\t\"none\",\n\t\"some\",\n\t\"ok\",\n\t\"err\",\n]);\n\n/**\n * Duck-type check: is `value` already a built ClarityValue? Tag-only CVs\n * (`true`/`false`/`none`) have no payload; every other tag carries `value`.\n */\nexport function isClarityValue(value: unknown): value is ClarityValue {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst type = (value as { type?: unknown }).type;\n\tif (typeof type !== \"string\" || !CV_TYPE_TAGS.has(type)) return false;\n\tif (type === \"true\" || type === \"false\" || type === \"none\") return true;\n\treturn \"value\" in value;\n}\n\nconst HEX_PAIRS_REGEX = /^(?:[0-9a-fA-F]{2})+$/;\n\n/**\n * Coerce a flexible buffer input to a BufferCV. Accepts `Uint8Array`, a\n * pre-built `BufferCV`, a tagged `{ type: 'ascii' | 'utf8' | 'hex', value }`\n * object, or a bare string (even-length hex — optionally 0x-prefixed — is\n * decoded as hex; anything else is UTF-8 encoded).\n */\nfunction coerceBuffer(value: unknown): ClarityValue {\n\tif (value instanceof Uint8Array) return bufferCV(value);\n\tif (typeof value === \"object\" && value !== null && \"type\" in value) {\n\t\tconst tagged = value as { type: string; value?: unknown };\n\t\tif (tagged.type === \"buffer\" && isClarityValue(value)) return value;\n\t\tif (typeof tagged.value === \"string\") {\n\t\t\tif (tagged.type === \"ascii\") return Cl.bufferFromAscii(tagged.value);\n\t\t\tif (tagged.type === \"utf8\") return Cl.bufferFromUtf8(tagged.value);\n\t\t\tif (tagged.type === \"hex\") return Cl.bufferFromHex(tagged.value);\n\t\t}\n\t\tthrow new Error(`Unsupported buffer input: ${JSON.stringify(value)}`);\n\t}\n\tif (typeof value === \"string\") {\n\t\tconst hex = value.startsWith(\"0x\") ? value.slice(2) : value;\n\t\tif (HEX_PAIRS_REGEX.test(hex)) return Cl.bufferFromHex(hex);\n\t\treturn Cl.bufferFromUtf8(value);\n\t}\n\tthrow new Error(\n\t\t\"buffer arg expects Uint8Array, hex string, { type, value }, or BufferCV\",\n\t);\n}\n\n/**\n * Convert a JS value to a ClarityValue using ABI type information.\n *\n * Pre-built ClarityValues pass through unchanged (escape hatch for callers\n * that already hold a CV). Buffer args additionally accept hex strings and\n * tagged `{ type, value }` objects — matching the generated-client input\n * contract.\n */\nexport function jsToClarityValue(\n\tabiType: AbiType,\n\tvalue: unknown,\n): ClarityValue {\n\t// Buffers first: the tagged `{ type: 'ascii', value }` input form is\n\t// shape-identical to StringAsciiCV, so buffer coercion wins for buff args.\n\tif (isAbiBuffer(abiType)) return coerceBuffer(value);\n\n\tif (isClarityValue(value)) return value;\n\n\tif (abiType === \"uint128\") return uintCV(value as bigint | number);\n\tif (abiType === \"int128\") return intCV(value as bigint | number);\n\tif (abiType === \"bool\") return boolCV(value as boolean);\n\tif (abiType === \"principal\" || abiType === \"trait_reference\")\n\t\treturn Cl.principal(value as string);\n\n\tif (isAbiStringAscii(abiType)) return stringAsciiCV(value as string);\n\tif (isAbiStringUtf8(abiType)) return stringUtf8CV(value as string);\n\n\tif (isAbiList(abiType)) {\n\t\tconst arr = value as unknown[];\n\t\treturn listCV(arr.map((item) => jsToClarityValue(abiType.list.type, item)));\n\t}\n\n\tif (isAbiTuple(abiType)) {\n\t\tconst obj = value as Record<string, unknown>;\n\t\tconst data: Record<string, ClarityValue> = {};\n\t\tfor (const field of abiType.tuple) {\n\t\t\tconst camelKey = toCamelCase(field.name);\n\t\t\tconst hasOriginal = field.name in obj;\n\t\t\tconst hasCamel = camelKey in obj;\n\t\t\tconst fieldValue = hasOriginal\n\t\t\t\t? obj[field.name]\n\t\t\t\t: hasCamel\n\t\t\t\t\t? obj[camelKey]\n\t\t\t\t\t: undefined;\n\t\t\tif (fieldValue === undefined && !isAbiOptional(field.type)) {\n\t\t\t\tthrow new Error(`Missing tuple field: ${field.name}`);\n\t\t\t}\n\t\t\tdata[field.name] = jsToClarityValue(field.type, fieldValue);\n\t\t}\n\t\treturn tupleCV(data);\n\t}\n\n\tif (isAbiOptional(abiType)) {\n\t\tif (value === null || value === undefined) return noneCV();\n\t\treturn someCV(jsToClarityValue(abiType.optional, value));\n\t}\n\n\tif (isAbiResponse(abiType)) {\n\t\tconst obj = value as Record<string, unknown>;\n\t\tif (\"ok\" in obj && !(\"err\" in obj))\n\t\t\treturn responseOkCV(jsToClarityValue(abiType.response.ok, obj.ok));\n\t\tif (\"err\" in obj && !(\"ok\" in obj))\n\t\t\treturn responseErrorCV(jsToClarityValue(abiType.response.error, obj.err));\n\t\tthrow new Error(\"Response must have exactly 'ok' or 'err' property\");\n\t}\n\n\tthrow new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);\n}\n\n/**\n * Convert a ClarityValue back to a typed JS value using ABI type information.\n */\nexport function clarityValueToJS<T extends AbiType>(\n\tabiType: T,\n\tcv: ClarityValue,\n): AbiToTS<T> {\n\treturn clarityValueToJSInner(abiType, cv) as AbiToTS<T>;\n}\n\n/** Non-generic version for internal use — avoids deep type instantiation. */\nexport function clarityValueToJSUntyped(\n\tabiType: AbiType,\n\tcv: ClarityValue,\n): unknown {\n\treturn clarityValueToJSInner(abiType, cv);\n}\n\nfunction clarityValueToJSInner(abiType: AbiType, cv: ClarityValue): unknown {\n\tif (abiType === \"uint128\" || abiType === \"int128\") {\n\t\tif (cv.type !== \"int\" && cv.type !== \"uint\")\n\t\t\tthrow new Error(`Expected int/uint CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (abiType === \"bool\") {\n\t\tif (cv.type === \"true\") return true;\n\t\tif (cv.type === \"false\") return false;\n\t\tthrow new Error(`Expected bool CV, got ${cv.type}`);\n\t}\n\n\tif (abiType === \"principal\" || abiType === \"trait_reference\") {\n\t\tif (cv.type !== \"address\" && cv.type !== \"contract\")\n\t\t\tthrow new Error(`Expected principal CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (isAbiStringAscii(abiType) || isAbiStringUtf8(abiType)) {\n\t\tif (cv.type !== \"ascii\" && cv.type !== \"utf8\")\n\t\t\tthrow new Error(`Expected string CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (isAbiBuffer(abiType)) {\n\t\tif (cv.type !== \"buffer\")\n\t\t\tthrow new Error(`Expected buffer CV, got ${cv.type}`);\n\t\t// BufferCV stores hex string; convert back to Uint8Array\n\t\tconst hex = cv.value;\n\t\tconst bytes = new Uint8Array(hex.length / 2);\n\t\tfor (let i = 0; i < bytes.length; i++) {\n\t\t\tbytes[i] = Number.parseInt(hex.substring(i * 2, i * 2 + 2), 16);\n\t\t}\n\t\treturn bytes;\n\t}\n\n\tif (isAbiList(abiType)) {\n\t\tif (cv.type !== \"list\") throw new Error(`Expected list CV, got ${cv.type}`);\n\t\treturn cv.value.map((item) =>\n\t\t\tclarityValueToJSInner(abiType.list.type, item),\n\t\t);\n\t}\n\n\tif (isAbiTuple(abiType)) {\n\t\tif (cv.type !== \"tuple\")\n\t\t\tthrow new Error(`Expected tuple CV, got ${cv.type}`);\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const field of abiType.tuple) {\n\t\t\tconst fieldCV = cv.value[field.name];\n\t\t\tif (!fieldCV) throw new Error(`Missing tuple field in CV: ${field.name}`);\n\t\t\tconst camelKey = toCamelCase(field.name);\n\t\t\tresult[camelKey] = clarityValueToJSInner(field.type, fieldCV);\n\t\t}\n\t\treturn result;\n\t}\n\n\tif (isAbiOptional(abiType)) {\n\t\tif (cv.type === \"none\") return null;\n\t\tif (cv.type === \"some\")\n\t\t\treturn clarityValueToJSInner(abiType.optional, cv.value);\n\t\tthrow new Error(`Expected optional CV, got ${cv.type}`);\n\t}\n\n\tif (isAbiResponse(abiType)) {\n\t\tif (cv.type === \"ok\")\n\t\t\treturn { ok: clarityValueToJSInner(abiType.response.ok, cv.value) };\n\t\tif (cv.type === \"err\")\n\t\t\treturn { err: clarityValueToJSInner(abiType.response.error, cv.value) };\n\t\tthrow new Error(`Expected response CV, got ${cv.type}`);\n\t}\n\n\tthrow new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAM,sBAA8B;;;ACapC,SAAS,SAAS,CAAC,OAAiC;AAAA,EAC1D,OAAO,OAAO,UAAU,YAAY,SAAS,MAAM,SAAS;AAAA;AAGtD,SAAS,QAAQ,CAAC,OAAiC;AAAA,EACzD,OAAO,OAAO,UAAU,YAAY,SAAS,YAAY,SAAS;AAAA;AAG5D,SAAS,MAAM,CAAC,OAAkC;AAAA,EACxD,OAAO,OAAO,UAAU;AAAA;AAGlB,SAAS,WAAW,CAAC,OAAiC;AAAA,EAC5D,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO;AAAA,EACtC,MAAM,QAAQ,MAAM,MAAM,GAAG;AAAA,EAE7B,MAAM,UAAU,MAAM;AAAA,EACtB,MAAM,eAAe,MAAM;AAAA,EAC3B,IAAI,CAAC,sBAAsB,OAAO;AAAA,IAAG,OAAO;AAAA,EAC5C,IAAI,iBAAiB,WAAW;A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AQ,OAAO;AAAA,MAClC,MAAM,UAAU,GAAG,MAAM,MAAM;AAAA,MAC/B,IAAI,CAAC;AAAA,QAAS,MAAM,IAAI,MAAM,8BAA8B,MAAM,MAAM;AAAA,MACxE,MAAM,WAAW,YAAY,MAAM,IAAI;AAAA,MACvC,OAAO,YAAY,sBAAsB,MAAM,MAAM,OAAO;AAAA,IAC7D;AAAA,IACA,OAAO;AAAA,EACR;AAAA,EAEA,IAAI,cAAc,OAAO,GAAG;AAAA,IAC3B,IAAI,GAAG,SAAS;AAAA,MAAQ,OAAO;AAAA,IAC/B,IAAI,GAAG,SAAS;AAAA,MACf,OAAO,sBAAsB,QAAQ,UAAU,GAAG,KAAK;AAAA,IACxD,MAAM,IAAI,MAAM,6BAA6B,GAAG,MAAM;AAAA,EACvD;AAAA,EAEA,IAAI,cAAc,OAAO,GAAG;AAAA,IAC3B,IAAI,GAAG,SAAS;AAAA,MACf,OAAO,EAAE,IAAI,sBAAsB,QAAQ,SAAS,IAAI,GAAG,KAAK,EAAE;AAAA,IACnE,IAAI,GAAG,SAAS;AAAA,MACf,OAAO,EAAE,KAAK,sBAAsB,QAAQ,SAAS,OAAO,GAAG,KAAK,EAAE;AAAA,IACvE,MAAM,IAAI,MAAM,6BAA6B,GAAG,MAAM;AAAA,EACvD;AAAA,EAEA,MAAM,IAAI,MAAM,qBAAqB,KAAK,UAAU,OAAO,GAAG;AAAA;",
|
|
11
|
+
"debugId": "61393ECAC463249664756E2164756E21",
|
|
12
|
+
"names": []
|
|
13
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isClarityName
|
|
3
|
-
} from "./stacks-
|
|
3
|
+
} from "./stacks-azp00pve.js";
|
|
4
4
|
import {
|
|
5
5
|
asciiToBytes,
|
|
6
6
|
bigIntToBytes,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
utf8ToBytes,
|
|
19
19
|
without0x,
|
|
20
20
|
writeUInt32BE
|
|
21
|
-
} from "./stacks-
|
|
21
|
+
} from "./stacks-qs5fzts5.js";
|
|
22
22
|
|
|
23
23
|
// src/clarity/types.ts
|
|
24
24
|
var ClarityWireType = {
|
|
@@ -356,4 +356,4 @@ var Cl = {
|
|
|
356
356
|
export { ClarityWireType, clarityTypeFromByte, serializeCVBytes, serializeCV, BytesReader, intCV, uintCV, trueCV, falseCV, boolCV, bufferCV, standardPrincipalCV, contractPrincipalCV, noneCV, someCV, responseOkCV, responseErrorCV, listCV, tupleCV, stringAsciiCV, stringUtf8CV, Cl, readAddress, readLPString, readCV, deserializeCVBytes, deserializeCV };
|
|
357
357
|
|
|
358
358
|
//# debugId=75F450EFADB0433F64756E2164756E21
|
|
359
|
-
//# sourceMappingURL=stacks-
|
|
359
|
+
//# sourceMappingURL=stacks-2mm20wqf.js.map
|
|
@@ -2,15 +2,15 @@ import {
|
|
|
2
2
|
estimateFee,
|
|
3
3
|
isProviderAccount,
|
|
4
4
|
resolveNonce
|
|
5
|
-
} from "./stacks-
|
|
5
|
+
} from "./stacks-502j0efj.js";
|
|
6
6
|
import {
|
|
7
7
|
AuthType,
|
|
8
8
|
createSingleSigSpendingCondition,
|
|
9
9
|
signSponsorWithAccount
|
|
10
|
-
} from "./stacks-
|
|
10
|
+
} from "./stacks-ssndnbbd.js";
|
|
11
11
|
import {
|
|
12
12
|
intToBigInt
|
|
13
|
-
} from "./stacks-
|
|
13
|
+
} from "./stacks-qs5fzts5.js";
|
|
14
14
|
|
|
15
15
|
// src/actions/wallet/sponsorTransaction.ts
|
|
16
16
|
async function sponsorTransaction(client, params) {
|
|
@@ -48,4 +48,4 @@ async function sponsorTransaction(client, params) {
|
|
|
48
48
|
export { sponsorTransaction };
|
|
49
49
|
|
|
50
50
|
//# debugId=B5D2826EE8DC537B64756E2164756E21
|
|
51
|
-
//# sourceMappingURL=stacks-
|
|
51
|
+
//# sourceMappingURL=stacks-3kmj5yre.js.map
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
getTransactionId,
|
|
6
6
|
serializePayload,
|
|
7
7
|
serializeTransaction
|
|
8
|
-
} from "./stacks-
|
|
8
|
+
} from "./stacks-ssndnbbd.js";
|
|
9
9
|
import {
|
|
10
10
|
bytesToHex
|
|
11
|
-
} from "./stacks-
|
|
11
|
+
} from "./stacks-qs5fzts5.js";
|
|
12
12
|
|
|
13
13
|
// src/actions/public/estimateFee.ts
|
|
14
14
|
async function estimateFee(client, params) {
|
|
@@ -207,4 +207,4 @@ function isProviderAccount(account) {
|
|
|
207
207
|
export { estimateFee, getNonce, TransactionError, BroadcastError, SerializationError, SigningError, sendTransaction, jsonRpcSource, memoryStore, createNonceManager, resolveNonce, reconcileNonce, startNonceReconciler, isNonceConflictError, broadcastWithNonceReset, isProviderAccount };
|
|
208
208
|
|
|
209
209
|
//# debugId=5FE30A330D92FC6964756E2164756E21
|
|
210
|
-
//# sourceMappingURL=stacks-
|
|
210
|
+
//# sourceMappingURL=stacks-502j0efj.js.map
|
|
@@ -115,6 +115,23 @@ function readPostConditions(r) {
|
|
|
115
115
|
conditionCode: r.readUInt8()
|
|
116
116
|
});
|
|
117
117
|
break;
|
|
118
|
+
case AssetType.Staking:
|
|
119
|
+
pcs.push({
|
|
120
|
+
type: "staking",
|
|
121
|
+
principal,
|
|
122
|
+
conditionCode: r.readUInt8(),
|
|
123
|
+
amount: r.readBigUInt64BE()
|
|
124
|
+
});
|
|
125
|
+
break;
|
|
126
|
+
case AssetType.Pox:
|
|
127
|
+
pcs.push({
|
|
128
|
+
type: "pox",
|
|
129
|
+
principal,
|
|
130
|
+
conditionCode: r.readUInt8()
|
|
131
|
+
});
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
throw new Error(`Unknown post-condition asset type: 0x${assetType.toString(16).padStart(2, "0")} (post-condition ${i + 1}/${count})`);
|
|
118
135
|
}
|
|
119
136
|
}
|
|
120
137
|
return pcs;
|
|
@@ -233,5 +250,5 @@ function deserializeTransaction(input) {
|
|
|
233
250
|
};
|
|
234
251
|
}
|
|
235
252
|
|
|
236
|
-
//# debugId=
|
|
237
|
-
//# sourceMappingURL=stacks-
|
|
253
|
+
//# debugId=986103D4B633E3BE64756E2164756E21
|
|
254
|
+
//# sourceMappingURL=stacks-5nskdw7w.cjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/transactions/wire/deserialize.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {\n\treadAddress,\n\treadCV,\n\treadLPString,\n} from \"../../clarity/deserialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport { BytesReader } from \"../../utils/bytes-reader.ts\";\nimport {\n\tbytesToAscii,\n\tbytesToHex,\n\thexToBytes,\n\twithout0x,\n} from \"../../utils/encoding.ts\";\nimport {\n\tAddressHashMode,\n\ttype AnchorMode,\n\ttype AssetInfoWire,\n\tAssetType,\n\tAuthType,\n\ttype Authorization,\n\tCOINBASE_BYTES_LENGTH,\n\ttype ClarityVersion,\n\tMEMO_MAX_LENGTH_BYTES,\n\tMICROBLOCK_HEADER_BYTES_LENGTH,\n\tPayloadType,\n\ttype PostConditionModeWire,\n\tPostConditionPrincipalId,\n\ttype PostConditionPrincipalWire,\n\ttype PostConditionWire,\n\ttype PoxConditionCode,\n\tRECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n\ttype SpendingCondition,\n\ttype StacksTransaction,\n\ttype TenureChangeCause,\n\ttype TransactionAuthField,\n\ttype TransactionPayload,\n\tVRF_PROOF_BYTES_LENGTH,\n} from \"../types.ts\";\n\nfunction readSpendingCondition(r: BytesReader): SpendingCondition {\n\tconst hashMode = r.readUInt8();\n\tconst signer = bytesToHex(r.readBytes(20));\n\tconst nonce = r.readBigUInt64BE();\n\tconst fee = r.readBigUInt64BE();\n\n\tif (\n\t\thashMode === AddressHashMode.P2PKH ||\n\t\thashMode === AddressHashMode.P2WPKH\n\t) {\n\t\tconst keyEncoding = r.readUInt8();\n\t\tconst signature = bytesToHex(\n\t\t\tr.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES),\n\t\t);\n\t\treturn {\n\t\t\thashMode,\n\t\t\tsigner,\n\t\t\tnonce,\n\t\t\tfee,\n\t\t\tkeyEncoding,\n\t\t\tsignature,\n\t\t} as SpendingCondition;\n\t}\n\n\tconst fieldCount = r.readUInt32BE();\n\tconst fields: TransactionAuthField[] = [];\n\tfor (let i = 0; i < fieldCount; i++) {\n\t\tconst fieldType = r.readUInt8();\n\t\tif (fieldType <= 0x01) {\n\t\t\tconst keyLen = fieldType === 0x00 ? 33 : 65;\n\t\t\tfields.push({\n\t\t\t\ttype: \"publicKey\",\n\t\t\t\tpubKeyEncoding: fieldType as 0x00 | 0x01,\n\t\t\t\tdata: bytesToHex(r.readBytes(keyLen)),\n\t\t\t});\n\t\t} else {\n\t\t\tfields.push({\n\t\t\t\ttype: \"signature\",\n\t\t\t\tpubKeyEncoding: (fieldType === 0x02 ? 0x00 : 0x01) as 0x00 | 0x01,\n\t\t\t\tdata: bytesToHex(r.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES)),\n\t\t\t});\n\t\t}\n\t}\n\tconst signaturesRequired = r.readUInt16BE();\n\n\treturn {\n\t\thashMode,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tfields,\n\t\tsignaturesRequired,\n\t} as SpendingCondition;\n}\n\nfunction readAuthorization(r: BytesReader): Authorization {\n\tconst authType = r.readUInt8();\n\tconst spendingCondition = readSpendingCondition(r);\n\n\tif (authType === AuthType.Standard) {\n\t\treturn { authType: AuthType.Standard, spendingCondition };\n\t}\n\n\tconst sponsorSpendingCondition = readSpendingCondition(r);\n\treturn {\n\t\tauthType: AuthType.Sponsored,\n\t\tspendingCondition,\n\t\tsponsorSpendingCondition,\n\t};\n}\n\nfunction readAssetInfo(r: BytesReader): AssetInfoWire {\n\treturn {\n\t\taddress: readAddress(r),\n\t\tcontractName: readLPString(r),\n\t\tassetName: readLPString(r),\n\t};\n}\n\nfunction readPostConditionPrincipal(\n\tr: BytesReader,\n): PostConditionPrincipalWire {\n\tconst type = r.readUInt8();\n\tswitch (type) {\n\t\tcase PostConditionPrincipalId.Origin:\n\t\t\treturn { type: \"origin\" };\n\t\tcase PostConditionPrincipalId.Standard:\n\t\t\treturn { type: \"standard\", address: readAddress(r) };\n\t\tcase PostConditionPrincipalId.Contract:\n\t\t\treturn {\n\t\t\t\ttype: \"contract\",\n\t\t\t\taddress: readAddress(r),\n\t\t\t\tcontractName: readLPString(r),\n\t\t\t};\n\t\tdefault:\n\t\t\t// Some legacy transactions may have unexpected principal types.\n\t\t\t// Treat as origin to allow deserialization to continue.\n\t\t\treturn { type: \"origin\" };\n\t}\n}\n\nfunction readPostConditions(r: BytesReader): PostConditionWire[] {\n\tconst count = r.readUInt32BE();\n\tconst pcs: PostConditionWire[] = [];\n\tfor (let i = 0; i < count; i++) {\n\t\t// Wire order: asset_type, then principal (per SIP-005 and stacks.js)\n\t\tconst assetType = r.readUInt8();\n\t\tconst principal = readPostConditionPrincipal(r);\n\t\tswitch (assetType) {\n\t\t\tcase AssetType.STX:\n\t\t\t\tpcs.push({\n\t\t\t\t\ttype: \"stx\",\n\t\t\t\t\tprincipal,\n\t\t\t\t\tconditionCode: r.readUInt8(),\n\t\t\t\t\tamount: r.readBigUInt64BE(),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase AssetType.Fungible:\n\t\t\t\tpcs.push({\n\t\t\t\t\ttype: \"ft\",\n\t\t\t\t\tprincipal,\n\t\t\t\t\tasset: readAssetInfo(r),\n\t\t\t\t\tconditionCode: r.readUInt8(),\n\t\t\t\t\tamount: r.readBigUInt64BE(),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase AssetType.NonFungible:\n\t\t\t\tpcs.push({\n\t\t\t\t\ttype: \"nft\",\n\t\t\t\t\tprincipal,\n\t\t\t\t\tasset: readAssetInfo(r),\n\t\t\t\t\tassetId: readCV(r),\n\t\t\t\t\tconditionCode: r.readUInt8(),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase AssetType.Staking:\n\t\t\t\t// SIP-045: same body as STX (fungible condition code + amount)\n\t\t\t\tpcs.push({\n\t\t\t\t\ttype: \"staking\",\n\t\t\t\t\tprincipal,\n\t\t\t\t\tconditionCode: r.readUInt8(),\n\t\t\t\t\tamount: r.readBigUInt64BE(),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase AssetType.Pox:\n\t\t\t\t// SIP-045: PoX condition code only, no amount\n\t\t\t\tpcs.push({\n\t\t\t\t\ttype: \"pox\",\n\t\t\t\t\tprincipal,\n\t\t\t\t\tconditionCode: r.readUInt8() as PoxConditionCode,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// An unknown asset type has an unknown body length; continuing would\n\t\t\t\t// silently misalign every field after this point.\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unknown post-condition asset type: 0x${assetType.toString(16).padStart(2, \"0\")} (post-condition ${i + 1}/${count})`,\n\t\t\t\t);\n\t\t}\n\t}\n\treturn pcs;\n}\n\nfunction readPayload(r: BytesReader): TransactionPayload {\n\tconst payloadType = r.readUInt8();\n\n\tswitch (payloadType) {\n\t\tcase PayloadType.TokenTransfer: {\n\t\t\tconst recipient = readCV(r);\n\t\t\tconst amount = r.readBigUInt64BE();\n\t\t\t// Memo is a flat 34-byte field (no length prefix) per SIP-005\n\t\t\tconst memoBytes = r.readBytes(MEMO_MAX_LENGTH_BYTES);\n\t\t\tconst memo = bytesToAscii(memoBytes).replace(/\\0+$/, \"\");\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.TokenTransfer,\n\t\t\t\trecipient,\n\t\t\t\tamount,\n\t\t\t\tmemo,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.ContractCall: {\n\t\t\tconst contractAddress = readAddress(r);\n\t\t\tconst contractName = readLPString(r);\n\t\t\tconst functionName = readLPString(r);\n\t\t\tconst numArgs = r.readUInt32BE();\n\t\t\tconst functionArgs: ClarityValue[] = [];\n\t\t\tfor (let i = 0; i < numArgs; i++) functionArgs.push(readCV(r));\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.ContractCall,\n\t\t\t\tcontractAddress,\n\t\t\t\tcontractName,\n\t\t\t\tfunctionName,\n\t\t\t\tfunctionArgs,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.SmartContract: {\n\t\t\tconst contractName = readLPString(r);\n\t\t\tconst codeBody = readLPString(r, 4);\n\t\t\treturn { payloadType: PayloadType.SmartContract, contractName, codeBody };\n\t\t}\n\t\tcase PayloadType.VersionedSmartContract: {\n\t\t\tconst clarityVersion = r.readUInt8() as ClarityVersion;\n\t\t\tconst contractName = readLPString(r);\n\t\t\tconst codeBody = readLPString(r, 4);\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.VersionedSmartContract,\n\t\t\t\tclarityVersion,\n\t\t\t\tcontractName,\n\t\t\t\tcodeBody,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.Coinbase: {\n\t\t\tconst coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));\n\t\t\treturn { payloadType: PayloadType.Coinbase, coinbaseBuffer };\n\t\t}\n\t\tcase PayloadType.CoinbaseToAltRecipient: {\n\t\t\tconst coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));\n\t\t\tconst recipient = readCV(r);\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.CoinbaseToAltRecipient,\n\t\t\t\tcoinbaseBuffer,\n\t\t\t\trecipient,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.PoisonMicroblock: {\n\t\t\tconst header1 = bytesToHex(r.readBytes(MICROBLOCK_HEADER_BYTES_LENGTH));\n\t\t\tconst header2 = bytesToHex(r.readBytes(MICROBLOCK_HEADER_BYTES_LENGTH));\n\t\t\treturn { payloadType: PayloadType.PoisonMicroblock, header1, header2 };\n\t\t}\n\t\tcase PayloadType.TenureChange: {\n\t\t\tconst tenureConsensusHash = bytesToHex(r.readBytes(20));\n\t\t\tconst prevTenureConsensusHash = bytesToHex(r.readBytes(20));\n\t\t\tconst burnViewConsensusHash = bytesToHex(r.readBytes(20));\n\t\t\tconst previousTenureEnd = bytesToHex(r.readBytes(32));\n\t\t\tconst previousTenureBlocks = r.readUInt32BE();\n\t\t\tconst cause = r.readUInt8() as TenureChangeCause;\n\t\t\tconst pubkeyHash = bytesToHex(r.readBytes(20));\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.TenureChange,\n\t\t\t\ttenureConsensusHash,\n\t\t\t\tprevTenureConsensusHash,\n\t\t\t\tburnViewConsensusHash,\n\t\t\t\tpreviousTenureEnd,\n\t\t\t\tpreviousTenureBlocks,\n\t\t\t\tcause,\n\t\t\t\tpubkeyHash,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.NakamotoCoinbase: {\n\t\t\tconst coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));\n\t\t\tconst optionalCV = readCV(r);\n\t\t\tconst recipient =\n\t\t\t\toptionalCV.type === \"none\"\n\t\t\t\t\t? null\n\t\t\t\t\t: optionalCV.type === \"some\"\n\t\t\t\t\t\t? optionalCV.value\n\t\t\t\t\t\t: optionalCV;\n\t\t\tconst vrfProof = bytesToHex(r.readBytes(VRF_PROOF_BYTES_LENGTH));\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.NakamotoCoinbase,\n\t\t\t\tcoinbaseBuffer,\n\t\t\t\trecipient,\n\t\t\t\tvrfProof,\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown payload type: ${payloadType}`);\n\t}\n}\n\nexport function deserializeTransaction(\n\tinput: string | Uint8Array,\n): StacksTransaction {\n\tconst bytes =\n\t\ttypeof input === \"string\" ? hexToBytes(without0x(input)) : input;\n\tconst r = new BytesReader(bytes);\n\n\treturn {\n\t\tversion: r.readUInt8(),\n\t\tchainId: r.readUInt32BE(),\n\t\tauth: readAuthorization(r),\n\t\tanchorMode: r.readUInt8() as AnchorMode,\n\t\tpostConditionMode: r.readUInt8() as PostConditionModeWire,\n\t\tpostConditions: readPostConditions(r),\n\t\tpayload: readPayload(r),\n\t};\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAuCA,SAAS,qBAAqB,CAAC,GAAmC;AAAA,EACjE,MAAM,WAAW,EAAE,UAAU;AAAA,EAC7B,MAAM,SAAS,WAAW,EAAE,UAAU,EAAE,CAAC;AAAA,EACzC,MAAM,QAAQ,EAAE,gBAAgB;AAAA,EAChC,MAAM,MAAM,EAAE,gBAAgB;AAAA,EAE9B,IACC,aAAa,gBAAgB,SAC7B,aAAa,gBAAgB,QAC5B;AAAA,IACD,MAAM,cAAc,EAAE,UAAU;AAAA,IAChC,MAAM,YAAY,WACjB,EAAE,UAAU,kCAAkC,CAC/C;AAAA,IACA,OAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM,aAAa,EAAE,aAAa;AAAA,EAClC,MAAM,SAAiC,CAAC;AAAA,EACxC,SAAS,IAAI,EAAG,IAAI,YAAY,KAAK;AAAA,IACpC,MAAM,YAAY,EAAE,UAAU;AAAA,IAC9B,IAAI,aAAa,GAAM;AAAA,MACtB,MAAM,SAAS,cAAc,IAAO,KAAK;AAAA,MACzC,OAAO,KAAK;AAAA,QACX,MAAM;AAAA,QACN,gBAAgB;AAAA,QAChB,MAAM,WAAW,EAAE,UAAU,MAAM,CAAC;AAAA,MACrC,CAAC;AAAA,IACF,EAAO;AAAA,MACN,OAAO,KAAK;AAAA,QACX,MAAM;AAAA,QACN,gBAAiB,cAAc,IAAO,IAAO;AAAA,QAC7C,MAAM,WAAW,EAAE,UAAU,kCAAkC,CAAC;AAAA,MACjE,CAAC;AAAA;AAAA,EAEH;AAAA,EACA,MAAM,qBAAqB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a;AAAA;AAAA;AAIlD,SAAS,sBAAsB,CACrC,OACoB;AAAA,EACpB,MAAM,QACL,OAAO,UAAU,WAAW,WAAW,UAAU,KAAK,CAAC,IAAI;AAAA,EAC5D,MAAM,IAAI,IAAI,YAAY,KAAK;AAAA,EAE/B,OAAO;AAAA,IACN,SAAS,EAAE,UAAU;AAAA,IACrB,SAAS,EAAE,aAAa;AAAA,IACxB,MAAM,kBAAkB,CAAC;AAAA,IACzB,YAAY,EAAE,UAAU;AAAA,IACxB,mBAAmB,EAAE,UAAU;AAAA,IAC/B,gBAAgB,mBAAmB,CAAC;AAAA,IACpC,SAAS,YAAY,CAAC;AAAA,EACvB;AAAA;",
|
|
8
|
+
"debugId": "986103D4B633E3BE64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callContract,
|
|
3
3
|
getMapEntry
|
|
4
|
-
} from "./stacks-
|
|
4
|
+
} from "./stacks-v150hffx.js";
|
|
5
5
|
import {
|
|
6
6
|
readContract
|
|
7
|
-
} from "./stacks-
|
|
7
|
+
} from "./stacks-msmgyerb.js";
|
|
8
|
+
import {
|
|
9
|
+
estimateFee,
|
|
10
|
+
resolveNonce
|
|
11
|
+
} from "./stacks-502j0efj.js";
|
|
8
12
|
import {
|
|
9
13
|
clarityValueToJSUntyped,
|
|
10
14
|
jsToClarityValue,
|
|
11
15
|
toCamelCase
|
|
12
|
-
} from "./stacks-
|
|
16
|
+
} from "./stacks-18jv9aen.js";
|
|
17
|
+
import {
|
|
18
|
+
buildContractCall
|
|
19
|
+
} from "./stacks-ssndnbbd.js";
|
|
20
|
+
import {
|
|
21
|
+
publicKeyToAddress
|
|
22
|
+
} from "./stacks-azp00pve.js";
|
|
13
23
|
|
|
14
24
|
// src/actions/getContract.ts
|
|
15
25
|
function getContract(params) {
|
|
@@ -75,6 +85,46 @@ function getContract(params) {
|
|
|
75
85
|
};
|
|
76
86
|
}
|
|
77
87
|
});
|
|
88
|
+
const buildCall = new Proxy({}, {
|
|
89
|
+
get(_target, prop) {
|
|
90
|
+
const fnName = camelToKebab.get(prop) ?? prop;
|
|
91
|
+
const fn = fnByName.get(fnName);
|
|
92
|
+
if (!fn || fn.access !== "public")
|
|
93
|
+
return;
|
|
94
|
+
return async (args, options) => {
|
|
95
|
+
const publicKey = options?.publicKey ?? client.account?.publicKey;
|
|
96
|
+
if (!publicKey) {
|
|
97
|
+
throw new Error("buildCall requires a publicKey (pass options.publicKey or configure a client account)");
|
|
98
|
+
}
|
|
99
|
+
const functionArgs = buildFunctionArgs(fn, args);
|
|
100
|
+
const network = client.chain?.network ?? "mainnet";
|
|
101
|
+
const nonce = options?.nonce ?? await resolveNonce(client, publicKeyToAddress(publicKey, network));
|
|
102
|
+
const unsigned = buildContractCall({
|
|
103
|
+
contractAddress: address,
|
|
104
|
+
contractName,
|
|
105
|
+
functionName: fn.name,
|
|
106
|
+
functionArgs,
|
|
107
|
+
fee: options?.fee ?? 0n,
|
|
108
|
+
nonce,
|
|
109
|
+
publicKey,
|
|
110
|
+
chain: client.chain,
|
|
111
|
+
postConditionMode: options?.postConditionMode,
|
|
112
|
+
postConditions: options?.postConditions,
|
|
113
|
+
sponsored: options?.sponsored
|
|
114
|
+
});
|
|
115
|
+
if (options?.fee === undefined) {
|
|
116
|
+
const estimates = await estimateFee(client, {
|
|
117
|
+
transaction: unsigned
|
|
118
|
+
});
|
|
119
|
+
const mid = estimates[1] ?? estimates[0];
|
|
120
|
+
if (mid) {
|
|
121
|
+
unsigned.auth.spendingCondition.fee = BigInt(mid.fee);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return unsigned;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
78
128
|
const maps = new Proxy({}, {
|
|
79
129
|
get(_target, prop) {
|
|
80
130
|
const mapName = camelToKebab.get(prop) ?? prop;
|
|
@@ -97,7 +147,13 @@ function getContract(params) {
|
|
|
97
147
|
};
|
|
98
148
|
}
|
|
99
149
|
});
|
|
100
|
-
return { read, call, maps };
|
|
150
|
+
return { read, call, buildCall, maps };
|
|
151
|
+
}
|
|
152
|
+
function resolveNetworkContract(client, contracts) {
|
|
153
|
+
if (!client.chain) {
|
|
154
|
+
throw new Error("Client must have a chain configured");
|
|
155
|
+
}
|
|
156
|
+
return contracts[client.chain.network];
|
|
101
157
|
}
|
|
102
158
|
function buildFunctionArgs(fn, args) {
|
|
103
159
|
return fn.args.map((arg) => {
|
|
@@ -130,7 +186,7 @@ class ContractResponseError extends Error {
|
|
|
130
186
|
}
|
|
131
187
|
}
|
|
132
188
|
|
|
133
|
-
export { getContract, ContractResponseError };
|
|
189
|
+
export { getContract, resolveNetworkContract, ContractResponseError };
|
|
134
190
|
|
|
135
|
-
//# debugId=
|
|
136
|
-
//# sourceMappingURL=stacks-
|
|
191
|
+
//# debugId=BBB428C76B76C91764756E2164756E21
|
|
192
|
+
//# sourceMappingURL=stacks-63xbc6cj.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 { PostCondition } 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 { estimateFee } from \"./public/estimateFee.ts\";\nimport { getMapEntry } from \"./public/getMapEntry.ts\";\nimport { readContract } from \"./public/readContract.ts\";\nimport { callContract } from \"./wallet/callContract.ts\";\nimport { resolveNonce } from \"./wallet/nonceManager.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 */\ntype 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\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]: (\n\t\targs: T[\"functions\"][K][\"args\"],\n\t) => Promise<UnwrapResponse<T[\"functions\"][K][\"ret\"]>>;\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]: (\n\t\targs: T[\"functions\"][K][\"args\"],\n\t\toptions?: ContractCallOptions,\n\t) => Promise<string>;\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>]: (\n\t\t\t\targs: ExtractFunctionArgs<C, N>,\n\t\t\t) => Promise<ReadMethodReturn<C, N>>;\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>]: (\n\t\t\t\targs: ExtractFunctionArgs<C, N>,\n\t\t\t\toptions?: ContractCallOptions,\n\t\t\t) => Promise<string>;\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?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\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; `fee`/`nonce` are resolved from the network when omitted.\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]: (\n\t\targs: T[\"functions\"][K][\"args\"],\n\t\toptions?: ContractBuildCallOptions,\n\t) => Promise<StacksTransaction>;\n};\n\ntype BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: (\n\t\t\t\targs: ExtractFunctionArgs<C, N>,\n\t\t\t\toptions?: ContractBuildCallOptions,\n\t\t\t) => Promise<StacksTransaction>;\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 resolveNonce(client, publicKeyToAddress(publicKey, network)));\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 estimates = await estimateFee(client, {\n\t\t\t\t\t\ttransaction: unsigned,\n\t\t\t\t\t});\n\t\t\t\t\tconst mid = estimates[1] ?? estimates[0];\n\t\t\t\t\tif (mid) {\n\t\t\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\t\t\t\t(unsigned.auth.spendingCondition as any).fee = BigInt(mid.fee);\n\t\t\t\t\t}\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\nfunction 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\nfunction 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": ";;;;;;;;;;;;;;;;;;;;;;;;AA4JO,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;AAAA,IAC/B,SAAS,IAAI,GAAG,MAAM,EAAiB;AAAA,EACxC;AAAA,EAEA,MAAM,YAAY,IAAI;AAAA,EACtB,IAAI,IAAI,MAAM;AAAA,IACb,WAAW,KAAK,IAAI,MAAM;AAAA,MACzB,UAAU,IAAI,EAAE,MAAM,CAAW;AAAA,IAClC;AAAA,EACD;AAAA,EAGA,MAAM,eAAe,IAAI;AAAA,EACzB,WAAW,MAAM,IAAI,WAAW;AAAA,IAC/B,aAAa,IAAI,YAAY,GAAG,IAAI,GAAG,GAAG,IAAI;AAAA,EAC/C;AAAA,EACA,IAAI,IAAI,MAAM;AAAA,IACb,WAAW,KAAK,IAAI,MAAM;AAAA,MACzB,aAAa,IAAI,YAAY,EAAE,IAAI,GAAG,EAAE,IAAI;AAAA,IAC7C;AAAA,EACD;AAAA,EAEA,MAAM,OAAO,IAAI,MAAM,CAAC,GAAwB;AAAA,IAC/C,GAAG,CAAC,SAAS,MAAc;AAAA,MAC1B,MAAM,SAAS,aAAa,IAAI,IAAI,KAAK;AAAA,MACzC,MAAM,KAAK,SAAS,IAAI,MAAM;AAAA,MAC9B,IAAI,CAAC,MAAM,GAAG,WAAW;AAAA,QAAa;AAAA,MAEtC,OAAO,OAAO,SAAkC;AAAA,QAC/C,MAAM,cAAc,kBA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SACgB,YACf;AAAA,IACD,MAAM,OAAO;AAAA,IAFG;AAAA;AAIlB;",
|
|
8
|
+
"debugId": "BBB428C76B76C91764756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Cl,
|
|
3
|
-
boolCV,
|
|
4
|
-
bufferCV,
|
|
5
|
-
intCV,
|
|
6
|
-
listCV,
|
|
7
|
-
noneCV,
|
|
8
|
-
responseErrorCV,
|
|
9
|
-
responseOkCV,
|
|
10
|
-
someCV,
|
|
11
|
-
stringAsciiCV,
|
|
12
|
-
stringUtf8CV,
|
|
13
|
-
tupleCV,
|
|
14
|
-
uintCV
|
|
15
|
-
} from "./stacks-0zysn74p.js";
|
|
16
|
-
import {
|
|
17
|
-
MAX_I128,
|
|
18
|
-
MAX_U128,
|
|
19
|
-
MIN_I128
|
|
20
|
-
} from "./stacks-v9jqcpd4.js";
|
|
21
|
-
import {
|
|
22
|
-
validateStacksAddress
|
|
23
|
-
} from "./stacks-6xmk24yw.js";
|
|
24
|
-
|
|
25
1
|
// src/clarity/abi/types.ts
|
|
26
2
|
var CONTRACT_NAME_REGEX = /^[a-zA-Z][a-zA-Z0-9\-]{0,127}$/;
|
|
27
3
|
|
|
@@ -129,7 +105,64 @@ function toCamelCase(str) {
|
|
|
129
105
|
}
|
|
130
106
|
|
|
131
107
|
// src/clarity/bridge.ts
|
|
108
|
+
var CV_TYPE_TAGS = new Set([
|
|
109
|
+
"int",
|
|
110
|
+
"uint",
|
|
111
|
+
"true",
|
|
112
|
+
"false",
|
|
113
|
+
"address",
|
|
114
|
+
"contract",
|
|
115
|
+
"ascii",
|
|
116
|
+
"utf8",
|
|
117
|
+
"buffer",
|
|
118
|
+
"list",
|
|
119
|
+
"tuple",
|
|
120
|
+
"none",
|
|
121
|
+
"some",
|
|
122
|
+
"ok",
|
|
123
|
+
"err"
|
|
124
|
+
]);
|
|
125
|
+
function isClarityValue(value) {
|
|
126
|
+
if (typeof value !== "object" || value === null)
|
|
127
|
+
return false;
|
|
128
|
+
const type = value.type;
|
|
129
|
+
if (typeof type !== "string" || !CV_TYPE_TAGS.has(type))
|
|
130
|
+
return false;
|
|
131
|
+
if (type === "true" || type === "false" || type === "none")
|
|
132
|
+
return true;
|
|
133
|
+
return "value" in value;
|
|
134
|
+
}
|
|
135
|
+
var HEX_PAIRS_REGEX = /^(?:[0-9a-fA-F]{2})+$/;
|
|
136
|
+
function coerceBuffer(value) {
|
|
137
|
+
if (value instanceof Uint8Array)
|
|
138
|
+
return bufferCV(value);
|
|
139
|
+
if (typeof value === "object" && value !== null && "type" in value) {
|
|
140
|
+
const tagged = value;
|
|
141
|
+
if (tagged.type === "buffer" && isClarityValue(value))
|
|
142
|
+
return value;
|
|
143
|
+
if (typeof tagged.value === "string") {
|
|
144
|
+
if (tagged.type === "ascii")
|
|
145
|
+
return Cl.bufferFromAscii(tagged.value);
|
|
146
|
+
if (tagged.type === "utf8")
|
|
147
|
+
return Cl.bufferFromUtf8(tagged.value);
|
|
148
|
+
if (tagged.type === "hex")
|
|
149
|
+
return Cl.bufferFromHex(tagged.value);
|
|
150
|
+
}
|
|
151
|
+
throw new Error(`Unsupported buffer input: ${JSON.stringify(value)}`);
|
|
152
|
+
}
|
|
153
|
+
if (typeof value === "string") {
|
|
154
|
+
const hex = value.startsWith("0x") ? value.slice(2) : value;
|
|
155
|
+
if (HEX_PAIRS_REGEX.test(hex))
|
|
156
|
+
return Cl.bufferFromHex(hex);
|
|
157
|
+
return Cl.bufferFromUtf8(value);
|
|
158
|
+
}
|
|
159
|
+
throw new Error("buffer arg expects Uint8Array, hex string, { type, value }, or BufferCV");
|
|
160
|
+
}
|
|
132
161
|
function jsToClarityValue(abiType, value) {
|
|
162
|
+
if (isAbiBuffer(abiType))
|
|
163
|
+
return coerceBuffer(value);
|
|
164
|
+
if (isClarityValue(value))
|
|
165
|
+
return value;
|
|
133
166
|
if (abiType === "uint128")
|
|
134
167
|
return uintCV(value);
|
|
135
168
|
if (abiType === "int128")
|
|
@@ -142,8 +175,6 @@ function jsToClarityValue(abiType, value) {
|
|
|
142
175
|
return stringAsciiCV(value);
|
|
143
176
|
if (isAbiStringUtf8(abiType))
|
|
144
177
|
return stringUtf8CV(value);
|
|
145
|
-
if (isAbiBuffer(abiType))
|
|
146
|
-
return bufferCV(value);
|
|
147
178
|
if (isAbiList(abiType)) {
|
|
148
179
|
const arr = value;
|
|
149
180
|
return listCV(arr.map((item) => jsToClarityValue(abiType.list.type, item)));
|
|
@@ -252,7 +283,5 @@ function clarityValueToJSInner(abiType, cv) {
|
|
|
252
283
|
throw new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);
|
|
253
284
|
}
|
|
254
285
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
//# debugId=295B2BA1DC85445964756E2164756E21
|
|
258
|
-
//# sourceMappingURL=stacks-g7ffp8aj.js.map
|
|
286
|
+
//# debugId=234B58D453D798AA64756E2164756E21
|
|
287
|
+
//# sourceMappingURL=stacks-6xt8py97.cjs.map
|