@secondlayer/stacks 2.13.0 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +15 -0
  2. package/dist/shared/{stacks-01pbr7gf.js → stacks-3vyvtahh.js} +9 -3
  3. package/dist/shared/{stacks-01pbr7gf.js.map → stacks-3vyvtahh.js.map} +3 -3
  4. package/dist/shared/{stacks-y5epf0sb.cjs → stacks-6mhsf8hk.cjs} +52 -2
  5. package/dist/shared/{stacks-y5epf0sb.cjs.map → stacks-6mhsf8hk.cjs.map} +10 -5
  6. package/dist/shared/stacks-8khy9v27.cjs +7 -0
  7. package/dist/shared/stacks-8khy9v27.cjs.map +10 -0
  8. package/dist/shared/{stacks-esn3wcw5.cjs → stacks-dmrvk1mz.js} +61 -7
  9. package/dist/shared/{stacks-kjg7fw4y.js.map → stacks-dmrvk1mz.js.map} +7 -6
  10. package/dist/shared/{stacks-g67f4w1d.js → stacks-f66v961k.js} +2 -2
  11. package/dist/shared/stacks-fh48neva.js +13 -0
  12. package/dist/shared/stacks-fh48neva.js.map +10 -0
  13. package/dist/shared/{stacks-tbv5p6pn.cjs → stacks-fjrpnkt3.cjs} +5 -2
  14. package/dist/shared/{stacks-tbv5p6pn.cjs.map → stacks-fjrpnkt3.cjs.map} +3 -3
  15. package/dist/shared/{stacks-6n2m9hyk.js → stacks-hxp7v905.js} +3 -3
  16. package/dist/shared/{stacks-kjg7fw4y.js → stacks-jcgvn5v5.cjs} +40 -25
  17. package/dist/shared/{stacks-esn3wcw5.cjs.map → stacks-jcgvn5v5.cjs.map} +7 -6
  18. package/dist/shared/{stacks-59xy6t1p.js → stacks-tswh2xav.js} +58 -4
  19. package/dist/shared/{stacks-59xy6t1p.js.map → stacks-tswh2xav.js.map} +10 -5
  20. package/dist/src/actions/index.cjs +6 -1
  21. package/dist/src/actions/index.cjs.map +1 -1
  22. package/dist/src/actions/index.d.cts +71 -1
  23. package/dist/src/actions/index.d.ts +71 -1
  24. package/dist/src/actions/index.js +17 -6
  25. package/dist/src/actions/index.js.map +1 -1
  26. package/dist/src/bitcoin/index.cjs +2 -2
  27. package/dist/src/bitcoin/index.cjs.map +3 -3
  28. package/dist/src/bitcoin/index.js +6 -2
  29. package/dist/src/bitcoin/index.js.map +3 -3
  30. package/dist/src/bns/index.cjs +9 -5
  31. package/dist/src/bns/index.cjs.map +3 -3
  32. package/dist/src/bns/index.js +13 -8
  33. package/dist/src/bns/index.js.map +3 -3
  34. package/dist/src/index.cjs +30 -8
  35. package/dist/src/index.cjs.map +4 -4
  36. package/dist/src/index.d.cts +67 -1
  37. package/dist/src/index.d.ts +67 -1
  38. package/dist/src/index.js +43 -12
  39. package/dist/src/index.js.map +4 -4
  40. package/dist/src/pox/index.js +5 -4
  41. package/dist/src/pox/index.js.map +2 -2
  42. package/dist/src/sbtc/index.js +5 -4
  43. package/dist/src/sbtc/index.js.map +2 -2
  44. package/dist/src/stackingdao/index.js +5 -4
  45. package/dist/src/stackingdao/index.js.map +2 -2
  46. package/dist/src/tools/index.cjs +213 -116
  47. package/dist/src/tools/index.cjs.map +22 -15
  48. package/dist/src/tools/index.js +213 -116
  49. package/dist/src/tools/index.js.map +22 -15
  50. package/dist/src/x402/index.js +4 -3
  51. package/dist/src/x402/index.js.map +2 -2
  52. package/package.json +4 -2
  53. /package/dist/shared/{stacks-g67f4w1d.js.map → stacks-f66v961k.js.map} +0 -0
  54. /package/dist/shared/{stacks-6n2m9hyk.js.map → stacks-hxp7v905.js.map} +0 -0
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  sponsorTransaction
3
- } from "../../shared/stacks-g67f4w1d.js";
3
+ } from "../../shared/stacks-f66v961k.js";
4
4
  import {
5
5
  sendTransaction
6
- } from "../../shared/stacks-kjg7fw4y.js";
6
+ } from "../../shared/stacks-dmrvk1mz.js";
7
+ import"../../shared/stacks-fh48neva.js";
7
8
  import"../../shared/stacks-709tra19.js";
