@secondlayer/stacks 2.10.0 → 2.12.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/README.md +24 -0
- package/dist/shared/{stacks-4t2vmp4y.js → stacks-01pbr7gf.js} +17 -16
- package/dist/shared/stacks-01pbr7gf.js.map +11 -0
- 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-hxm7r5ay.cjs → stacks-44y18a8e.cjs} +3 -10
- package/dist/shared/stacks-44y18a8e.cjs.map +10 -0
- package/dist/shared/{stacks-2dhf79w5.js → stacks-59xy6t1p.js} +33 -31
- package/dist/shared/{stacks-2dhf79w5.js.map → stacks-59xy6t1p.js.map} +6 -6
- package/dist/shared/{stacks-99ghanwx.js → stacks-6n2m9hyk.js} +56 -6
- package/dist/shared/stacks-6n2m9hyk.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-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-esn3wcw5.cjs +416 -0
- package/dist/shared/stacks-esn3wcw5.cjs.map +18 -0
- 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-e60vrr34.js → stacks-g11v9a35.js} +4 -4
- package/dist/shared/{stacks-0ek3cyt8.js → stacks-g67f4w1d.js} +7 -14
- package/dist/shared/stacks-g67f4w1d.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-kjg7fw4y.js +434 -0
- package/dist/shared/stacks-kjg7fw4y.js.map +18 -0
- 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-xw0j252s.cjs → stacks-shn9zw99.cjs} +43 -3
- package/dist/shared/stacks-shn9zw99.cjs.map +10 -0
- package/dist/shared/{stacks-vf0ekgwb.js → stacks-ssndnbbd.js} +8 -10
- package/dist/shared/{stacks-vf0ekgwb.js.map → stacks-ssndnbbd.js.map} +2 -2
- package/dist/shared/{stacks-maamjqma.cjs → stacks-tbv5p6pn.cjs} +7 -9
- package/dist/shared/stacks-tbv5p6pn.cjs.map +11 -0
- package/dist/shared/{stacks-a36n7sjz.js → stacks-x94a1d6s.js} +3 -3
- package/dist/shared/{stacks-k5an9zcw.cjs → stacks-y5epf0sb.cjs} +19 -22
- package/dist/shared/{stacks-k5an9zcw.cjs.map → stacks-y5epf0sb.cjs.map} +6 -6
- package/dist/src/accounts/index.js +3 -5
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.cjs +8 -1
- package/dist/src/actions/index.cjs.map +1 -1
- package/dist/src/actions/index.d.cts +198 -13
- package/dist/src/actions/index.d.ts +198 -13
- package/dist/src/actions/index.js +29 -17
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.js +8 -11
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.js +12 -14
- package/dist/src/bns/index.js.map +2 -2
- 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.cjs +10 -1
- package/dist/src/index.cjs.map +3 -3
- package/dist/src/index.d.cts +167 -9
- package/dist/src/index.d.ts +167 -9
- package/dist/src/index.js +30 -17
- package/dist/src/index.js.map +3 -3
- package/dist/src/postconditions/index.js +3 -3
- package/dist/src/pox/index.js +11 -13
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/sbtc/index.js +10 -12
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/stackingdao/index.js +11 -13
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/tools/index.cjs +348 -63
- package/dist/src/tools/index.cjs.map +18 -15
- package/dist/src/tools/index.js +348 -63
- package/dist/src/tools/index.js.map +18 -15
- package/dist/src/transactions/index.js +6 -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.cjs +5 -2
- package/dist/src/x402/index.cjs.map +3 -3
- package/dist/src/x402/index.d.cts +36 -0
- package/dist/src/x402/index.d.ts +36 -0
- package/dist/src/x402/index.js +13 -11
- package/dist/src/x402/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/shared/stacks-0ek3cyt8.js.map +0 -10
- package/dist/shared/stacks-4t2vmp4y.js.map +0 -11
- package/dist/shared/stacks-6xmk24yw.js.map +0 -10
- package/dist/shared/stacks-99ghanwx.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-9t68zmpn.js +0 -210
- package/dist/shared/stacks-9t68zmpn.js.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-hxm7r5ay.cjs.map +0 -10
- package/dist/shared/stacks-maamjqma.cjs.map +0 -11
- package/dist/shared/stacks-v9jqcpd4.js +0 -18
- package/dist/shared/stacks-v9jqcpd4.js.map +0 -10
- package/dist/shared/stacks-wyxj879g.cjs.map +0 -13
- package/dist/shared/stacks-xmsms921.cjs +0 -196
- package/dist/shared/stacks-xmsms921.cjs.map +0 -15
- package/dist/shared/stacks-xw0j252s.cjs.map +0 -10
- 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-e60vrr34.js.map → stacks-g11v9a35.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-a36n7sjz.js.map → stacks-x94a1d6s.js.map} +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/actions/public/getAccountInfo.ts", "../src/actions/public/getBalance.ts", "../src/actions/public/getBlock.ts", "../src/actions/public/
|
|
3
|
+
"sources": ["../src/actions/public/getAccountInfo.ts", "../src/actions/public/getBalance.ts", "../src/actions/public/getBlock.ts", "../src/actions/public/getContractAbi.ts", "../src/actions/public/getTransaction.ts", "../src/actions/public/multicall.ts", "../src/errors/simulation.ts", "../src/actions/public/simulateCall.ts", "../src/actions/public/simulateTransaction.ts", "../src/actions/wallet/deployContract.ts", "../src/actions/wallet/signMessage.ts", "../src/actions/wallet/signTransaction.ts", "../src/actions/wallet/transferStx.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Client } from \"../../clients/types.ts\";\n\nexport type GetAccountInfoParams = {\n\taddress: string;\n};\n\nexport type AccountInfo = {\n\tbalance: bigint;\n\tnonce: bigint;\n\tbalanceProof: string;\n\tnonceProof: string;\n};\n\nexport async function getAccountInfo(\n\tclient: Client,\n\tparams: GetAccountInfoParams,\n): Promise<AccountInfo> {\n\tconst data = await client.request(`/v2/accounts/${params.address}?proof=1`, {\n\t\tmethod: \"GET\",\n\t});\n\treturn {\n\t\tbalance: BigInt(data.balance),\n\t\tnonce: BigInt(data.nonce),\n\t\tbalanceProof: data.balance_proof ?? \"\",\n\t\tnonceProof: data.nonce_proof ?? \"\",\n\t};\n}\n",
|
|
6
6
|
"import type { Client } from \"../../clients/types.ts\";\n\nexport type GetBalanceParams = {\n\taddress: string;\n};\n\nexport async function getBalance(\n\tclient: Client,\n\tparams: GetBalanceParams,\n): Promise<bigint> {\n\tconst data = await client.request(`/v2/accounts/${params.address}`, {\n\t\tmethod: \"GET\",\n\t});\n\treturn BigInt(data.balance);\n}\n",
|
|
7
7
|
"import type { Client } from \"../../clients/types.ts\";\n\nexport type GetBlockParams = {\n\theight?: number;\n\thash?: string;\n};\n\nexport async function getBlock(\n\tclient: Client,\n\tparams?: GetBlockParams,\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n): Promise<any> {\n\tif (params?.hash) {\n\t\treturn client.request(`/extended/v2/blocks/${params.hash}`, {\n\t\t\tmethod: \"GET\",\n\t\t});\n\t}\n\tif (params?.height !== undefined) {\n\t\treturn client.request(`/extended/v2/blocks/${params.height}`, {\n\t\t\tmethod: \"GET\",\n\t\t});\n\t}\n\t// Latest block\n\treturn client.request(\"/extended/v2/blocks?limit=1\", { method: \"GET\" });\n}\n",
|
|
8
|
-
"import type { Client } from \"../../clients/types.ts\";\n\nexport async function getBlockHeight(client: Client): Promise<number> {\n\tconst data = await client.request(\"/v2/info\", { method: \"GET\" });\n\treturn data.stacks_tip_height;\n}\n",
|
|
9
8
|
"import type { Client } from \"../../clients/types.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\n\nexport type GetContractAbiParams = {\n\tcontract: string; // \"address.name\"\n};\n\nexport async function getContractAbi(\n\tclient: Client,\n\tparams: GetContractAbiParams,\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n): Promise<any> {\n\tconst [address, name] = parseContractId(params.contract);\n\treturn client.request(`/v2/contracts/interface/${address}/${name}`, {\n\t\tmethod: \"GET\",\n\t});\n}\n",
|
|
9
|
+
"import type { Client } from \"../../clients/types.ts\";\nimport {\n\ttype TransactionReceipt,\n\ttype TransactionStatusSource,\n\textendedApiSource,\n} from \"./txSources.ts\";\n\nexport type GetTransactionParams = {\n\ttxid: string;\n\t/** Where to read status from. Defaults to {@link extendedApiSource}. */\n\tsource?: TransactionStatusSource;\n};\n\n/**\n * Fetch a transaction's receipt (status, block info, decoded result).\n * Returns `null` when the source has no record of the transaction.\n */\nexport async function getTransaction(\n\tclient: Client,\n\tparams: GetTransactionParams,\n): Promise<TransactionReceipt | null> {\n\tconst source = params.source ?? extendedApiSource();\n\tconst { receipt } = await source.get({ client, txid: params.txid });\n\treturn receipt;\n}\n",
|
|
10
10
|
"import type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { readContract } from \"./readContract.ts\";\n\nexport type MulticallCall = {\n\tcontract: string;\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n};\n\nexport type MulticallParams<TAllowFailure extends boolean = true> = {\n\tcalls: readonly MulticallCall[];\n\tallowFailure?: TAllowFailure;\n};\n\nexport type MulticallSuccessResult = {\n\tstatus: \"success\";\n\tresult: ClarityValue;\n};\nexport type MulticallFailureResult = { status: \"failure\"; error: Error };\n\nexport type MulticallResult<T extends boolean> = T extends true\n\t? (MulticallSuccessResult | MulticallFailureResult)[]\n\t: ClarityValue[];\n\nexport async function multicall<TAllowFailure extends boolean = true>(\n\tclient: Client,\n\tparams: MulticallParams<TAllowFailure>,\n): Promise<MulticallResult<TAllowFailure>> {\n\tconst { calls, allowFailure = true } = params;\n\n\tif (allowFailure) {\n\t\tconst settled = await Promise.allSettled(\n\t\t\tcalls.map((call) => readContract(client, call)),\n\t\t);\n\t\treturn settled.map((r) =>\n\t\t\tr.status === \"fulfilled\"\n\t\t\t\t? { status: \"success\" as const, result: r.value }\n\t\t\t\t: {\n\t\t\t\t\t\tstatus: \"failure\" as const,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\tr.reason instanceof Error\n\t\t\t\t\t\t\t\t? r.reason\n\t\t\t\t\t\t\t\t: new Error(String(r.reason)),\n\t\t\t\t\t},\n\t\t) as MulticallResult<TAllowFailure>;\n\t}\n\n\tconst results = await Promise.all(\n\t\tcalls.map((call) => readContract(client, call)),\n\t);\n\treturn results as MulticallResult<TAllowFailure>;\n}\n",
|
|
11
11
|
"import { BaseError } from \"./base.ts\";\n\nexport class SimulationError extends BaseError {\n\toverride name = \"SimulationError\";\n\twritesDetected: boolean;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: { writesDetected: boolean; details?: string },\n\t) {\n\t\tsuper(message, { details: options.details });\n\t\tthis.writesDetected = options.writesDetected;\n\t}\n}\n",
|
|
12
12
|
"import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { SimulationError } from \"../../errors/simulation.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\nimport { bytesToHex, with0x } from \"../../utils/encoding.ts\";\n\nexport type SimulateCallParams = {\n\tcontract: string;\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n\ttip?: string;\n};\n\nexport type SimulateCallSuccess = { success: true; result: ClarityValue };\nexport type SimulateCallFailure = { success: false; error: SimulationError };\nexport type SimulateCallResult = SimulateCallSuccess | SimulateCallFailure;\n\nexport async function simulateCall(\n\tclient: Client,\n\tparams: SimulateCallParams,\n): Promise<SimulateCallResult> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst sender = params.sender ?? address;\n\n\tconst serializedArgs = (params.args ?? []).map((arg) =>\n\t\twith0x(bytesToHex(serializeCVBytes(arg))),\n\t);\n\n\tlet path = `/v2/contracts/call-read/${address}/${name}/${params.functionName}`;\n\tif (params.tip) {\n\t\tpath += `?tip=${params.tip}`;\n\t}\n\n\tconst data = await client.request(path, {\n\t\tmethod: \"POST\",\n\t\tbody: {\n\t\t\tsender,\n\t\t\targuments: serializedArgs,\n\t\t},\n\t});\n\n\tif (data.okay) {\n\t\treturn { success: true, result: deserializeCVBytes(data.result) };\n\t}\n\n\tconst cause: string = data.cause ?? \"Simulation failed\";\n\tconst writesDetected =\n\t\tcause.includes(\"NotReadOnly\") || cause.includes(\"CostBalanceExceeded\");\n\n\treturn {\n\t\tsuccess: false,\n\t\terror: new SimulationError(\n\t\t\twritesDetected\n\t\t\t\t? \"Function mutates state and cannot be simulated\"\n\t\t\t\t: \"Simulation failed\",\n\t\t\t{ writesDetected, details: cause },\n\t\t),\n\t};\n}\n",
|
|
13
13
|
"import type { Client } from \"../../clients/types.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { AddressHashMode, PayloadType } from \"../../transactions/types.ts\";\nimport { c32address } from \"../../utils/address.ts\";\nimport { type FeeEstimation, estimateFee } from \"./estimateFee.ts\";\nimport { type SimulateCallResult, simulateCall } from \"./simulateCall.ts\";\n\nexport type SimulateTransactionParams = {\n\ttransaction: StacksTransaction;\n\tsender?: string;\n\ttip?: string;\n};\n\nexport type SimulateContractCallResult = {\n\ttype: \"contract-call\";\n\texecution: SimulateCallResult;\n\tfees: FeeEstimation[];\n};\n\nexport type SimulateTransferResult = {\n\ttype: \"token-transfer\";\n\tfees: FeeEstimation[];\n};\n\nexport type SimulateDeployResult = {\n\ttype: \"contract-deploy\";\n\tfees: FeeEstimation[];\n};\n\nexport type SimulateTransactionResult =\n\t| SimulateContractCallResult\n\t| SimulateTransferResult\n\t| SimulateDeployResult;\n\nfunction isMultiSig(hashMode: number): boolean {\n\treturn (\n\t\thashMode === AddressHashMode.P2SH ||\n\t\thashMode === AddressHashMode.P2WSH ||\n\t\thashMode === AddressHashMode.P2SH_NonSequential ||\n\t\thashMode === AddressHashMode.P2WSH_P2SH_NonSequential\n\t);\n}\n\nfunction extractSender(tx: StacksTransaction, client: Client): string {\n\tconst { hashMode, signer } = tx.auth.spendingCondition;\n\tconst chain = client.chain;\n\tconst version = isMultiSig(hashMode)\n\t\t? (chain?.addressVersion.multiSig ?? 20)\n\t\t: (chain?.addressVersion.singleSig ?? 22);\n\treturn c32address(version, signer);\n}\n\nexport async function simulateTransaction(\n\tclient: Client,\n\tparams: SimulateTransactionParams,\n): Promise<SimulateTransactionResult> {\n\tconst { transaction, tip } = params;\n\tconst { payload } = transaction;\n\n\tif (payload.payloadType === PayloadType.ContractCall) {\n\t\tconst sender = params.sender ?? extractSender(transaction, client);\n\t\tconst contract = `${payload.contractAddress}.${payload.contractName}`;\n\n\t\tconst [execution, fees] = await Promise.all([\n\t\t\tsimulateCall(client, {\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: payload.functionName,\n\t\t\t\targs: payload.functionArgs,\n\t\t\t\tsender,\n\t\t\t\ttip,\n\t\t\t}),\n\t\t\testimateFee(client, { transaction }),\n\t\t]);\n\n\t\treturn { type: \"contract-call\", execution, fees };\n\t}\n\n\tconst fees = await estimateFee(client, { transaction });\n\n\tif (\n\t\tpayload.payloadType === PayloadType.SmartContract ||\n\t\tpayload.payloadType === PayloadType.VersionedSmartContract\n\t) {\n\t\treturn { type: \"contract-deploy\", fees };\n\t}\n\n\treturn { type: \"token-transfer\", fees };\n}\n",
|
|
14
|
-
"import type { Client } from \"../../clients/types.ts\";\nimport type { PostCondition } from \"../../postconditions/types.ts\";\nimport { buildContractDeploy } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport type { ClarityVersion } from \"../../transactions/types.ts\";\nimport { isClarityName } from \"../../utils/address.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport {
|
|
14
|
+
"import type { Client } from \"../../clients/types.ts\";\nimport type { PostCondition } from \"../../postconditions/types.ts\";\nimport { buildContractDeploy } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport type { ClarityVersion } from \"../../transactions/types.ts\";\nimport { isClarityName } from \"../../utils/address.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { broadcastWithNonceReset, resolveNonce } from \"./nonceManager.ts\";\nimport {\n\ttype FeeParam,\n\tassertNoFeeTierForProvider,\n\tisFeeTier,\n\tisProviderAccount,\n\tresolveFee,\n\tsetUnsignedFee,\n} from \"./utils.ts\";\n\nexport type DeployContractParams = {\n\tcontractName: string;\n\tcodeBody: string;\n\tclarityVersion?: ClarityVersion;\n\tfee?: FeeParam;\n\tnonce?: IntegerType;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n};\n\n/** Build, sign, and broadcast a contract deploy */\nexport async function deployContract(\n\tclient: Client,\n\tparams: DeployContractParams,\n): Promise<string> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\tif (!isClarityName(params.contractName))\n\t\tthrow new Error(`Invalid contract name: ${params.contractName}`);\n\n\t// Provider: delegate to wallet\n\tif (isProviderAccount(account)) {\n\t\tassertNoFeeTierForProvider(params.fee);\n\t\tconst result = await account.provider.request(\"stx_deployContract\", {\n\t\t\tcontractName: params.contractName,\n\t\t\tcodeBody: params.codeBody,\n\t\t\tclarityVersion: params.clarityVersion,\n\t\t});\n\t\treturn result.txid;\n\t}\n\n\t// Local/Custom: build → sign → broadcast\n\tconst nonce = params.nonce ?? (await resolveNonce(client, account.address));\n\n\tconst needsFeeResolution = params.fee === undefined || isFeeTier(params.fee);\n\n\tconst unsigned = buildContractDeploy({\n\t\tcontractName: params.contractName,\n\t\tcodeBody: params.codeBody,\n\t\tclarityVersion: params.clarityVersion,\n\t\tfee: needsFeeResolution ? 0n : (params.fee as IntegerType),\n\t\tnonce,\n\t\tpublicKey: account.publicKey,\n\t\tchain: client.chain,\n\t\tpostConditionMode: params.postConditionMode,\n\t\tpostConditions: params.postConditions,\n\t});\n\n\tif (needsFeeResolution) {\n\t\tsetUnsignedFee(unsigned, await resolveFee(client, unsigned, params.fee));\n\t}\n\n\tconst signed = await signTransactionWithAccount(unsigned, account);\n\treturn broadcastWithNonceReset(client, {\n\t\ttransaction: signed,\n\t\taddress: account.address,\n\t});\n}\n",
|
|
15
15
|
"import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport { Cl } from \"../../clarity/values.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { bytesToHex, concatBytes } from \"../../utils/encoding.ts\";\nimport { isProviderAccount } from \"./utils.ts\";\n\nexport type SignMessageParams = {\n\tmessage: string | ClarityValue;\n\tdomain?: {\n\t\tname: string;\n\t\tversion: string;\n\t\tchainId: number;\n\t};\n};\n\nconst SIP018_PREFIX = new Uint8Array([0x53, 0x49, 0x50, 0x30, 0x31, 0x38]); // \"SIP018\"\n\n/** Sign a structured message per SIP-018 */\nexport async function signMessage(\n\tclient: Client,\n\tparams: SignMessageParams,\n): Promise<string> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\t// Provider: delegate to wallet\n\tif (isProviderAccount(account)) {\n\t\tconst method = params.domain\n\t\t\t? \"stx_signStructuredMessage\"\n\t\t\t: \"stx_signMessage\";\n\t\tconst result = await account.provider.request(method, {\n\t\t\tmessage: params.message,\n\t\t\tdomain: params.domain,\n\t\t});\n\t\treturn result.signature;\n\t}\n\n\t// Local/Custom: sign locally\n\tconst cv =\n\t\ttypeof params.message === \"string\"\n\t\t\t? Cl.stringAscii(params.message)\n\t\t\t: params.message;\n\n\tconst serializedMsg = serializeCVBytes(cv);\n\n\tlet hash: Uint8Array;\n\n\tif (params.domain) {\n\t\tconst domainCV = Cl.tuple({\n\t\t\tname: Cl.stringAscii(params.domain.name),\n\t\t\tversion: Cl.stringAscii(params.domain.version),\n\t\t\t\"chain-id\": Cl.uint(params.domain.chainId),\n\t\t});\n\t\tconst serializedDomain = serializeCVBytes(domainCV);\n\t\thash = sha256(concatBytes(SIP018_PREFIX, serializedDomain, serializedMsg));\n\t} else {\n\t\thash = sha256(serializedMsg);\n\t}\n\n\tconst sigBytes = await account.sign(hash);\n\treturn bytesToHex(sigBytes);\n}\n",
|
|
16
16
|
"import type { Client } from \"../../clients/types.ts\";\nimport { signMultiSigWithAccount } from \"../../transactions/multisig.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { deserializeTransaction } from \"../../transactions/wire/deserialize.ts\";\nimport { serializeTransactionHex } from \"../../transactions/wire/serialize.ts\";\nimport { isProviderAccount } from \"./utils.ts\";\n\nexport type SignTransactionParams = {\n\ttransaction: StacksTransaction;\n\t/** Public keys for multi-sig signing (auto-detected from _multisig metadata if omitted) */\n\tsigners?: string[];\n};\n\n/** Sign a transaction using the client's account */\nexport async function signTransactionAction(\n\tclient: Client,\n\tparams: SignTransactionParams,\n): Promise<StacksTransaction> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\t// Provider: send hex to wallet, get signed hex back\n\tif (isProviderAccount(account)) {\n\t\tconst hex = serializeTransactionHex(params.transaction);\n\t\tconst result = await account.provider.request(\"stx_signTransaction\", {\n\t\t\ttransaction: hex,\n\t\t});\n\t\treturn deserializeTransaction(result.transaction);\n\t}\n\n\t// Multi-sig: auto-detect from fields or _multisig metadata\n\tconst condition = params.transaction.auth.spendingCondition;\n\tif (\"fields\" in condition) {\n\t\tconst publicKeys =\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\tparams.signers ?? (params.transaction as any)._multisig?.publicKeys;\n\t\tif (!publicKeys)\n\t\t\tthrow new Error(\"Multi-sig signing requires signers (publicKeys)\");\n\t\treturn signMultiSigWithAccount(params.transaction, account, publicKeys);\n\t}\n\n\t// Local/Custom: sign with account\n\treturn signTransactionWithAccount(params.transaction, account);\n}\n",
|
|
17
|
-
"import type { Client } from \"../../clients/types.ts\";\nimport type { PostCondition } from \"../../postconditions/types.ts\";\nimport { buildTokenTransfer } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport { validateStacksAddress } from \"../../utils/address.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport {
|
|
17
|
+
"import type { Client } from \"../../clients/types.ts\";\nimport type { PostCondition } from \"../../postconditions/types.ts\";\nimport { buildTokenTransfer } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport { validateStacksAddress } from \"../../utils/address.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { broadcastWithNonceReset, resolveNonce } from \"./nonceManager.ts\";\nimport {\n\ttype FeeParam,\n\tassertNoFeeTierForProvider,\n\tisFeeTier,\n\tisProviderAccount,\n\tresolveFee,\n\tsetUnsignedFee,\n} from \"./utils.ts\";\n\nexport type TransferStxParams = {\n\tto: string;\n\tamount: IntegerType;\n\tmemo?: string;\n\tfee?: FeeParam;\n\tnonce?: IntegerType;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n};\n\n/** Build, sign, and broadcast an STX transfer */\nexport async function transferStx(\n\tclient: Client,\n\tparams: TransferStxParams,\n): Promise<string> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\tif (!validateStacksAddress(params.to))\n\t\tthrow new Error(`Invalid recipient address: ${params.to}`);\n\n\t// Provider: delegate to wallet\n\tif (isProviderAccount(account)) {\n\t\tassertNoFeeTierForProvider(params.fee);\n\t\tconst result = await account.provider.request(\"stx_transferStx\", {\n\t\t\trecipient: params.to,\n\t\t\tamount: String(params.amount),\n\t\t\tmemo: params.memo,\n\t\t});\n\t\treturn result.txid;\n\t}\n\n\t// Local/Custom: build → sign → broadcast\n\tconst nonce = params.nonce ?? (await resolveNonce(client, account.address));\n\n\tconst needsFeeResolution = params.fee === undefined || isFeeTier(params.fee);\n\n\tconst unsigned = buildTokenTransfer({\n\t\trecipient: params.to,\n\t\tamount: params.amount,\n\t\tmemo: params.memo,\n\t\tfee: needsFeeResolution ? 0n : (params.fee as IntegerType),\n\t\tnonce,\n\t\tpublicKey: account.publicKey,\n\t\tchain: client.chain,\n\t\tpostConditionMode: params.postConditionMode,\n\t\tpostConditions: params.postConditions,\n\t});\n\n\tif (needsFeeResolution) {\n\t\tsetUnsignedFee(unsigned, await resolveFee(client, unsigned, params.fee));\n\t}\n\n\tconst signed = await signTransactionWithAccount(unsigned, account);\n\treturn broadcastWithNonceReset(client, {\n\t\ttransaction: signed,\n\t\taddress: account.address,\n\t});\n}\n"
|
|
18
18
|
],
|
|
19
|
-
"mappings": ";AAaA,eAAsB,cAAc,CACnC,QACA,QACuB;AAAA,EACvB,MAAM,OAAO,MAAM,OAAO,QAAQ,gBAAgB,OAAO,mBAAmB;AAAA,IAC3E,QAAQ;AAAA,EACT,CAAC;AAAA,EACD,OAAO;AAAA,IACN,SAAS,OAAO,KAAK,OAAO;AAAA,IAC5B,OAAO,OAAO,KAAK,KAAK;AAAA,IACxB,cAAc,KAAK,iBAAiB;AAAA,IACpC,YAAY,KAAK,eAAe;AAAA,EACjC;AAAA;;;ACnBD,eAAsB,UAAU,CAC/B,QACA,QACkB;AAAA,EAClB,MAAM,OAAO,MAAM,OAAO,QAAQ,gBAAgB,OAAO,WAAW;A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A;",
|
|
20
|
+
"debugId": "DB85D1168A53BA1164756E2164756E21",
|
|
21
21
|
"names": []
|
|
22
22
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
providerToAccount
|
|
3
3
|
} from "../../shared/stacks-qcae5852.js";
|
|
4
|
-
import {
|
|
5
|
-
hash160
|
|
6
|
-
} from "../../shared/stacks-xxn5ma6g.js";
|
|
7
4
|
import {
|
|
8
5
|
bytesToHex,
|
|
9
6
|
c32address,
|
|
7
|
+
hash160,
|
|
10
8
|
hexToBytes,
|
|
11
9
|
without0x
|
|
12
|
-
} from "../../shared/stacks-
|
|
10
|
+
} from "../../shared/stacks-qs5fzts5.js";
|
|
13
11
|
import"../../shared/stacks-cfazrteq.js";
|
|
14
12
|
|
|
15
13
|
// src/accounts/privateKeyToAccount.ts
|
|
@@ -97,5 +95,5 @@ export {
|
|
|
97
95
|
compressPrivateKey
|
|
98
96
|
};
|
|
99
97
|
|
|
100
|
-
//# debugId=
|
|
98
|
+
//# debugId=AE3E7159A40E2C1E64756E2164756E21
|
|
101
99
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"import { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport { bytesToHex } from \"../utils/encoding.ts\";\nimport {\n\tcompressPrivateKey,\n\tprivateKeyToAccount,\n} from \"./privateKeyToAccount.ts\";\nimport type { LocalAccount } from \"./types.ts\";\n\nconst STX_DERIVATION_PATH = \"m/44'/5757'/0'/0\";\n\nexport function mnemonicToAccount(\n\tmnemonic: string,\n\toptions?: {\n\t\taccountIndex?: number;\n\t\taddressVersion?: number;\n\t},\n): LocalAccount {\n\tconst { accountIndex = 0, addressVersion } = options ?? {};\n\n\tconst seed = mnemonicToSeedSync(mnemonic);\n\tconst root = HDKey.fromMasterSeed(seed);\n\tconst child = root.derive(`${STX_DERIVATION_PATH}/${accountIndex}`);\n\n\tif (!child.privateKey) throw new Error(\"Failed to derive private key\");\n\n\tconst privateKeyHex = compressPrivateKey(bytesToHex(child.privateKey));\n\treturn privateKeyToAccount(privateKeyHex, { addressVersion });\n}\n",
|
|
7
7
|
"import type { AccountSource, CustomAccount } from \"./types.ts\";\n\nexport function toAccount(source: AccountSource): CustomAccount {\n\treturn {\n\t\ttype: \"custom\",\n\t\taddress: source.address,\n\t\tpublicKey: source.publicKey,\n\t\tsign: source.sign,\n\t};\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;AAAA;AACA;AACA,8BAAc;AAMd,SAAS,iBAAiB,GAAG;AAAA,EAC5B,IAAI,CAAC,IAAI,gBAAgB;AAAA,IACxB,IAAI,iBAAiB,CAAC,QAAoB,SAAuB;AAAA,MAChE,MAAM,IAAI,KAAK,OAAO,QAAQ,GAAG;AAAA,MACjC,WAAW,OAAO;AAAA,QAAM,EAAE,OAAO,GAAG;AAAA,MACpC,OAAO,EAAE,OAAO;AAAA;AAAA,EAElB;AAAA;AAGD,IAAM,gCAAgC;AAE/B,SAAS,mBAAmB,CAClC,YACA,SACe;AAAA,EACf,kBAAkB;AAAA,EAClB,MAAM,WAAW,oBAAoB,UAAU;AAAA,EAC/C,MAAM,SAAS,SAAS,MAAM,GAAG,EAAE;AAAA,EAGnC,MAAM,iBAAiB,kBAAkB,QAAQ,IAAI;AAAA,EACrD,MAAM,eAAe,WAAW,cAAc;AAAA,EAG9C,MAAM,iBAAiB,SAAS,kBAAkB;AAAA,EAClD,MAAM,UAAU,WACf,gBACA,WAAW,QAAQ,cAAc,CAAC,CACnC;AAAA,EAEA,OAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,WAAW;AAAA,IAEX,IAAI,CAAC,MAA8B;AAAA,MAClC,MAAM,MAAM,KAAK,MAAM,QAAQ,EAAE,MAAM,KAAK,CAAC;AAAA,MAC7C,MAAM,SAAS,IAAI,WAAW,EAA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AO;AAAA,IAChB,WAAW,OAAO;AAAA,IAClB,MAAM,OAAO;AAAA,EACd;AAAA;",
|
|
10
|
+
"debugId": "AE3E7159A40E2C1E64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -7,6 +7,7 @@ __export(exports_actions, {
|
|
|
7
7
|
watchBlocks: () => watchBlocks,
|
|
8
8
|
watchAddressBalance: () => watchAddressBalance,
|
|
9
9
|
watchAddress: () => watchAddress,
|
|
10
|
+
waitForTransactionReceipt: () => waitForTransactionReceipt,
|
|
10
11
|
transferStx: () => transferStx,
|
|
11
12
|
sponsorTransaction: () => sponsorTransaction,
|
|
12
13
|
simulateTransaction: () => simulateTransaction,
|
|
@@ -14,9 +15,14 @@ __export(exports_actions, {
|
|
|
14
15
|
signTransactionAction: () => signTransactionAction,
|
|
15
16
|
signMessage: () => signMessage,
|
|
16
17
|
sendTransaction: () => sendTransaction,
|
|
18
|
+
resolveFee: () => resolveFee,
|
|
17
19
|
readContract: () => readContract,
|
|
18
20
|
multicall: () => multicall,
|
|
21
|
+
minimumFee: () => minimumFee,
|
|
19
22
|
isProviderAccount: () => isProviderAccount,
|
|
23
|
+
isFeeTier: () => isFeeTier,
|
|
24
|
+
indexTxSource: () => indexTxSource,
|
|
25
|
+
getTransaction: () => getTransaction,
|
|
20
26
|
getNonce: () => getNonce,
|
|
21
27
|
getMapEntry: () => getMapEntry,
|
|
22
28
|
getContractAbi: () => getContractAbi,
|
|
@@ -25,6 +31,7 @@ __export(exports_actions, {
|
|
|
25
31
|
getBlock: () => getBlock,
|
|
26
32
|
getBalance: () => getBalance,
|
|
27
33
|
getAccountInfo: () => getAccountInfo,
|
|
34
|
+
extendedApiSource: () => extendedApiSource,
|
|
28
35
|
estimateFee: () => estimateFee,
|
|
29
36
|
deployContract: () => deployContract,
|
|
30
37
|
callContract: () => callContract,
|
|
@@ -32,5 +39,5 @@ __export(exports_actions, {
|
|
|
32
39
|
});
|
|
33
40
|
module.exports = __toCommonJS(exports_actions);
|
|
34
41
|
|
|
35
|
-
//# debugId=
|
|
42
|
+
//# debugId=38538D184946FE2164756E2164756E21
|
|
36
43
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -522,6 +522,109 @@ type SimulateDeployResult = {
|
|
|
522
522
|
};
|
|
523
523
|
type SimulateTransactionResult = SimulateContractCallResult | SimulateTransferResult | SimulateDeployResult;
|
|
524
524
|
declare function simulateTransaction(client: Client, params: SimulateTransactionParams): Promise<SimulateTransactionResult>;
|
|
525
|
+
/**
|
|
526
|
+
* Pluggable transaction-status sources for {@link getTransaction} /
|
|
527
|
+
* `waitForTransactionReceipt`.
|
|
528
|
+
*
|
|
529
|
+
* A bare stacks-node has no confirmed-transaction endpoint, so status reads
|
|
530
|
+
* need a host that indexes transactions. Where that data comes from is
|
|
531
|
+
* pluggable, mirroring the nonce sources:
|
|
532
|
+
*
|
|
533
|
+
* - {@link extendedApiSource} — default; `/extended/v1/tx/{txid}` on the
|
|
534
|
+
* client's transport host (Hiro API or any extended-API-compatible host).
|
|
535
|
+
* - {@link indexTxSource} — Secondlayer's `/v1/index/transactions/{txid}`;
|
|
536
|
+
* returns the chain tip in the same response, so N-confirmation waits
|
|
537
|
+
* need no second request.
|
|
538
|
+
*/
|
|
539
|
+
type TransactionStatus = "pending" | "success" | "abort_by_response" | "abort_by_post_condition" | "dropped";
|
|
540
|
+
type TransactionReceipt = {
|
|
541
|
+
txid: string
|
|
542
|
+
status: TransactionStatus
|
|
543
|
+
/** Anchor block height; absent while pending. */
|
|
544
|
+
blockHeight?: number
|
|
545
|
+
blockHash?: string
|
|
546
|
+
/** Decoded Clarity result; absent while pending or when the source omits it. */
|
|
547
|
+
result?: ClarityValue
|
|
548
|
+
resultHex?: string
|
|
549
|
+
events: unknown[]
|
|
550
|
+
/** The source's unnormalized response, for fields the receipt doesn't model. */
|
|
551
|
+
raw: unknown
|
|
552
|
+
};
|
|
553
|
+
type TransactionSnapshot = {
|
|
554
|
+
/** `null` when the source has no record of the tx (mempool + chain). */
|
|
555
|
+
receipt: TransactionReceipt | null
|
|
556
|
+
/** Chain tip height, when the source knows it (saves a round-trip). */
|
|
557
|
+
tip?: number
|
|
558
|
+
};
|
|
559
|
+
type TransactionStatusSource = {
|
|
560
|
+
get(args: {
|
|
561
|
+
client: Client
|
|
562
|
+
txid: string
|
|
563
|
+
}): Promise<TransactionSnapshot>
|
|
564
|
+
};
|
|
565
|
+
type FetchImpl = typeof globalThis.fetch;
|
|
566
|
+
/**
|
|
567
|
+
* Default source: `GET /extended/v1/tx/{txid}` via the client's transport.
|
|
568
|
+
* Requires a host that serves Hiro's extended API (a bare stacks-node does
|
|
569
|
+
* not). Does not report the chain tip — the wait action fetches it separately
|
|
570
|
+
* when `confirmations > 1`.
|
|
571
|
+
*/
|
|
572
|
+
declare function extendedApiSource(): TransactionStatusSource;
|
|
573
|
+
type IndexTxSourceParams = {
|
|
574
|
+
/** Base URL of a Secondlayer-shaped index API. */
|
|
575
|
+
baseUrl?: string
|
|
576
|
+
apiKey?: string
|
|
577
|
+
fetchImpl?: FetchImpl
|
|
578
|
+
};
|
|
579
|
+
/**
|
|
580
|
+
* Source backed by Secondlayer's `/v1/index/transactions/{txid}`. The response
|
|
581
|
+
* embeds the chain tip, so N-confirmation math needs no extra request. The
|
|
582
|
+
* index only returns canonical (mined) transactions — while a tx is in the
|
|
583
|
+
* mempool this source reports `receipt: null`, and the wait action's grace
|
|
584
|
+
* window carries it until inclusion.
|
|
585
|
+
*/
|
|
586
|
+
declare function indexTxSource(params?: IndexTxSourceParams): TransactionStatusSource;
|
|
587
|
+
type GetTransactionParams = {
|
|
588
|
+
txid: string
|
|
589
|
+
/** Where to read status from. Defaults to {@link extendedApiSource}. */
|
|
590
|
+
source?: TransactionStatusSource
|
|
591
|
+
};
|
|
592
|
+
/**
|
|
593
|
+
* Fetch a transaction's receipt (status, block info, decoded result).
|
|
594
|
+
* Returns `null` when the source has no record of the transaction.
|
|
595
|
+
*/
|
|
596
|
+
declare function getTransaction(client: Client, params: GetTransactionParams): Promise<TransactionReceipt | null>;
|
|
597
|
+
type WaitForTransactionReceiptParams = {
|
|
598
|
+
txid: string
|
|
599
|
+
/** Anchor-block confirmations to wait for. Default 1 (mined). */
|
|
600
|
+
confirmations?: number
|
|
601
|
+
/** Give up after this many ms. Default 180_000 (3 min). */
|
|
602
|
+
timeout?: number
|
|
603
|
+
/** Delay between status polls, ms. Default 3_000. */
|
|
604
|
+
pollingInterval?: number
|
|
605
|
+
/**
|
|
606
|
+
* How long a tx may be unknown to the source before it counts as dropped,
|
|
607
|
+
* ms. Covers broadcast propagation lag and canonical-only sources that
|
|
608
|
+
* can't see the mempool. Default 30_000.
|
|
609
|
+
*/
|
|
610
|
+
droppedGracePeriod?: number
|
|
611
|
+
/** Where to read status from. Defaults to {@link extendedApiSource}. */
|
|
612
|
+
source?: TransactionStatusSource
|
|
613
|
+
};
|
|
614
|
+
/**
|
|
615
|
+
* Poll until a transaction is mined with N confirmations, then return its
|
|
616
|
+
* receipt.
|
|
617
|
+
*
|
|
618
|
+
* Rejects with {@link TransactionAbortedError} when the tx mines but aborts
|
|
619
|
+
* (`abort_by_response` / `abort_by_post_condition`) — the receipt is attached.
|
|
620
|
+
* Rejects with {@link TransactionDroppedError} when the tx leaves the mempool
|
|
621
|
+
* unmined or stays unknown past `droppedGracePeriod`, and
|
|
622
|
+
* {@link WaitForTransactionTimeoutError} at `timeout`.
|
|
623
|
+
*
|
|
624
|
+
* Reorg-tolerant: every cycle re-reads the receipt (block height may change)
|
|
625
|
+
* and recomputes confirmations from the current tip.
|
|
626
|
+
*/
|
|
627
|
+
declare function waitForTransactionReceipt(client: Client, params: WaitForTransactionReceiptParams): Promise<TransactionReceipt>;
|
|
525
628
|
/** Handle returned by WebSocket subscription methods; call `unsubscribe()` to stop. */
|
|
526
629
|
type Subscription = {
|
|
527
630
|
unsubscribe: () => void
|
|
@@ -658,9 +761,17 @@ declare function watchNftEvent(client: Client, params: WatchNftEventParams): Pro
|
|
|
658
761
|
type SendTransactionParams = {
|
|
659
762
|
transaction: StacksTransaction
|
|
660
763
|
attachment?: Uint8Array | string
|
|
764
|
+
/**
|
|
765
|
+
* Wait for the transaction to be mined before returning. `true` waits for
|
|
766
|
+
* 1 confirmation; a number waits for that many. The receipt lands on the
|
|
767
|
+
* result. Rejects if the tx aborts, is dropped, or the wait times out.
|
|
768
|
+
*/
|
|
769
|
+
wait?: boolean | number
|
|
661
770
|
};
|
|
662
771
|
type SendTransactionResult = {
|
|
663
772
|
txid: string
|
|
773
|
+
/** Present when `wait` was requested. */
|
|
774
|
+
receipt?: TransactionReceipt
|
|
664
775
|
};
|
|
665
776
|
/** Broadcast a signed transaction to the network */
|
|
666
777
|
declare function sendTransaction(client: Client, params: SendTransactionParams): Promise<SendTransactionResult>;
|
|
@@ -707,11 +818,35 @@ type PoxPostCondition = {
|
|
|
707
818
|
};
|
|
708
819
|
type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition;
|
|
709
820
|
type IntegerType = number | string | bigint | Uint8Array;
|
|
821
|
+
declare function isProviderAccount(account: Account): account is ProviderAccount;
|
|
822
|
+
/**
|
|
823
|
+
* Named fee tiers. `'low' | 'mid' | 'high'` map to the node's three fee
|
|
824
|
+
* estimations; `'min'` is the node's minimum relay fee — 1 uSTX per byte of
|
|
825
|
+
* the serialized transaction, computable offline.
|
|
826
|
+
*/
|
|
827
|
+
type FeeTier = "min" | "low" | "mid" | "high";
|
|
828
|
+
/** Fee input accepted by wallet actions: an explicit amount or a named tier. */
|
|
829
|
+
type FeeParam = IntegerType | FeeTier;
|
|
830
|
+
declare function isFeeTier(fee: FeeParam | undefined): fee is FeeTier;
|
|
831
|
+
/**
|
|
832
|
+
* Minimum relay fee: 1 uSTX per byte of the serialized transaction. The fee
|
|
833
|
+
* field is fixed-width (8 bytes), so the size — and therefore this floor — is
|
|
834
|
+
* stable regardless of the fee value later set on the spending condition.
|
|
835
|
+
*/
|
|
836
|
+
declare function minimumFee(transaction: StacksTransaction): bigint;
|
|
837
|
+
/**
|
|
838
|
+
* Resolve a fee param to a concrete amount. Numeric input passes through.
|
|
839
|
+
* Tiers `'low' | 'mid' | 'high'` index the node's estimations (nearest
|
|
840
|
+
* available when fewer than three are returned); `'min'` — and any estimation
|
|
841
|
+
* failure (e.g. NoEstimateAvailable) — resolves to {@link minimumFee}, which
|
|
842
|
+
* needs no network round-trip.
|
|
843
|
+
*/
|
|
844
|
+
declare function resolveFee(client: Client, transaction: StacksTransaction, fee: FeeParam | undefined): Promise<bigint>;
|
|
710
845
|
type TransferStxParams = {
|
|
711
846
|
to: string
|
|
712
847
|
amount: IntegerType
|
|
713
848
|
memo?: string
|
|
714
|
-
fee?:
|
|
849
|
+
fee?: FeeParam
|
|
715
850
|
nonce?: IntegerType
|
|
716
851
|
postConditionMode?: "allow" | "deny"
|
|
717
852
|
postConditions?: PostCondition[]
|
|
@@ -722,7 +857,7 @@ type CallContractParams = {
|
|
|
722
857
|
contract: string
|
|
723
858
|
functionName: string
|
|
724
859
|
functionArgs?: ClarityValue[]
|
|
725
|
-
fee?:
|
|
860
|
+
fee?: FeeParam
|
|
726
861
|
nonce?: IntegerType
|
|
727
862
|
postConditionMode?: "allow" | "deny"
|
|
728
863
|
postConditions?: PostCondition[]
|
|
@@ -733,7 +868,7 @@ type DeployContractParams = {
|
|
|
733
868
|
contractName: string
|
|
734
869
|
codeBody: string
|
|
735
870
|
clarityVersion?: ClarityVersion
|
|
736
|
-
fee?:
|
|
871
|
+
fee?: FeeParam
|
|
737
872
|
nonce?: IntegerType
|
|
738
873
|
postConditionMode?: "allow" | "deny"
|
|
739
874
|
postConditions?: PostCondition[]
|
|
@@ -752,12 +887,11 @@ type SignMessageParams = {
|
|
|
752
887
|
declare function signMessage2(client: Client, params: SignMessageParams): Promise<string>;
|
|
753
888
|
type SponsorTransactionParams = {
|
|
754
889
|
transaction: StacksTransaction
|
|
755
|
-
fee?:
|
|
890
|
+
fee?: FeeParam
|
|
756
891
|
nonce?: IntegerType
|
|
757
892
|
};
|
|
758
893
|
/** Sponsor a transaction: set sponsor spending condition, sign as sponsor */
|
|
759
894
|
declare function sponsorTransaction(client: Client, params: SponsorTransactionParams): Promise<StacksTransaction>;
|
|
760
|
-
declare function isProviderAccount(account: Account): account is ProviderAccount;
|
|
761
895
|
type AbiUInt128 = "uint128";
|
|
762
896
|
type AbiInt128 = "int128";
|
|
763
897
|
type AbiBool = "bool";
|
|
@@ -889,6 +1023,32 @@ interface AbiContract {
|
|
|
889
1023
|
implemented_traits?: ReadonlyArray<string>;
|
|
890
1024
|
defined_traits?: ReadonlyArray<AbiTraitDefinition>;
|
|
891
1025
|
}
|
|
1026
|
+
declare const abiTypes: unique symbol;
|
|
1027
|
+
/**
|
|
1028
|
+
* Phantom type bundle a codegen tool can fuse onto an as-const ABI literal.
|
|
1029
|
+
*
|
|
1030
|
+
* Function/map keys are camelCase (matching the runtime client's method names)
|
|
1031
|
+
* and `args` is the named-args object each method accepts. `ret` is the raw
|
|
1032
|
+
* output type before any response unwrapping.
|
|
1033
|
+
*/
|
|
1034
|
+
type ContractTypes = {
|
|
1035
|
+
functions: Record<string, {
|
|
1036
|
+
args: object
|
|
1037
|
+
ret: unknown
|
|
1038
|
+
access: "public" | "read-only" | "private"
|
|
1039
|
+
}>
|
|
1040
|
+
maps?: Record<string, {
|
|
1041
|
+
key: unknown
|
|
1042
|
+
value: unknown
|
|
1043
|
+
}>
|
|
1044
|
+
};
|
|
1045
|
+
/**
|
|
1046
|
+
* Resolve the brand off an ABI type. `never` for un-branded ABIs, which lets
|
|
1047
|
+
* consumers fall back to structural inference.
|
|
1048
|
+
*/
|
|
1049
|
+
type AbiTypesOf<C> = C extends {
|
|
1050
|
+
readonly [abiTypes]?: infer T
|
|
1051
|
+
} ? NonNullable<T> extends ContractTypes ? NonNullable<T> : never : never;
|
|
892
1052
|
type ExtractFunctionNames<
|
|
893
1053
|
C extends AbiContract,
|
|
894
1054
|
Access extends FunctionAccess = FunctionAccess
|
|
@@ -941,28 +1101,53 @@ type ExtractMapValue<
|
|
|
941
1101
|
> = ExtractMap<C, N> extends {
|
|
942
1102
|
value: infer V extends AbiType
|
|
943
1103
|
} ? AbiToTS<V> : never;
|
|
944
|
-
/**
|
|
1104
|
+
/**
|
|
1105
|
+
* Unwrap `(response ok err)` → just the `ok` branch type. Distributes over the
|
|
1106
|
+
* `{ ok } | { err }` union: the `err` branch maps to `never` (it throws
|
|
1107
|
+
* `ContractResponseError` at runtime, so it never reaches the caller).
|
|
1108
|
+
*/
|
|
945
1109
|
type UnwrapResponse<T> = T extends {
|
|
946
1110
|
ok: infer O
|
|
947
|
-
}
|
|
948
|
-
err:
|
|
949
|
-
} ?
|
|
1111
|
+
} ? O : T extends {
|
|
1112
|
+
err: unknown
|
|
1113
|
+
} ? never : T;
|
|
950
1114
|
type ReadMethodReturn<
|
|
951
1115
|
C extends AbiContract,
|
|
952
1116
|
N extends ExtractReadOnlyFunctions<C>
|
|
953
1117
|
> = UnwrapResponse<ExtractFunctionOutput<C, N>>;
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1118
|
+
/**
|
|
1119
|
+
* When the ABI carries a codegen brand (`TypedAbi`), method types resolve to
|
|
1120
|
+
* the generated named aliases — cleaner hovers and error messages. Un-branded
|
|
1121
|
+
* ABIs fall back to structural inference over the as-const literal.
|
|
1122
|
+
*/
|
|
1123
|
+
type TypedReadMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "read-only" ? K : never] : (args: T["functions"][K]["args"]) => Promise<UnwrapResponse<T["functions"][K]["ret"]>> };
|
|
1124
|
+
type TypedCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : (args: T["functions"][K]["args"], options?: ContractCallOptions) => Promise<string> };
|
|
1125
|
+
type TypedMapMethods<T extends ContractTypes> = { [K in keyof NonNullable<T["maps"]>] : (key: NonNullable<T["maps"]>[K]["key"]) => Promise<NonNullable<T["maps"]>[K]["value"] | null> };
|
|
1126
|
+
type ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>) => Promise<ReadMethodReturn<C, N>> } : TypedReadMethods<AbiTypesOf<C>>;
|
|
1127
|
+
type CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractCallOptions) => Promise<string> } : TypedCallMethods<AbiTypesOf<C>>;
|
|
1128
|
+
type MapMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractMapNames<C> as ToCamelCase<N>] : (key: ExtractMapKey<C, N>) => Promise<ExtractMapValue<C, N> | null> } : TypedMapMethods<AbiTypesOf<C>>;
|
|
957
1129
|
type ContractCallOptions = {
|
|
958
1130
|
fee?: IntegerType
|
|
959
1131
|
nonce?: IntegerType
|
|
960
1132
|
postConditionMode?: "allow" | "deny"
|
|
961
1133
|
postConditions?: PostCondition[]
|
|
962
1134
|
};
|
|
1135
|
+
/**
|
|
1136
|
+
* Options for `buildCall.*` — building an unsigned transaction for
|
|
1137
|
+
* wallet-signs-later flows. `publicKey` defaults to the client account's
|
|
1138
|
+
* public key; `fee`/`nonce` are resolved from the network when omitted.
|
|
1139
|
+
*/
|
|
1140
|
+
type ContractBuildCallOptions = ContractCallOptions & {
|
|
1141
|
+
publicKey?: string
|
|
1142
|
+
sponsored?: boolean
|
|
1143
|
+
};
|
|
1144
|
+
type TypedBuildCallMethods<T extends ContractTypes> = { [K in keyof T["functions"] as T["functions"][K]["access"] extends "public" ? K : never] : (args: T["functions"][K]["args"], options?: ContractBuildCallOptions) => Promise<StacksTransaction> };
|
|
1145
|
+
type BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never] ? { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractBuildCallOptions) => Promise<StacksTransaction> } : TypedBuildCallMethods<AbiTypesOf<C>>;
|
|
963
1146
|
type ContractInstance<C extends AbiContract> = {
|
|
964
1147
|
read: ReadMethods<C>
|
|
965
1148
|
call: CallMethods<C>
|
|
1149
|
+
/** Build unsigned transactions (wallet-signs-later) — never broadcasts. */
|
|
1150
|
+
buildCall: BuildCallMethods<C>
|
|
966
1151
|
maps: MapMethods<C>
|
|
967
1152
|
};
|
|
968
1153
|
type GetContractParams<C extends AbiContract> = {
|
|
@@ -977,4 +1162,4 @@ declare class ContractResponseError extends Error {
|
|
|
977
1162
|
name: string;
|
|
978
1163
|
constructor(message: string, errorValue: unknown);
|
|
979
1164
|
}
|
|
980
|
-
export { watchTransaction, watchNftEvent, watchMempool, watchBlocks, watchAddressBalance, watchAddress, transferStx, sponsorTransaction, simulateTransaction, simulateCall, signTransactionAction, signMessage2 as signMessage, sendTransaction, readContract, multicall, isProviderAccount, getNonce, getMapEntry, getContractAbi, getContract, getBlockHeight, getBlock, getBalance, getAccountInfo, estimateFee, deployContract, callContract, WatchTransactionParams, WatchNftEventParams, WatchMempoolParams, WatchBlocksParams, WatchAddressParams, WatchAddressBalanceParams, TransferStxParams, SponsorTransactionParams, SimulateTransferResult, SimulateTransactionResult, SimulateTransactionParams, SimulateDeployResult, SimulateContractCallResult, SimulateCallSuccess, SimulateCallResult, SimulateCallParams, SimulateCallFailure, SignTransactionParams, SignMessageParams, SendTransactionResult, SendTransactionParams, ReadContractParams, MulticallSuccessResult, MulticallResult, MulticallParams, MulticallFailureResult, MulticallCall, GetNonceParams, GetMapEntryParams, GetContractParams, GetContractAbiParams, GetBlockParams, GetBalanceParams, GetAccountInfoParams, FeeEstimation, EstimateFeeParams, DeployContractParams, ContractResponseError, ContractInstance, ContractCallOptions, CallContractParams, AccountInfo };
|
|
1165
|
+
export { watchTransaction, watchNftEvent, watchMempool, watchBlocks, watchAddressBalance, watchAddress, waitForTransactionReceipt, transferStx, sponsorTransaction, simulateTransaction, simulateCall, signTransactionAction, signMessage2 as signMessage, sendTransaction, resolveFee, readContract, multicall, minimumFee, isProviderAccount, isFeeTier, indexTxSource, getTransaction, getNonce, getMapEntry, getContractAbi, getContract, getBlockHeight, getBlock, getBalance, getAccountInfo, extendedApiSource, estimateFee, deployContract, callContract, WatchTransactionParams, WatchNftEventParams, WatchMempoolParams, WatchBlocksParams, WatchAddressParams, WatchAddressBalanceParams, WaitForTransactionReceiptParams, TransferStxParams, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, SponsorTransactionParams, SimulateTransferResult, SimulateTransactionResult, SimulateTransactionParams, SimulateDeployResult, SimulateContractCallResult, SimulateCallSuccess, SimulateCallResult, SimulateCallParams, SimulateCallFailure, SignTransactionParams, SignMessageParams, SendTransactionResult, SendTransactionParams, ReadContractParams, MulticallSuccessResult, MulticallResult, MulticallParams, MulticallFailureResult, MulticallCall, IndexTxSourceParams, GetTransactionParams, GetNonceParams, GetMapEntryParams, GetContractParams, GetContractAbiParams, GetBlockParams, GetBalanceParams, GetAccountInfoParams, FeeTier, FeeParam, FeeEstimation, EstimateFeeParams, DeployContractParams, ContractResponseError, ContractInstance, ContractCallOptions, ContractBuildCallOptions, CallContractParams, AccountInfo };
|