@secondlayer/stacks 2.11.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-v150hffx.js → stacks-01pbr7gf.js} +13 -12
- package/dist/shared/stacks-01pbr7gf.js.map +11 -0
- package/dist/shared/{stacks-hxm7r5ay.cjs → stacks-44y18a8e.cjs} +3 -10
- package/dist/shared/stacks-44y18a8e.cjs.map +10 -0
- package/dist/shared/{stacks-7nvbv61d.js → stacks-59xy6t1p.js} +27 -25
- package/dist/shared/{stacks-7nvbv61d.js.map → stacks-59xy6t1p.js.map} +6 -6
- package/dist/shared/{stacks-63xbc6cj.js → stacks-6n2m9hyk.js} +3 -3
- package/dist/shared/stacks-esn3wcw5.cjs +416 -0
- package/dist/shared/stacks-esn3wcw5.cjs.map +18 -0
- package/dist/shared/{stacks-3kmj5yre.js → stacks-g67f4w1d.js} +5 -12
- package/dist/shared/stacks-g67f4w1d.js.map +10 -0
- package/dist/shared/stacks-kjg7fw4y.js +434 -0
- package/dist/shared/stacks-kjg7fw4y.js.map +18 -0
- package/dist/shared/{stacks-maamjqma.cjs → stacks-tbv5p6pn.cjs} +7 -9
- package/dist/shared/stacks-tbv5p6pn.cjs.map +11 -0
- 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/actions/index.cjs +8 -1
- package/dist/src/actions/index.cjs.map +1 -1
- package/dist/src/actions/index.d.cts +140 -6
- package/dist/src/actions/index.d.ts +140 -6
- package/dist/src/actions/index.js +22 -8
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bns/index.js +3 -3
- 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 +23 -7
- package/dist/src/index.js.map +3 -3
- package/dist/src/pox/index.js +3 -3
- package/dist/src/sbtc/index.js +3 -3
- package/dist/src/stackingdao/index.js +3 -3
- package/dist/src/tools/index.cjs +194 -13
- package/dist/src/tools/index.cjs.map +12 -9
- package/dist/src/tools/index.js +194 -13
- package/dist/src/tools/index.js.map +12 -9
- 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 +7 -4
- package/dist/src/x402/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/shared/stacks-3kmj5yre.js.map +0 -10
- package/dist/shared/stacks-502j0efj.js +0 -210
- package/dist/shared/stacks-502j0efj.js.map +0 -15
- package/dist/shared/stacks-hxm7r5ay.cjs.map +0 -10
- package/dist/shared/stacks-maamjqma.cjs.map +0 -11
- package/dist/shared/stacks-v150hffx.js.map +0 -11
- package/dist/shared/stacks-xmsms921.cjs +0 -196
- package/dist/shared/stacks-xmsms921.cjs.map +0 -15
- /package/dist/shared/{stacks-63xbc6cj.js.map → stacks-6n2m9hyk.js.map} +0 -0
|
@@ -34,12 +34,6 @@ async function getBlock(client, params) {
|
|
|
34
34
|
return client.request("/extended/v2/blocks?limit=1", { method: "GET" });
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// src/actions/public/getBlockHeight.ts
|
|
38
|
-
async function getBlockHeight(client) {
|
|
39
|
-
const data = await client.request("/v2/info", { method: "GET" });
|
|
40
|
-
return data.stacks_tip_height;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
37
|
// src/actions/public/getContractAbi.ts
|
|
44
38
|
async function getContractAbi(client, params) {
|
|
45
39
|
const [address, name] = parseContractId(params.contract);
|
|
@@ -48,6 +42,13 @@ async function getContractAbi(client, params) {
|
|
|
48
42
|
});
|
|
49
43
|
}
|
|
50
44
|
|
|
45
|
+
// src/actions/public/getTransaction.ts
|
|
46
|
+
async function getTransaction(client, params) {
|
|
47
|
+
const source = params.source ?? extendedApiSource();
|
|
48
|
+
const { receipt } = await source.get({ client, txid: params.txid });
|
|
49
|
+
return receipt;
|
|
50
|
+
}
|
|
51
|
+
|
|
51
52
|
// src/actions/public/multicall.ts
|
|
52
53
|
async function multicall(client, params) {
|
|
53
54
|
const { calls, allowFailure = true } = params;
|
|
@@ -142,6 +143,7 @@ async function deployContract(client, params) {
|
|
|
142
143
|
if (!isClarityName(params.contractName))
|
|
143
144
|
throw new Error(`Invalid contract name: ${params.contractName}`);
|
|
144
145
|
if (isProviderAccount(account)) {
|
|
146
|
+
assertNoFeeTierForProvider(params.fee);
|
|
145
147
|
const result = await account.provider.request("stx_deployContract", {
|
|
146
148
|
contractName: params.contractName,
|
|
147
149
|
codeBody: params.codeBody,
|
|
@@ -150,23 +152,20 @@ async function deployContract(client, params) {
|
|
|
150
152
|
return result.txid;
|
|
151
153
|
}
|
|
152
154
|
const nonce = params.nonce ?? await resolveNonce(client, account.address);
|
|
155
|
+
const needsFeeResolution = params.fee === undefined || isFeeTier(params.fee);
|
|
153
156
|
const unsigned = buildContractDeploy({
|
|
154
157
|
contractName: params.contractName,
|
|
155
158
|
codeBody: params.codeBody,
|
|
156
159
|
clarityVersion: params.clarityVersion,
|
|
157
|
-
fee: params.fee
|
|
160
|
+
fee: needsFeeResolution ? 0n : params.fee,
|
|
158
161
|
nonce,
|
|
159
162
|
publicKey: account.publicKey,
|
|
160
163
|
chain: client.chain,
|
|
161
164
|
postConditionMode: params.postConditionMode,
|
|
162
165
|
postConditions: params.postConditions
|
|
163
166
|
});
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
const mid = estimates[1] ?? estimates[0];
|
|
167
|
-
if (mid) {
|
|
168
|
-
unsigned.auth.spendingCondition.fee = BigInt(mid.fee);
|
|
169
|
-
}
|
|
167
|
+
if (needsFeeResolution) {
|
|
168
|
+
setUnsignedFee(unsigned, await resolveFee(client, unsigned, params.fee));
|
|
170
169
|
}
|
|
171
170
|
const signed = await signTransactionWithAccount(unsigned, account);
|
|
172
171
|
return broadcastWithNonceReset(client, {
|
|
@@ -238,6 +237,7 @@ async function transferStx(client, params) {
|
|
|
238
237
|
if (!validateStacksAddress(params.to))
|
|
239
238
|
throw new Error(`Invalid recipient address: ${params.to}`);
|
|
240
239
|
if (isProviderAccount(account)) {
|
|
240
|
+
assertNoFeeTierForProvider(params.fee);
|
|
241
241
|
const result = await account.provider.request("stx_transferStx", {
|
|
242
242
|
recipient: params.to,
|
|
243
243
|
amount: String(params.amount),
|
|
@@ -246,23 +246,20 @@ async function transferStx(client, params) {
|
|
|
246
246
|
return result.txid;
|
|
247
247
|
}
|
|
248
248
|
const nonce = params.nonce ?? await resolveNonce(client, account.address);
|
|
249
|
+
const needsFeeResolution = params.fee === undefined || isFeeTier(params.fee);
|
|
249
250
|
const unsigned = buildTokenTransfer({
|
|
250
251
|
recipient: params.to,
|
|
251
252
|
amount: params.amount,
|
|
252
253
|
memo: params.memo,
|
|
253
|
-
fee: params.fee
|
|
254
|
+
fee: needsFeeResolution ? 0n : params.fee,
|
|
254
255
|
nonce,
|
|
255
256
|
publicKey: account.publicKey,
|
|
256
257
|
chain: client.chain,
|
|
257
258
|
postConditionMode: params.postConditionMode,
|
|
258
259
|
postConditions: params.postConditions
|
|
259
260
|
});
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
const mid = estimates[1] ?? estimates[0];
|
|
263
|
-
if (mid) {
|
|
264
|
-
unsigned.auth.spendingCondition.fee = BigInt(mid.fee);
|
|
265
|
-
}
|
|
261
|
+
if (needsFeeResolution) {
|
|
262
|
+
setUnsignedFee(unsigned, await resolveFee(client, unsigned, params.fee));
|
|
266
263
|
}
|
|
267
264
|
const signed = await signTransactionWithAccount(unsigned, account);
|
|
268
265
|
return broadcastWithNonceReset(client, {
|
|
@@ -271,5 +268,5 @@ async function transferStx(client, params) {
|
|
|
271
268
|
});
|
|
272
269
|
}
|
|
273
270
|
|
|
274
|
-
//# debugId=
|
|
275
|
-
//# sourceMappingURL=stacks-
|
|
271
|
+
//# debugId=DB85D1168A53BA1164756E2164756E21
|
|
272
|
+
//# sourceMappingURL=stacks-y5epf0sb.cjs.map
|
|
@@ -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;AAAA,IACnE,QAAQ;AAAA,EACT,CAAC;AAAA,EACD,OAAO,OAAO,KAAK,OAAO;AAAA;;;ACN3B,eAAsB,QAAQ,CAC7B,QACA,QAEe;AAAA,EACf,IAAI,QAAQ,MAAM;AAAA,IACjB,OAAO,OAAO,QAAQ,uBAAuB,OAAO,QAAQ;AAAA,MAC3D,QAAQ;AAAA,IACT,CAAC;AAAA,EACF;AAAA,EACA,IAAI,QAAQ,WAAW,WAAW;AAAA,IACjC,OAAO,OAAO,QAAQ,uBAAuB,OAAO,UAAU;AAAA,MAC7D,QAAQ;AAAA,IACT,CAAC;AAAA,EACF;AAAA,EAEA,OAAO,OAAO,QAAQ,+BAA+B,EAAE,QAAQ,MAAM,CAAC;AAAA;;;
|
|
20
|
-
"debugId": "
|
|
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;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,OAAO,GAAG;AAAA,EAE3E,MAAM,WAAW,mBAAmB;AAAA,IACnC,WAAW,OAAO;AAAA,IAClB,QAAQ,OAAO;AAAA,IACf,MAAM,OAAO;AAAA,IACb,KAAK,qBAAqB,KAAM,OAAO;AAAA,IACvC;AAAA,IACA,WAAW,QAAQ;AAAA,IACnB,OAAO,OAAO;AAAA,IACd,mBAAmB,OAAO;AAAA,IAC1B,gBAAgB,OAAO;AAAA,EACxB,CAAC;AAAA,EAED,IAAI,oBAAoB;AAAA,IACvB,eAAe,UAAU,MAAM,WAAW,QAAQ,UAAU,OAAO,GAAG,CAAC;AAAA,EACxE;AAAA,EAEA,MAAM,SAAS,MAAM,2BAA2B,UAAU,OAAO;AAAA,EACjE,OAAO,wBAAwB,QAAQ;AAAA,IACtC,aAAa;AAAA,IACb,SAAS,QAAQ;AAAA,EAClB,CAAC;AAAA;",
|
|
20
|
+
"debugId": "DB85D1168A53BA1164756E2164756E21",
|
|
21
21
|
"names": []
|
|
22
22
|
}
|
|
@@ -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";
|
|
@@ -1028,4 +1162,4 @@ declare class ContractResponseError extends Error {
|
|
|
1028
1162
|
name: string;
|
|
1029
1163
|
constructor(message: string, errorValue: unknown);
|
|
1030
1164
|
}
|
|
1031
|
-
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, ContractBuildCallOptions, 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 };
|