8
9
  import {
9
10
  Pc
@@ -86,5 +87,5 @@ export {
86
87
  buildExactTransfer
87
88
  };
88
89
 
89
- //# debugId=E54BFB0C68BF6AA864756E2164756E21
90
+ //# debugId=E6F437861BF4CE0264756E2164756E21
90
91
  //# sourceMappingURL=index.js.map
@@ -5,7 +5,7 @@
5
5
  "import type { StacksChain } from \"../chains/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { Pc } from \"../postconditions/builder.ts\";\nimport type { PostCondition } from \"../postconditions/types.ts\";\nimport {\n\tbuildContractCall,\n\tbuildTokenTransfer,\n} from \"../transactions/build.ts\";\nimport {\n\tMEMO_MAX_LENGTH_BYTES,\n\ttype StacksTransaction,\n} from \"../transactions/types.ts\";\nimport { parseContractId } from \"../utils/address.ts\";\nimport { type IntegerType, utf8ToBytes } from \"../utils/encoding.ts\";\n\n/**\n * The asset an x402 payment moves. Either native STX or a SIP-010 token,\n * in which case the fully-qualified contract id and the fungible-token asset\n * name (the `::<asset-name>` suffix, e.g. `sbtc-token`) are both required —\n * the asset name is not always equal to the contract name.\n */\nexport type X402Asset =\n\t| { kind: \"stx\" }\n\t| { kind: \"sip010\"; contractId: string; assetName: string };\n\nexport type BuildExactTransferOptions = {\n\t/** The asset and amount to move. */\n\tasset: X402Asset;\n\tamount: IntegerType;\n\t/** Recipient principal (the resource server's `payTo`). */\n\tpayTo: string;\n\t/** Origin/payer principal — pinned by the post-condition. */\n\tpayer: string;\n\t/** Origin compressed public key (the payer signs origin-only). */\n\tpayerPublicKey: string;\n\t/** The payer account's next nonce. */\n\taccountNonce: IntegerType;\n\t/**\n\t * The x402 challenge nonce, carried in the on-chain memo so the facilitator\n\t * can correlate the settled tx with the challenge. Bound to ≤ 34 bytes\n\t * (UTF-8) — both the STX memo and the SIP-010 `(buff 34)` memo arg cap there.\n\t */\n\tnonce: string;\n\tchain?: StacksChain;\n};\n\n/**\n * Build an exact-amount, Deny-mode, post-conditioned, **sponsored** transfer\n * (origin-only, un-broadcast). The origin sets fee `0`; the facilitator's\n * sponsor fills in + pays the fee at settle time. The Deny-mode post-condition\n * asserts EXACTLY `amount` leaves `payer` to `payTo`, so settlement aborts\n * on-chain if anything differs — the \"exact amount\" x402 guarantee is enforced\n * by Clarity, not just by facilitator simulation.\n */\nexport function buildExactTransfer(\n\toptions: BuildExactTransferOptions,\n): StacksTransaction {\n\tconst { asset, amount, payTo, payer, payerPublicKey, accountNonce, chain } =\n\t\toptions;\n\n\tif (utf8ToBytes(options.nonce).byteLength > MEMO_MAX_LENGTH_BYTES) {\n\t\tthrow new Error(\n\t\t\t`x402 nonce exceeds the ${MEMO_MAX_LENGTH_BYTES}-byte memo budget`,\n\t\t);\n\t}\n\n\tif (asset.kind === \"stx\") {\n\t\t// A TokenTransfer payload CANNOT carry post-conditions (Stacks consensus\n\t\t// rejects it: \"TokenTransfer transactions do not support post-conditions\").\n\t\t// STX exactness is inherent — the amount + recipient are in the signed\n\t\t// payload, so there is nothing a post-condition would add.\n\t\treturn buildTokenTransfer({\n\t\t\trecipient: payTo,\n\t\t\tamount,\n\t\t\tmemo: options.nonce,\n\t\t\tfee: 0,\n\t\t\tnonce: accountNonce,\n\t\t\tpublicKey: payerPublicKey,\n\t\t\tchain,\n\t\t\tsponsored: true,\n\t\t});\n\t}\n\n\tconst [contractAddress, contractName] = parseContractId(asset.contractId);\n\tconst postConditions: PostCondition[] = [\n\t\tPc.principal(payer)\n\t\t\t.willSendEq(amount)\n\t\t\t.ft(asset.contractId, asset.assetName),\n\t];\n\t// SIP-010: (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))\n\treturn buildContractCall({\n\t\tcontractAddress,\n\t\tcontractName,\n\t\tfunctionName: \"transfer\",\n\t\tfunctionArgs: [\n\t\t\tCl.uint(amount),\n\t\t\tCl.principal(payer),\n\t\t\tCl.principal(payTo),\n\t\t\tCl.some(Cl.bufferFromUtf8(options.nonce)),\n\t\t],\n\t\tfee: 0,\n\t\tnonce: accountNonce,\n\t\tpublicKey: payerPublicKey,\n\t\tchain,\n\t\tpostConditionMode: \"deny\",\n\t\tpostConditions,\n\t\tsponsored: true,\n\t});\n}\n",
6
6
  "import type { TransactionReceipt } from \"../actions/public/txSources.ts\";\nimport { sendTransaction } from \"../actions/wallet/sendTransaction.ts\";\nimport { sponsorTransaction } from \"../actions/wallet/sponsorTransaction.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport { deserializeTransaction } from \"../transactions/wire/deserialize.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\n\nexport type SponsorAndBroadcastOptions = {\n\t/** Override the sponsor fee (µSTX). Defaults to a fee estimate. */\n\tfee?: IntegerType;\n\t/** Override the sponsor account nonce. Defaults to the on-chain nonce. */\n\tnonce?: IntegerType;\n\t/**\n\t * Wait for the payment to be mined before returning (`true` = 1\n\t * confirmation, a number = that many). Settlement rejects if the payment\n\t * aborts or drops, instead of reporting a txid that never lands.\n\t */\n\twait?: boolean | number;\n};\n\nexport type SponsorAndBroadcastResult = {\n\ttxid: string;\n\t/** Present when `wait` was requested. */\n\treceipt?: TransactionReceipt;\n};\n\n/**\n * Take an origin-signed, sponsored transfer (hex) from the payer, sponsor-sign\n * it with `client`'s account (paying the STX fee), and broadcast it.\n *\n * The payer never holds STX: they sign origin-only with fee `0`; this fills in\n * the sponsor spending condition + fee and POSTs to `/v2/transactions`. The\n * sponsor cannot grief the payer — amount/recipient/asset are pinned by the\n * origin signature + Deny-mode post-conditions baked into the tx.\n *\n * @param client a wallet client whose `account` is the funded sponsor signer.\n * @param signedTxHex the payer's origin-signed sponsored tx, hex-serialized.\n */\nexport async function sponsorAndBroadcast(\n\tclient: Client,\n\tsignedTxHex: string,\n\toptions: SponsorAndBroadcastOptions = {},\n): Promise<SponsorAndBroadcastResult> {\n\tconst transaction = deserializeTransaction(signedTxHex);\n\tconst sponsored = await sponsorTransaction(client, {\n\t\ttransaction,\n\t\tfee: options.fee,\n\t\tnonce: options.nonce,\n\t});\n\treturn sendTransaction(client, {\n\t\ttransaction: sponsored,\n\t\tw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EF,eAAsB,mBAAmB,CACxC,QACA,aACA,UAAsC,CAAC,GACF;AAAA,EACrC,MAAM,cAAc,uBAAuB,WAAW;AAAA,EACtD,MAAM,YAAY,MAAM,mBAAmB,QAAQ;AAAA,IAClD;AAAA,IACA,KAAK,QAAQ;AAAA,IACb,OAAO,QAAQ;AAAA,EAChB,CAAC;AAAA,EACD,OAAO,gBAAgB,QAAQ;AAAA,IAC9B,aAAa;AAAA,IACb,MAAM,QAAQ;AAAA,EACf,CAAC;AAAA;",
9
+ "debugId": "E6F437861BF4CE0264756E2164756E21",
10
10
  "names": []
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/stacks",
3
- "version": "2.13.0",
3
+ "version": "2.14.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -110,7 +110,9 @@
110
110
  "require": "./dist/src/x402/index.cjs"
111
111
  }
112
112
  },
113
- "files": ["dist"],
113
+ "files": [
114
+ "dist"
115
+ ],
114
116
  "scripts": {
115
117
  "build": "bunup",
116
118
  "test": "bun test",