@secondlayer/stacks 6.5.4 → 6.6.1
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-esm-17adzt3x.js → stacks-esm-0t9vwtwh.js} +9 -9
- package/dist/shared/{stacks-esm-s3natb0x.js → stacks-esm-1f46cr7b.js} +8 -8
- package/dist/shared/{stacks-esm-s3natb0x.js.map → stacks-esm-1f46cr7b.js.map} +3 -3
- package/dist/shared/{stacks-esm-2cac1jn9.js → stacks-esm-2z40q8gs.js} +4 -4
- package/dist/shared/{stacks-esm-ev07d2aw.js → stacks-esm-4rjjsz3p.js} +3 -3
- package/dist/shared/{stacks-esm-5eq7meyt.js → stacks-esm-8p8xy3dz.js} +16 -4
- package/dist/shared/stacks-esm-8p8xy3dz.js.map +12 -0
- package/dist/shared/{stacks-esm-h82jj95c.js → stacks-esm-9ptct1c4.js} +3 -3
- package/dist/shared/{stacks-esm-qasbsv66.js → stacks-esm-a7apmjbk.js} +2 -2
- package/dist/shared/{stacks-esm-1nfzrepv.js → stacks-esm-brtqryjb.js} +4 -4
- package/dist/shared/{stacks-esm-pc20c78w.js → stacks-esm-e63kx7dq.js} +3 -3
- package/dist/shared/{stacks-esm-tsb8h0yr.js → stacks-esm-eep45e8s.js} +2 -2
- package/dist/shared/{stacks-esm-wnxhfx93.js → stacks-esm-fmq4j4ez.js} +2 -2
- package/dist/shared/{stacks-esm-7tc40d6t.js → stacks-esm-h60faj2n.js} +2 -2
- package/dist/shared/{stacks-esm-6zfssx7v.js → stacks-esm-hcaycch3.js} +3 -3
- package/dist/shared/{stacks-esm-cs4419br.js → stacks-esm-jwgtksgq.js} +32 -15
- package/dist/shared/stacks-esm-jwgtksgq.js.map +15 -0
- package/dist/shared/{stacks-esm-jm688fhe.js → stacks-esm-m8ph0bvw.js} +19 -11
- package/dist/shared/{stacks-esm-jm688fhe.js.map → stacks-esm-m8ph0bvw.js.map} +4 -4
- package/dist/shared/{stacks-esm-hm7kb2cp.js → stacks-esm-mqhwqhq4.js} +4 -4
- package/dist/shared/{stacks-esm-tfechw5c.js → stacks-esm-nqkwt2z7.js} +2 -2
- package/dist/shared/{stacks-esm-mmvrwreq.js → stacks-esm-wjg9aer9.js} +4 -4
- package/dist/shared/{stacks-esm-scq242d9.js → stacks-esm-zsdw7fq3.js} +3 -3
- package/dist/src/accounts/index.cjs +14 -2
- package/dist/src/accounts/index.cjs.map +3 -3
- package/dist/src/accounts/index.js +2 -2
- package/dist/src/actions/index.cjs +52 -16
- package/dist/src/actions/index.cjs.map +8 -8
- package/dist/src/actions/index.d.cts +2 -0
- package/dist/src/actions/index.d.ts +2 -0
- package/dist/src/actions/index.js +12 -12
- package/dist/src/bitcoin/index.cjs +41 -13
- package/dist/src/bitcoin/index.cjs.map +5 -5
- package/dist/src/bitcoin/index.js +10 -10
- package/dist/src/bns/index.cjs +52 -16
- package/dist/src/bns/index.cjs.map +8 -8
- package/dist/src/bns/index.js +12 -12
- package/dist/src/clarity/index.cjs +41 -13
- package/dist/src/clarity/index.cjs.map +5 -5
- package/dist/src/clarity/index.js +6 -6
- package/dist/src/connect/index.cjs +30 -7
- package/dist/src/connect/index.cjs.map +5 -5
- package/dist/src/connect/index.js +30 -7
- package/dist/src/connect/index.js.map +5 -5
- package/dist/src/connect/walletconnect/index.cjs +3 -1
- package/dist/src/connect/walletconnect/index.cjs.map +3 -3
- package/dist/src/connect/walletconnect/index.js +3 -1
- package/dist/src/connect/walletconnect/index.js.map +3 -3
- package/dist/src/filters/index.cjs +14 -2
- package/dist/src/filters/index.cjs.map +3 -3
- package/dist/src/filters/index.js +3 -3
- package/dist/src/index.cjs +75 -20
- package/dist/src/index.cjs.map +9 -9
- package/dist/src/index.d.cts +8 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +40 -14
- package/dist/src/index.js.map +4 -4
- package/dist/src/postconditions/index.cjs +41 -13
- package/dist/src/postconditions/index.cjs.map +5 -5
- package/dist/src/postconditions/index.js +5 -5
- package/dist/src/pox/index.cjs +52 -16
- package/dist/src/pox/index.cjs.map +8 -8
- package/dist/src/pox/index.js +12 -12
- package/dist/src/pox5/index.cjs +52 -16
- package/dist/src/pox5/index.cjs.map +8 -8
- package/dist/src/pox5/index.js +14 -14
- package/dist/src/sbtc/index.cjs +52 -16
- package/dist/src/sbtc/index.cjs.map +8 -8
- package/dist/src/sbtc/index.js +12 -12
- package/dist/src/simnet/index.cjs +44 -16
- package/dist/src/simnet/index.cjs.map +5 -5
- package/dist/src/simnet/index.js +44 -16
- package/dist/src/simnet/index.js.map +5 -5
- package/dist/src/stackingdao/index.cjs +52 -16
- package/dist/src/stackingdao/index.cjs.map +8 -8
- package/dist/src/stackingdao/index.js +10 -10
- package/dist/src/transactions/index.cjs +44 -16
- package/dist/src/transactions/index.cjs.map +5 -5
- package/dist/src/transactions/index.js +5 -5
- package/dist/src/utils/index.cjs +20 -3
- package/dist/src/utils/index.cjs.map +4 -4
- package/dist/src/utils/index.d.cts +8 -1
- package/dist/src/utils/index.d.ts +8 -1
- package/dist/src/utils/index.js +9 -4
- package/dist/src/utils/index.js.map +3 -3
- package/package.json +2 -2
- package/dist/shared/stacks-esm-5eq7meyt.js.map +0 -12
- package/dist/shared/stacks-esm-cs4419br.js.map +0 -15
- /package/dist/shared/{stacks-esm-17adzt3x.js.map → stacks-esm-0t9vwtwh.js.map} +0 -0
- /package/dist/shared/{stacks-esm-2cac1jn9.js.map → stacks-esm-2z40q8gs.js.map} +0 -0
- /package/dist/shared/{stacks-esm-ev07d2aw.js.map → stacks-esm-4rjjsz3p.js.map} +0 -0
- /package/dist/shared/{stacks-esm-h82jj95c.js.map → stacks-esm-9ptct1c4.js.map} +0 -0
- /package/dist/shared/{stacks-esm-qasbsv66.js.map → stacks-esm-a7apmjbk.js.map} +0 -0
- /package/dist/shared/{stacks-esm-1nfzrepv.js.map → stacks-esm-brtqryjb.js.map} +0 -0
- /package/dist/shared/{stacks-esm-pc20c78w.js.map → stacks-esm-e63kx7dq.js.map} +0 -0
- /package/dist/shared/{stacks-esm-tsb8h0yr.js.map → stacks-esm-eep45e8s.js.map} +0 -0
- /package/dist/shared/{stacks-esm-wnxhfx93.js.map → stacks-esm-fmq4j4ez.js.map} +0 -0
- /package/dist/shared/{stacks-esm-7tc40d6t.js.map → stacks-esm-h60faj2n.js.map} +0 -0
- /package/dist/shared/{stacks-esm-6zfssx7v.js.map → stacks-esm-hcaycch3.js.map} +0 -0
- /package/dist/shared/{stacks-esm-hm7kb2cp.js.map → stacks-esm-mqhwqhq4.js.map} +0 -0
- /package/dist/shared/{stacks-esm-tfechw5c.js.map → stacks-esm-nqkwt2z7.js.map} +0 -0
- /package/dist/shared/{stacks-esm-mmvrwreq.js.map → stacks-esm-wjg9aer9.js.map} +0 -0
- /package/dist/shared/{stacks-esm-scq242d9.js.map → stacks-esm-zsdw7fq3.js.map} +0 -0
|
@@ -3,24 +3,24 @@ import {
|
|
|
3
3
|
with0x2,
|
|
4
4
|
intToBigInt2,
|
|
5
5
|
c32address2
|
|
6
|
-
} from "./stacks-esm-
|
|
6
|
+
} from "./stacks-esm-8p8xy3dz.js";
|
|
7
7
|
import {
|
|
8
8
|
validateStacksAddress2,
|
|
9
9
|
parseContractId2,
|
|
10
10
|
isClarityName2
|
|
11
|
-
} from "./stacks-esm-
|
|
11
|
+
} from "./stacks-esm-h60faj2n.js";
|
|
12
12
|
import {
|
|
13
13
|
serializeCVBytes2,
|
|
14
14
|
Cl2,
|
|
15
15
|
deserializeCVBytes2
|
|
16
|
-
} from "./stacks-esm-
|
|
16
|
+
} from "./stacks-esm-jwgtksgq.js";
|
|
17
17
|
import {
|
|
18
18
|
AuthType2,
|
|
19
19
|
PayloadType2,
|
|
20
20
|
AddressHashMode2,
|
|
21
21
|
serializeTransactionHex2,
|
|
22
22
|
deserializeTransaction2
|
|
23
|
-
} from "./stacks-esm-
|
|
23
|
+
} from "./stacks-esm-2z40q8gs.js";
|
|
24
24
|
import {
|
|
25
25
|
createSingleSigSpendingCondition2,
|
|
26
26
|
signMultiSigWithAccount2,
|
|
@@ -28,10 +28,10 @@ import {
|
|
|
28
28
|
buildContractDeploy2,
|
|
29
29
|
signTransactionWithAccount2,
|
|
30
30
|
signSponsorWithAccount2
|
|
31
|
-
} from "./stacks-esm-
|
|
31
|
+
} from "./stacks-esm-wjg9aer9.js";
|
|
32
32
|
import {
|
|
33
33
|
structuredDataHash2
|
|
34
|
-
} from "./stacks-esm-
|
|
34
|
+
} from "./stacks-esm-zsdw7fq3.js";
|
|
35
35
|
import {
|
|
36
36
|
estimateFee2,
|
|
37
37
|
HttpRequestError2,
|
|
@@ -43,10 +43,10 @@ import {
|
|
|
43
43
|
resolveFee2,
|
|
44
44
|
setUnsignedFee,
|
|
45
45
|
assertNoFeeTierForProvider
|
|
46
|
-
} from "./stacks-esm-
|
|
46
|
+
} from "./stacks-esm-m8ph0bvw.js";
|
|
47
47
|
import {
|
|
48
48
|
MalformedResponseError2
|
|
49
|
-
} from "./stacks-esm-
|
|
49
|
+
} from "./stacks-esm-mqhwqhq4.js";
|
|
50
50
|
import {
|
|
51
51
|
BaseError2
|
|
52
52
|
} from "./stacks-esm-7v18h5dk.js";
|
|
@@ -388,4 +388,4 @@ async function transferStx2(client, params) {
|
|
|
388
388
|
export { getAccountHistory2, getAccountInfo2, getBlock2, getContractAbi2, getContractSource2, getMempoolStats2, getNftHoldings2, getRawBlock2, SimulationError2, simulateCall2, simulateTransaction2, deployContract2, signMessage2, signTransactionAction2, sponsorTransaction2, transferStx2 };
|
|
389
389
|
|
|
390
390
|
//# debugId=A9516B8833B4AB8564756E2164756E21
|
|
391
|
-
//# sourceMappingURL=stacks-esm-
|
|
391
|
+
//# sourceMappingURL=stacks-esm-0t9vwtwh.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
publicKeyToAddress2
|
|
3
|
-
} from "./stacks-esm-
|
|
3
|
+
} from "./stacks-esm-h60faj2n.js";
|
|
4
4
|
import {
|
|
5
5
|
toCamelCase2,
|
|
6
6
|
jsToClarityValue2,
|
|
7
7
|
clarityValueToJSUntyped2
|
|
8
|
-
} from "./stacks-esm-
|
|
8
|
+
} from "./stacks-esm-4rjjsz3p.js";
|
|
9
9
|
import {
|
|
10
10
|
buildContractCall2
|
|
11
|
-
} from "./stacks-esm-
|
|
11
|
+
} from "./stacks-esm-wjg9aer9.js";
|
|
12
12
|
import {
|
|
13
13
|
getMapEntry2,
|
|
14
14
|
getNonce2,
|
|
15
15
|
resolveFee2,
|
|
16
16
|
setUnsignedFee,
|
|
17
17
|
callContract2
|
|
18
|
-
} from "./stacks-esm-
|
|
18
|
+
} from "./stacks-esm-m8ph0bvw.js";
|
|
19
19
|
import {
|
|
20
20
|
readContract2
|
|
21
|
-
} from "./stacks-esm-
|
|
21
|
+
} from "./stacks-esm-mqhwqhq4.js";
|
|
22
22
|
|
|
23
23
|
// src/actions/getContract.ts
|
|
24
24
|
function getContract2(params) {
|
|
@@ -78,7 +78,7 @@ function getContract2(params) {
|
|
|
78
78
|
return callContract2(client, {
|
|
79
79
|
contract: contractId,
|
|
80
80
|
functionName: fn.name,
|
|
81
|
-
|
|
81
|
+
args: clarityArgs,
|
|
82
82
|
...options
|
|
83
83
|
});
|
|
84
84
|
};
|
|
@@ -184,5 +184,5 @@ class ContractResponseError2 extends Error {
|
|
|
184
184
|
|
|
185
185
|
export { getContract2, resolveNetworkContract, buildFunctionArgs2, isResponseOutput2, ContractResponseError2 };
|
|
186
186
|
|
|
187
|
-
//# debugId=
|
|
188
|
-
//# sourceMappingURL=stacks-esm-
|
|
187
|
+
//# debugId=DF58331E045DE08F64756E2164756E21
|
|
188
|
+
//# sourceMappingURL=stacks-esm-1f46cr7b.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/actions/getContract.ts"],
|
|
4
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"
|
|
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\targs: 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
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AA4LO,SAAS,YAA2C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,IAAI,MAAiB,KAAK;AAAA,GAClD;AAAA;AAIK,SAAS,iBAAgB,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,+BAA8B,MAAM;AAAA,EAI/B;AAAA,EAHR,OAAO;AAAA,EAChB,WAAW,CACV,SACgB,YACf;AAAA,IACD,MAAM,OAAO;AAAA,IAFG;AAAA;AAIlB;",
|
|
8
|
+
"debugId": "DF58331E045DE08F64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -13,17 +13,17 @@ import {
|
|
|
13
13
|
writeUInt16BE2,
|
|
14
14
|
writeUInt82,
|
|
15
15
|
c32addressDecode2
|
|
16
|
-
} from "./stacks-esm-
|
|
16
|
+
} from "./stacks-esm-8p8xy3dz.js";
|
|
17
17
|
import {
|
|
18
18
|
serializeCVBytes2,
|
|
19
19
|
BytesReader,
|
|
20
20
|
readAddress,
|
|
21
21
|
readLPString,
|
|
22
22
|
readCV
|
|
23
|
-
} from "./stacks-esm-
|
|
23
|
+
} from "./stacks-esm-jwgtksgq.js";
|
|
24
24
|
import {
|
|
25
25
|
parseContractId2
|
|
26
|
-
} from "./stacks-esm-
|
|
26
|
+
} from "./stacks-esm-h60faj2n.js";
|
|
27
27
|
|
|
28
28
|
// src/transactions/types.ts
|
|
29
29
|
var AuthType2 = {
|
|
@@ -768,4 +768,4 @@ function postConditionToHex2(pc) {
|
|
|
768
768
|
export { AuthType2, PayloadType2, ClarityVersion2, AnchorMode2, PostConditionModeWire2, AddressHashMode2, PubKeyEncoding2, FungibleConditionCode2, NonFungibleConditionCode2, PoxConditionCode2, PostConditionPrincipalId2, AssetType2, AuthFieldType2, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES2, MEMO_MAX_LENGTH_BYTES2, MAX_STRING_LENGTH_BYTES2, COINBASE_BYTES_LENGTH2, VRF_PROOF_BYTES_LENGTH2, MICROBLOCK_HEADER_BYTES_LENGTH2, TenureChangeCause2, serializePostConditionWire2, serializePayload, clearTxCache, serializeTransaction2, serializeTransactionHex2, deserializePostConditionWire2, deserializeTransaction2, splitTransactions2, parsePostConditionAmount2, convertPostCondition, wireToPostCondition2, fromHex2, postConditionToHex2 };
|
|
769
769
|
|
|
770
770
|
//# debugId=F2ACA1329F82CAF264756E2164756E21
|
|
771
|
-
//# sourceMappingURL=stacks-esm-
|
|
771
|
+
//# sourceMappingURL=stacks-esm-2z40q8gs.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
MAX_I1282,
|
|
4
4
|
MIN_I1282,
|
|
5
5
|
parsePrincipal2
|
|
6
|
-
} from "./stacks-esm-
|
|
6
|
+
} from "./stacks-esm-h60faj2n.js";
|
|
7
7
|
import {
|
|
8
8
|
intCV2,
|
|
9
9
|
uintCV2,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
stringAsciiCV2,
|
|
19
19
|
stringUtf8CV2,
|
|
20
20
|
Cl2
|
|
21
|
-
} from "./stacks-esm-
|
|
21
|
+
} from "./stacks-esm-jwgtksgq.js";
|
|
22
22
|
// src/clarity/abi/guards.ts
|
|
23
23
|
function isUint1282(value) {
|
|
24
24
|
return typeof value === "bigint" && value >= 0n && value <= MAX_U1282;
|
|
@@ -287,4 +287,4 @@ function clarityValueToJSInner(abiType, cv) {
|
|
|
287
287
|
export { isUint1282, isInt1282, isBool2, isPrincipal3, isStandardPrincipal2, isContractPrincipal2, isTraitReference2, isString2, isUint8Array2, isArray2, isOptional2, isOkResponse2, isErrResponse2, isResponse2, isAbiList2, isAbiTuple2, isAbiOptional2, isAbiResponse2, isAbiBuffer2, isAbiStringAscii2, isAbiStringUtf82, isAbiTraitReference2, toCamelCase2, isClarityValue2, jsToClarityValue2, clarityValueToJS2, clarityValueToJSUntyped2 };
|
|
288
288
|
|
|
289
289
|
//# debugId=24A34C3ABD1FC51B64756E2164756E21
|
|
290
|
-
//# sourceMappingURL=stacks-esm-
|
|
290
|
+
//# sourceMappingURL=stacks-esm-4rjjsz3p.js.map
|
|
@@ -12,6 +12,8 @@ function bytesToHex2(bytes) {
|
|
|
12
12
|
}
|
|
13
13
|
function hexToBytes2(hex) {
|
|
14
14
|
let h = without0x2(hex);
|
|
15
|
+
if (!/^[0-9a-fA-F]*$/.test(h))
|
|
16
|
+
throw new Error("Invalid byte sequence");
|
|
15
17
|
if (h.length % 2)
|
|
16
18
|
h = `0${h}`;
|
|
17
19
|
const array = new Uint8Array(h.length / 2);
|
|
@@ -43,6 +45,13 @@ function asciiToBytes2(str) {
|
|
|
43
45
|
}
|
|
44
46
|
return bytes;
|
|
45
47
|
}
|
|
48
|
+
function isAscii(str) {
|
|
49
|
+
for (let i = 0;i < str.length; i++) {
|
|
50
|
+
if (str.charCodeAt(i) > 127)
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
46
55
|
function bytesToAscii2(bytes) {
|
|
47
56
|
return String.fromCharCode(...bytes);
|
|
48
57
|
}
|
|
@@ -61,8 +70,11 @@ function concatBytes2(...arrays) {
|
|
|
61
70
|
function intToBigInt2(value) {
|
|
62
71
|
if (typeof value === "bigint")
|
|
63
72
|
return value;
|
|
64
|
-
if (typeof value === "string")
|
|
73
|
+
if (typeof value === "string") {
|
|
74
|
+
if (value.trim() === "")
|
|
75
|
+
throw new SyntaxError("Cannot convert an empty string to an integer");
|
|
65
76
|
return BigInt(value);
|
|
77
|
+
}
|
|
66
78
|
if (typeof value === "number") {
|
|
67
79
|
if (!Number.isInteger(value))
|
|
68
80
|
throw new RangeError("Values of type 'number' must be an integer.");
|
|
@@ -259,7 +271,7 @@ function hashP2PKH2(input) {
|
|
|
259
271
|
return bytesToHex2(hash1602(input));
|
|
260
272
|
}
|
|
261
273
|
|
|
262
|
-
export { bytesToHex2, hexToBytes2, with0x2, without0x2, utf8ToBytes2, bytesToUtf82, asciiToBytes2, bytesToAscii2, concatBytes2, intToBigInt2, intToBytes2, bigIntToBytes2, intToHex2, toTwos2, fromTwos2, bytesToTwosBigInt2, writeUInt32BE2, readUInt32BE2, writeUInt16BE2, readUInt16BE2, writeUInt82, c32address2, c32addressDecode2, ripemd1602, sha2562, sha512_2562, hash1602, txidFromBytes2, hashP2PKH2 };
|
|
274
|
+
export { bytesToHex2, hexToBytes2, with0x2, without0x2, utf8ToBytes2, bytesToUtf82, asciiToBytes2, isAscii, bytesToAscii2, concatBytes2, intToBigInt2, intToBytes2, bigIntToBytes2, intToHex2, toTwos2, fromTwos2, bytesToTwosBigInt2, writeUInt32BE2, readUInt32BE2, writeUInt16BE2, readUInt16BE2, writeUInt82, c32address2, c32addressDecode2, ripemd1602, sha2562, sha512_2562, hash1602, txidFromBytes2, hashP2PKH2 };
|
|
263
275
|
|
|
264
|
-
//# debugId=
|
|
265
|
-
//# sourceMappingURL=stacks-esm-
|
|
276
|
+
//# debugId=23A2D2F37D9007B964756E2164756E21
|
|
277
|
+
//# sourceMappingURL=stacks-esm-8p8xy3dz.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils/c32.ts", "../src/utils/encoding.ts", "../src/utils/hash.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bytesToHex, hexToBytes } from \"./encoding.ts\";\n\nconst C32 = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst HEX = \"0123456789abcdef\";\n\nfunction c32normalize(input: string): string {\n\treturn input.toUpperCase().replace(/O/g, \"0\").replace(/L|I/g, \"1\");\n}\n\nfunction c32encode(inputHex: string): string {\n\tlet hex = inputHex;\n\tif (hex.length % 2 !== 0) hex = `0${hex}`;\n\thex = hex.toLowerCase();\n\n\tconst res: string[] = [];\n\tlet carry = 0;\n\tfor (let i = hex.length - 1; i >= 0; i--) {\n\t\tif (carry < 4) {\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tconst currentCode = HEX.indexOf(hex[i]!) >> carry;\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tconst nextCode = i !== 0 ? HEX.indexOf(hex[i - 1]!) : 0;\n\t\t\tconst nextBits = 1 + carry;\n\t\t\tconst nextLowBits = (nextCode % (1 << nextBits)) << (5 - nextBits);\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tres.unshift(C32[currentCode + nextLowBits]!);\n\t\t\tcarry = nextBits;\n\t\t} else {\n\t\t\tcarry = 0;\n\t\t}\n\t}\n\n\t// Strip leading c32 zeros\n\tlet leadingZeros = 0;\n\twhile (leadingZeros < res.length && res[leadingZeros] === \"0\") leadingZeros++;\n\tconst stripped = res.slice(leadingZeros);\n\n\t// Preserve leading zero bytes from hex\n\tconst bytes = hexToBytes(hex);\n\tlet zeroBytesCount = 0;\n\twhile (zeroBytesCount < bytes.length && bytes[zeroBytesCount] === 0)\n\t\tzeroBytesCount++;\n\tconst prefix = Array(zeroBytesCount).fill(C32[0]) as string[];\n\n\treturn [...prefix, ...stripped].join(\"\");\n}\n\nfunction c32decode(c32input: string): string {\n\tconst input = c32normalize(c32input);\n\tif (!input.match(`^[${C32}]*$`)) throw new Error(\"Not a c32-encoded string\");\n\n\tconst zeroPrefix = input.match(`^${C32[0]}*`);\n\tconst numLeadingZeroBytes = zeroPrefix ? zeroPrefix[0]?.length : 0;\n\n\tconst res: string[] = [];\n\tlet carry = 0;\n\tlet carryBits = 0;\n\tfor (let i = input.length - 1; i >= 0; i--) {\n\t\tif (carryBits === 4) {\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tres.unshift(HEX[carry]!);\n\t\t\tcarryBits = 0;\n\t\t\tcarry = 0;\n\t\t}\n\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\tconst currentValue = (C32.indexOf(input[i]!) << carryBits) + carry;\n\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\tres.unshift(HEX[currentValue % 16]!);\n\t\tcarryBits += 1;\n\t\tcarry = currentValue >> 4;\n\t\tif (carry > 1 << carryBits) throw new Error(\"Panic error in c32 decoding\");\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\tres.unshift(HEX[carry]!);\n\n\tif (res.length % 2 === 1) res.unshift(\"0\");\n\n\t// Strip leading hex zeros\n\tlet hexLeadingZeros = 0;\n\twhile (hexLeadingZeros < res.length && res[hexLeadingZeros] === \"0\")\n\t\thexLeadingZeros++;\n\tlet hexStr = res.slice(hexLeadingZeros - (hexLeadingZeros % 2)).join(\"\");\n\n\tfor (let i = 0; i < numLeadingZeroBytes; i++) hexStr = `00${hexStr}`;\n\n\treturn hexStr;\n}\n\nfunction c32checksum(dataHex: string): string {\n\treturn bytesToHex(sha256(sha256(hexToBytes(dataHex))).slice(0, 4));\n}\n\nfunction c32checkEncode(version: number, data: string): string {\n\tif (version < 0 || version >= 32)\n\t\tthrow new Error(\"Invalid version (must be between 0 and 31)\");\n\tif (!data.match(/^[0-9a-fA-F]*$/))\n\t\tthrow new Error(\"Invalid data (not a hex string)\");\n\n\tlet d = data.toLowerCase();\n\tif (d.length % 2 !== 0) d = `0${d}`;\n\n\tlet versionHex = version.toString(16);\n\tif (versionHex.length === 1) versionHex = `0${versionHex}`;\n\n\tconst checksumHex = c32checksum(`${versionHex}${d}`);\n\treturn `${C32[version]}${c32encode(`${d}${checksumHex}`)}`;\n}\n\nfunction c32checkDecode(c32data: string): [number, string] {\n\tconst normalized = c32normalize(c32data);\n\tconst dataHex = c32decode(normalized.slice(1));\n\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\tconst version = C32.indexOf(normalized[0]!);\n\tconst checksum = dataHex.slice(-8);\n\n\tlet versionHex = version.toString(16);\n\tif (versionHex.length === 1) versionHex = `0${versionHex}`;\n\n\tif (\n\t\tc32checksum(`${versionHex}${dataHex.substring(0, dataHex.length - 8)}`) !==\n\t\tchecksum\n\t) {\n\t\tthrow new Error(\"Invalid c32check string: checksum mismatch\");\n\t}\n\n\treturn [version, dataHex.substring(0, dataHex.length - 8)];\n}\n\nexport function c32address(version: number, hash160hex: string): string {\n\tif (!hash160hex.match(/^[0-9a-fA-F]{40}$/)) {\n\t\tthrow new Error(\"Invalid argument: not a hash160 hex string\");\n\t}\n\treturn `S${c32checkEncode(version, hash160hex)}`;\n}\n\nexport function c32addressDecode(c32addr: string): [number, string] {\n\tif (c32addr.length <= 5)\n\t\tthrow new Error(\"Invalid c32 address: invalid length\");\n\tif (c32addr[0] !== \"S\")\n\t\tthrow new Error('Invalid c32 address: must start with \"S\"');\n\treturn c32checkDecode(c32addr.slice(1));\n}\n",
|
|
6
|
+
"const hexes = Array.from({ length: 256 }, (_, i) =>\n\ti.toString(16).padStart(2, \"0\"),\n);\n\nexport function bytesToHex(bytes: Uint8Array): string {\n\tlet hex = \"\";\n\tfor (const b of bytes) {\n\t\thex += hexes[b];\n\t}\n\treturn hex;\n}\n\nexport function hexToBytes(hex: string): Uint8Array {\n\tlet h = without0x(hex);\n\t// parseInt reads \"1g\" as 1, so the whole string is checked first.\n\tif (!/^[0-9a-fA-F]*$/.test(h)) throw new Error(\"Invalid byte sequence\");\n\tif (h.length % 2) h = `0${h}`;\n\n\tconst array = new Uint8Array(h.length / 2);\n\tfor (let i = 0; i < array.length; i++) {\n\t\tconst j = i * 2;\n\t\tconst byte = Number.parseInt(h.slice(j, j + 2), 16);\n\t\tif (Number.isNaN(byte) || byte < 0)\n\t\t\tthrow new Error(\"Invalid byte sequence\");\n\t\tarray[i] = byte;\n\t}\n\treturn array;\n}\n\nexport function with0x(value: string): string {\n\treturn /^0x/i.test(value) ? value : `0x${value}`;\n}\n\nexport function without0x(value: string): string {\n\treturn /^0x/i.test(value) ? value.slice(2) : value;\n}\n\nexport function utf8ToBytes(str: string): Uint8Array {\n\treturn new TextEncoder().encode(str);\n}\n\nexport function bytesToUtf8(bytes: Uint8Array): string {\n\treturn new TextDecoder().decode(bytes);\n}\n\nexport function asciiToBytes(str: string): Uint8Array {\n\tconst bytes = new Uint8Array(str.length);\n\tfor (let i = 0; i < str.length; i++) {\n\t\tbytes[i] = str.charCodeAt(i) & 0xff;\n\t}\n\treturn bytes;\n}\n\n/** Whether every character is 7-bit ASCII. */\nexport function isAscii(str: string): boolean {\n\tfor (let i = 0; i < str.length; i++) {\n\t\tif (str.charCodeAt(i) > 0x7f) return false;\n\t}\n\treturn true;\n}\n\nexport function bytesToAscii(bytes: Uint8Array): string {\n\treturn String.fromCharCode(...bytes);\n}\n\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\tif (arrays.length === 1) return arrays[0]!;\n\tconst length = arrays.reduce((a, arr) => a + arr.length, 0);\n\tconst result = new Uint8Array(length);\n\tlet pad = 0;\n\tfor (const arr of arrays) {\n\t\tresult.set(arr, pad);\n\t\tpad += arr.length;\n\t}\n\treturn result;\n}\n\nexport type IntegerType = number | string | bigint | Uint8Array;\n\nexport function intToBigInt(value: IntegerType): bigint {\n\tif (typeof value === \"bigint\") return value;\n\tif (typeof value === \"string\") {\n\t\t// BigInt(\"\") is 0n; an empty or blank string is not a number.\n\t\tif (value.trim() === \"\")\n\t\t\tthrow new SyntaxError(\"Cannot convert an empty string to an integer\");\n\t\treturn BigInt(value);\n\t}\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isInteger(value))\n\t\t\tthrow new RangeError(\"Values of type 'number' must be an integer.\");\n\t\tif (value > Number.MAX_SAFE_INTEGER)\n\t\t\tthrow new RangeError(\n\t\t\t\t`Values of type 'number' must be <= ${Number.MAX_SAFE_INTEGER}. Use BigInt instead.`,\n\t\t\t);\n\t\treturn BigInt(value);\n\t}\n\tif (value instanceof Uint8Array) return BigInt(`0x${bytesToHex(value)}`);\n\tthrow new TypeError(\"Must be a number, bigint, string, or Uint8Array.\");\n}\n\nexport function intToBytes(value: IntegerType, byteLength: number): Uint8Array {\n\treturn bigIntToBytes(intToBigInt(value), byteLength);\n}\n\nexport function bigIntToBytes(value: bigint, length = 16): Uint8Array {\n\tconst hex = value.toString(16).padStart(length * 2, \"0\");\n\treturn hexToBytes(hex);\n}\n\nexport function intToHex(integer: IntegerType, byteLength = 8): string {\n\tconst value = typeof integer === \"bigint\" ? integer : intToBigInt(integer);\n\treturn value.toString(16).padStart(byteLength * 2, \"0\");\n}\n\nexport function toTwos(value: bigint, width: bigint): bigint {\n\tconst limit = BigInt(1) << (width - BigInt(1));\n\tif (value < -limit || value > limit - BigInt(1)) {\n\t\tthrow new Error(`Unable to represent integer in width: ${width}`);\n\t}\n\tif (value >= BigInt(0)) return value;\n\treturn value + (BigInt(1) << width);\n}\n\nexport function fromTwos(value: bigint, width: bigint): bigint {\n\tif (value & (BigInt(1) << (width - BigInt(1)))) {\n\t\treturn value - (BigInt(1) << width);\n\t}\n\treturn value;\n}\n\nexport function bytesToTwosBigInt(bytes: Uint8Array): bigint {\n\tif (bytes.length === 0) return 0n;\n\tconst hex = bytesToHex(bytes);\n\tif (hex.length === 0) return 0n;\n\treturn fromTwos(BigInt(`0x${hex}`), BigInt(bytes.byteLength * 8));\n}\n\nexport function writeUInt32BE(value: number): Uint8Array {\n\tconst buf = new Uint8Array(4);\n\tbuf[0] = (value >>> 24) & 0xff;\n\tbuf[1] = (value >>> 16) & 0xff;\n\tbuf[2] = (value >>> 8) & 0xff;\n\tbuf[3] = value & 0xff;\n\treturn buf;\n}\n\nexport function readUInt32BE(bytes: Uint8Array, offset = 0): number {\n\treturn (\n\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t((bytes[offset]! << 24) |\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\t(bytes[offset + 1]! << 16) |\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\t(bytes[offset + 2]! << 8) |\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tbytes[offset + 3]!) >>>\n\t\t0\n\t);\n}\n\nexport function writeUInt16BE(value: number): Uint8Array {\n\tconst buf = new Uint8Array(2);\n\tbuf[0] = (value >>> 8) & 0xff;\n\tbuf[1] = value & 0xff;\n\treturn buf;\n}\n\nexport function readUInt16BE(bytes: Uint8Array, offset = 0): number {\n\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\treturn ((bytes[offset]! << 8) | bytes[offset + 1]!) >>> 0;\n}\n\nexport function writeUInt8(value: number): Uint8Array {\n\treturn new Uint8Array([value & 0xff]);\n}\n",
|
|
7
|
+
"import { ripemd160 } from \"@noble/hashes/legacy.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { sha512_256 } from \"@noble/hashes/sha2.js\";\nimport { bytesToHex } from \"./encoding.ts\";\n\nexport { sha256, sha512_256, ripemd160 };\n\n/** RIPEMD160(SHA256(input)) — standard Bitcoin/Stacks address hash */\nexport function hash160(input: Uint8Array): Uint8Array {\n\treturn ripemd160(sha256(input));\n}\n\n/** Hash used for transaction IDs */\nexport function txidFromBytes(data: Uint8Array): string {\n\treturn bytesToHex(sha512_256(data));\n}\n\n/** hash160 as hex — used for P2PKH address derivation */\nexport function hashP2PKH(input: Uint8Array): string {\n\treturn bytesToHex(hash160(input));\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";AAAA;;;ACAA,IAAM,QAAQ,MAAM,KAAK,EAAE,QAAQ,IAAI,GAAG,CAAC,GAAG,MAC7C,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAC/B;AAEO,SAAS,WAAU,CAAC,OAA2B;AAAA,EACrD,IAAI,MAAM;AAAA,EACV,WAAW,KAAK,OAAO;AAAA,IACtB,OAAO,MAAM;AAAA,EACd;AAAA,EACA,OAAO;AAAA;AAGD,SAAS,WAAU,CAAC,KAAyB;AAAA,EACnD,IAAI,IAAI,WAAU,GAAG;AAAA,EAErB,IAAI,CAAC,iBAAiB,KAAK,CAAC;AAAA,IAAG,MAAM,IAAI,MAAM,uBAAuB;AAAA,EACtE,IAAI,EAAE,SAAS;AAAA,IAAG,IAAI,IAAI;AAAA,EAE1B,MAAM,QAAQ,IAAI,WAAW,EAAE,SAAS,CAAC;AAAA,EACzC,SAAS,IAAI,EAAG,IAAI,MAAM,QAAQ,KAAK;AAAA,IACtC,MAAM,IAAI,IAAI;AAAA,IACd,MAAM,OAAO,OAAO,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE;AAAA,IAClD,IAAI,OAAO,MAAM,IAAI,KAAK,OAAO;AAAA,MAChC,MAAM,IAAI,MAAM,uBAAuB;AAAA,IACxC,MAAM,KAAK;AAAA,EACZ;AAAA,EACA,OAAO;AAAA;AAGD,SAAS,OAAM,CAAC,OAAuB;AAAA,EAC7C,OAAO,OAAO,KAAK,KAAK,IAAI,QAAQ,KAAK;AAAA;AAGnC,SAAS,UAAS,CAAC,OAAuB;AAAA,EAChD,OAAO,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC,IAAI;AAAA;AAGvC,SAAS,YAAW,CAAC,KAAyB;AAAA,EACpD,OAA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D,OAAO,eAAe,QAAQ,MAAM,CAAC,CAAC;AAAA;;;AE7IvC,sBAAS;AACT,mBAAS;AACT,uBAAS;AAMF,SAAS,QAAO,CAAC,OAA+B;AAAA,EACtD,OAAO,WAAU,QAAO,KAAK,CAAC;AAAA;AAIxB,SAAS,cAAa,CAAC,MAA0B;AAAA,EACvD,OAAO,YAAW,YAAW,IAAI,CAAC;AAAA;AAI5B,SAAS,UAAS,CAAC,OAA2B;AAAA,EACpD,OAAO,YAAW,SAAQ,KAAK,CAAC;AAAA;",
|
|
10
|
+
"debugId": "23A2D2F37D9007B964756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validateStacksAddress2,
|
|
3
3
|
parseContractId2
|
|
4
|
-
} from "./stacks-esm-
|
|
4
|
+
} from "./stacks-esm-h60faj2n.js";
|
|
5
5
|
import {
|
|
6
6
|
parsePostConditionAmount2,
|
|
7
7
|
fromHex2
|
|
8
|
-
} from "./stacks-esm-
|
|
8
|
+
} from "./stacks-esm-2z40q8gs.js";
|
|
9
9
|
|
|
10
10
|
// src/postconditions/builder.ts
|
|
11
11
|
class PartialPcWithPrincipal {
|
|
@@ -152,4 +152,4 @@ var Pc2 = {
|
|
|
152
152
|
export { Pc2 };
|
|
153
153
|
|
|
154
154
|
//# debugId=4A4139991457AA7164756E2164756E21
|
|
155
|
-
//# sourceMappingURL=stacks-esm-
|
|
155
|
+
//# sourceMappingURL=stacks-esm-9ptct1c4.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./stacks-esm-51sysw9g.js";
|
|
4
4
|
import {
|
|
5
5
|
MalformedResponseError2
|
|
6
|
-
} from "./stacks-esm-
|
|
6
|
+
} from "./stacks-esm-mqhwqhq4.js";
|
|
7
7
|
|
|
8
8
|
// src/bitcoin/activation.ts
|
|
9
9
|
async function getBurnBlockHeight2(client) {
|
|
@@ -25,4 +25,4 @@ async function isClarity6Active2(client, gate = {}) {
|
|
|
25
25
|
export { getBurnBlockHeight2, isClarity6Active2 };
|
|
26
26
|
|
|
27
27
|
//# debugId=54CB93A3E662F0D564756E2164756E21
|
|
28
|
-
//# sourceMappingURL=stacks-esm-
|
|
28
|
+
//# sourceMappingURL=stacks-esm-a7apmjbk.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deserializeCVBytes2
|
|
3
|
-
} from "./stacks-esm-
|
|
3
|
+
} from "./stacks-esm-jwgtksgq.js";
|
|
4
4
|
import {
|
|
5
5
|
parseContractId2
|
|
6
|
-
} from "./stacks-esm-
|
|
6
|
+
} from "./stacks-esm-h60faj2n.js";
|
|
7
7
|
import {
|
|
8
8
|
MalformedResponseError2,
|
|
9
9
|
readContract2
|
|
10
|
-
} from "./stacks-esm-
|
|
10
|
+
} from "./stacks-esm-mqhwqhq4.js";
|
|
11
11
|
|
|
12
12
|
// src/actions/public/getBalance.ts
|
|
13
13
|
async function getBalance2(client, params) {
|
|
@@ -77,4 +77,4 @@ async function multicall2(client, params) {
|
|
|
77
77
|
export { getBalance2, getDataVar2, multicall2 };
|
|
78
78
|
|
|
79
79
|
//# debugId=67ECD438D984CEAE64756E2164756E21
|
|
80
|
-
//# sourceMappingURL=stacks-esm-
|
|
80
|
+
//# sourceMappingURL=stacks-esm-brtqryjb.js.map
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
hexToBytes2,
|
|
4
4
|
without0x2,
|
|
5
5
|
concatBytes2
|
|
6
|
-
} from "./stacks-esm-
|
|
6
|
+
} from "./stacks-esm-8p8xy3dz.js";
|
|
7
7
|
import {
|
|
8
8
|
doubleSha2562,
|
|
9
9
|
reverseBytes2,
|
|
10
10
|
parseBitcoinTx2,
|
|
11
11
|
parseBlockHeader2
|
|
12
|
-
} from "./stacks-esm-
|
|
12
|
+
} from "./stacks-esm-nqkwt2z7.js";
|
|
13
13
|
|
|
14
14
|
// src/bitcoin/merkle.ts
|
|
15
15
|
function hashPair(left, right) {
|
|
@@ -254,4 +254,4 @@ function esploraSource2(config) {
|
|
|
254
254
|
export { merkleRoot2, buildMerkleProof2, rootFromProof2, BitcoinSourceError2, buildTxProof2, fallbackProofSource2, bitcoinRpcSource2, esploraSource2 };
|
|
255
255
|
|
|
256
256
|
//# debugId=94F144E59A4150A264756E2164756E21
|
|
257
|
-
//# sourceMappingURL=stacks-esm-
|
|
257
|
+
//# sourceMappingURL=stacks-esm-e63kx7dq.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
doubleSha2562,
|
|
3
3
|
BITCOIN_NETWORK_PARAMS,
|
|
4
4
|
base58CheckEncode
|
|
5
|
-
} from "./stacks-esm-
|
|
5
|
+
} from "./stacks-esm-nqkwt2z7.js";
|
|
6
6
|
|
|
7
7
|
// src/pox/constants.ts
|
|
8
8
|
var POX_CONTRACTS2 = {
|
|
@@ -136,4 +136,4 @@ var BtcAddress2 = {
|
|
|
136
136
|
export { POX_CONTRACTS2, MIN_LOCK_PERIOD2, MAX_LOCK_PERIOD2, POX_ADDRESS_VERSION2, canonicalizeBtcAddress, parseBtcAddress2, stringifyBtcAddress2, BtcAddress2 };
|
|
137
137
|
|
|
138
138
|
//# debugId=3CEA7DEF8974AE9664756E2164756E21
|
|
139
|
-
//# sourceMappingURL=stacks-esm-
|
|
139
|
+
//# sourceMappingURL=stacks-esm-eep45e8s.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parsePrincipal2
|
|
3
|
-
} from "./stacks-esm-
|
|
3
|
+
} from "./stacks-esm-h60faj2n.js";
|
|
4
4
|
|
|
5
5
|
// src/filters/event-types.ts
|
|
6
6
|
var DECODED_EVENT_TYPES2 = [
|
|
@@ -315,4 +315,4 @@ var on2 = {
|
|
|
315
315
|
export { DECODED_EVENT_TYPES2, VM_EVENT_TYPES2, VM_NODE_TO_STORED_TYPE2, CHAIN_EVENT_FILTER_TYPES2, assetId2, isPrincipal2, hasWildcard2, assertPrincipalish2, assertAssetIdentifier2, assertContractId2, makeChainEventFilter2, fromSubgraphSource2, on2 };
|
|
316
316
|
|
|
317
317
|
//# debugId=24E6C97F2709378864756E2164756E21
|
|
318
|
-
//# sourceMappingURL=stacks-esm-
|
|
318
|
+
//# sourceMappingURL=stacks-esm-fmq4j4ez.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
c32address2,
|
|
6
6
|
c32addressDecode2,
|
|
7
7
|
hash1602
|
|
8
|
-
} from "./stacks-esm-
|
|
8
|
+
} from "./stacks-esm-8p8xy3dz.js";
|
|
9
9
|
|
|
10
10
|
// src/utils/constants.ts
|
|
11
11
|
var MAX_U1282 = (1n << 128n) - 1n;
|
|
@@ -81,4 +81,4 @@ function getContractAddress2(deployer, contractName) {
|
|
|
81
81
|
export { MAX_U1282, MAX_I1282, MIN_I1282, AddressVersion2, ZERO_ADDRESS2, TESTNET_ZERO_ADDRESS2, MICROSTX_PER_STX2, publicKeyToAddress2, CONTRACT_NAME_REGEX2, validateStacksAddress2, isValidAddress2, parsePrincipal2, parseContractId2, isClarityName2, isAddressEqual2, addressToVersion2, getContractAddress2 };
|
|
82
82
|
|
|
83
83
|
//# debugId=6C81A592883588B564756E2164756E21
|
|
84
|
-
//# sourceMappingURL=stacks-esm-
|
|
84
|
+
//# sourceMappingURL=stacks-esm-h60faj2n.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
utf8ToBytes2,
|
|
5
5
|
asciiToBytes2,
|
|
6
6
|
bytesToAscii2
|
|
7
|
-
} from "./stacks-esm-
|
|
7
|
+
} from "./stacks-esm-8p8xy3dz.js";
|
|
8
8
|
import {
|
|
9
9
|
isUint1282,
|
|
10
10
|
isInt1282,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isAbiStringAscii2,
|
|
21
21
|
isAbiStringUtf82,
|
|
22
22
|
toCamelCase2
|
|
23
|
-
} from "./stacks-esm-
|
|
23
|
+
} from "./stacks-esm-4rjjsz3p.js";
|
|
24
24
|
import {
|
|
25
25
|
SIP010_ABI2,
|
|
26
26
|
SIP009_ABI2,
|
|
@@ -591,4 +591,4 @@ function parseDeclaredStandards2(claritySource) {
|
|
|
591
591
|
export { prettyPrint2, cvToJSON2, cvToValue2, cvToBigInt2, cvToString2, cvToBuffer2, cvToBoolean2, cvToPrincipal2, ClarityConversionError2, jsToClarity2, prepareArgs2, validateArgs2, validateArgsArray2, normalizeAccess2, normalizeType2, normalizeAbi2, TRAIT_STANDARDS2, classifyContract2, parseDeclaredStandards2 };
|
|
592
592
|
|
|
593
593
|
//# debugId=E6605040EEC27A6C64756E2164756E21
|
|
594
|
-
//# sourceMappingURL=stacks-esm-
|
|
594
|
+
//# sourceMappingURL=stacks-esm-hcaycch3.js.map
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
utf8ToBytes2,
|
|
6
6
|
bytesToUtf82,
|
|
7
7
|
asciiToBytes2,
|
|
8
|
+
isAscii,
|
|
8
9
|
bytesToAscii2,
|
|
9
10
|
concatBytes2,
|
|
10
11
|
intToBigInt2,
|
|
@@ -15,11 +16,11 @@ import {
|
|
|
15
16
|
writeUInt32BE2,
|
|
16
17
|
c32address2,
|
|
17
18
|
c32addressDecode2
|
|
18
|
-
} from "./stacks-esm-
|
|
19
|
+
} from "./stacks-esm-8p8xy3dz.js";
|
|
19
20
|
import {
|
|
20
21
|
parsePrincipal2,
|
|
21
22
|
isClarityName2
|
|
22
|
-
} from "./stacks-esm-
|
|
23
|
+
} from "./stacks-esm-h60faj2n.js";
|
|
23
24
|
import {
|
|
24
25
|
BaseError2
|
|
25
26
|
} from "./stacks-esm-7v18h5dk.js";
|
|
@@ -246,6 +247,10 @@ function deserializeCV2(input) {
|
|
|
246
247
|
// src/clarity/serialize.ts
|
|
247
248
|
var CLARITY_INT_SIZE = 128n;
|
|
248
249
|
var CLARITY_INT_BYTE_SIZE = 16;
|
|
250
|
+
var MAX_U128 = (1n << 128n) - 1n;
|
|
251
|
+
var MAX_I128 = (1n << 127n) - 1n;
|
|
252
|
+
var MIN_I128 = -(1n << 127n);
|
|
253
|
+
var MAX_STRING_BYTES = 1048576;
|
|
249
254
|
function typeIdByte(type) {
|
|
250
255
|
return ClarityWireType2[type];
|
|
251
256
|
}
|
|
@@ -267,11 +272,17 @@ function serializeCVBytes2(value) {
|
|
|
267
272
|
case "false":
|
|
268
273
|
return new Uint8Array([typeIdByte(value.type)]);
|
|
269
274
|
case "int": {
|
|
270
|
-
const
|
|
275
|
+
const n = BigInt(value.value);
|
|
276
|
+
if (n > MAX_I128 || n < MIN_I128)
|
|
277
|
+
throw new RangeError(`Int is outside i128: ${n}`);
|
|
278
|
+
const bytes = bigIntToBytes2(toTwos2(n, CLARITY_INT_SIZE), CLARITY_INT_BYTE_SIZE);
|
|
271
279
|
return withTypeId(value.type, bytes);
|
|
272
280
|
}
|
|
273
281
|
case "uint": {
|
|
274
|
-
const
|
|
282
|
+
const n = BigInt(value.value);
|
|
283
|
+
if (n < 0n || n > MAX_U128)
|
|
284
|
+
throw new RangeError(`UInt is outside u128: ${n}`);
|
|
285
|
+
const bytes = bigIntToBytes2(n, CLARITY_INT_BYTE_SIZE);
|
|
275
286
|
return withTypeId(value.type, bytes);
|
|
276
287
|
}
|
|
277
288
|
case "buffer": {
|
|
@@ -310,6 +321,8 @@ function serializeCVBytes2(value) {
|
|
|
310
321
|
return withTypeId(value.type, concatBytes2(...parts));
|
|
311
322
|
}
|
|
312
323
|
case "ascii": {
|
|
324
|
+
if (!isAscii(value.value))
|
|
325
|
+
throw new Error("string-ascii holds only ASCII characters");
|
|
313
326
|
const strBytes = asciiToBytes2(value.value);
|
|
314
327
|
return withTypeId(value.type, concatBytes2(writeUInt32BE2(strBytes.length), strBytes));
|
|
315
328
|
}
|
|
@@ -326,9 +339,9 @@ function serializeCV2(value) {
|
|
|
326
339
|
}
|
|
327
340
|
|
|
328
341
|
// src/clarity/values.ts
|
|
329
|
-
var
|
|
330
|
-
var
|
|
331
|
-
var
|
|
342
|
+
var MAX_U1282 = BigInt("0xffffffffffffffffffffffffffffffff");
|
|
343
|
+
var MIN_I1282 = BigInt("-170141183460469231731687303715884105728");
|
|
344
|
+
var MAX_I1282 = BigInt("0x7fffffffffffffffffffffffffffffff");
|
|
332
345
|
function intCV2(value) {
|
|
333
346
|
let v = value;
|
|
334
347
|
if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
|
|
@@ -337,18 +350,18 @@ function intCV2(value) {
|
|
|
337
350
|
if (v instanceof Uint8Array)
|
|
338
351
|
v = bytesToTwosBigInt2(v);
|
|
339
352
|
const n = intToBigInt2(v);
|
|
340
|
-
if (n >
|
|
341
|
-
throw new RangeError(`Int exceeds max i128: ${
|
|
342
|
-
if (n <
|
|
343
|
-
throw new RangeError(`Int below min i128: ${
|
|
353
|
+
if (n > MAX_I1282)
|
|
354
|
+
throw new RangeError(`Int exceeds max i128: ${MAX_I1282}`);
|
|
355
|
+
if (n < MIN_I1282)
|
|
356
|
+
throw new RangeError(`Int below min i128: ${MIN_I1282}`);
|
|
344
357
|
return { type: "int", value: n };
|
|
345
358
|
}
|
|
346
359
|
function uintCV2(value) {
|
|
347
360
|
const n = intToBigInt2(value);
|
|
348
361
|
if (n < 0n)
|
|
349
362
|
throw new RangeError("Cannot construct unsigned int from negative value");
|
|
350
|
-
if (n >
|
|
351
|
-
throw new RangeError(`UInt exceeds max u128: ${
|
|
363
|
+
if (n > MAX_U1282)
|
|
364
|
+
throw new RangeError(`UInt exceeds max u128: ${MAX_U1282}`);
|
|
352
365
|
return { type: "uint", value: n };
|
|
353
366
|
}
|
|
354
367
|
var trueCV2 = () => ({ type: "true" });
|
|
@@ -397,6 +410,10 @@ function tupleCV2(data) {
|
|
|
397
410
|
return { type: "tuple", value: data };
|
|
398
411
|
}
|
|
399
412
|
function stringAsciiCV2(value) {
|
|
413
|
+
if (!isAscii(value))
|
|
414
|
+
throw new Error("string-ascii holds only ASCII characters");
|
|
415
|
+
if (value.length > MAX_STRING_BYTES)
|
|
416
|
+
throw new Error(`string-ascii exceeds max size of ${MAX_STRING_BYTES} bytes`);
|
|
400
417
|
return { type: "ascii", value };
|
|
401
418
|
}
|
|
402
419
|
function stringUtf8CV2(value) {
|
|
@@ -437,5 +454,5 @@ var Cl2 = {
|
|
|
437
454
|
|
|
438
455
|
export { ClarityWireType2, clarityTypeFromByte2, serializeCVBytes2, serializeCV2, TransactionError2, BroadcastError2, TransactionAbortedError2, TransactionDroppedError2, WaitForTransactionTimeoutError2, SerializationError2, SigningError2, BytesReader, intCV2, uintCV2, trueCV2, falseCV2, boolCV2, bufferCV2, standardPrincipalCV2, contractPrincipalCV2, noneCV2, someCV2, responseOkCV2, responseErrorCV2, listCV2, tupleCV2, stringAsciiCV2, stringUtf8CV2, Cl2, readAddress, readLPString, readCV, deserializeCVBytes2, deserializeCV2 };
|
|
439
456
|
|
|
440
|
-
//# debugId=
|
|
441
|
-
//# sourceMappingURL=stacks-esm-
|
|
457
|
+
//# debugId=B94BC96978C6CB7F64756E2164756E21
|
|
458
|
+
//# sourceMappingURL=stacks-esm-jwgtksgq.js.map
|