@secondlayer/stacks 2.9.1 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/{stacks-wyxj879g.cjs → stacks-18jv9aen.js} +83 -4
- package/dist/shared/stacks-18jv9aen.js.map +13 -0
- package/dist/shared/{stacks-0zysn74p.js → stacks-2mm20wqf.js} +3 -3
- package/dist/shared/{stacks-1qmx9kt8.js → stacks-3kmj5yre.js} +4 -4
- package/dist/shared/{stacks-ttbq8emk.js → stacks-502j0efj.js} +3 -3
- package/dist/shared/{stacks-nqae5amn.cjs → stacks-5nskdw7w.cjs} +19 -2
- package/dist/shared/stacks-5nskdw7w.cjs.map +10 -0
- package/dist/shared/{stacks-8mj5jw77.js → stacks-63xbc6cj.js} +63 -7
- package/dist/shared/stacks-63xbc6cj.js.map +10 -0
- package/dist/shared/{stacks-g7ffp8aj.js → stacks-6xt8py97.cjs} +59 -30
- package/dist/shared/stacks-6xt8py97.cjs.map +13 -0
- package/dist/shared/{stacks-53bjdb6p.js → stacks-7nvbv61d.js} +8 -8
- package/dist/shared/stacks-azp00pve.js +70 -0
- package/dist/shared/stacks-azp00pve.js.map +11 -0
- package/dist/shared/{stacks-vk8fwz0t.cjs → stacks-b9904rc2.cjs} +3 -2
- package/dist/shared/{stacks-vk8fwz0t.cjs.map → stacks-b9904rc2.cjs.map} +2 -2
- package/dist/shared/{stacks-3y058qda.cjs → stacks-fhzwsn5d.cjs} +16 -2
- package/dist/shared/{stacks-3y058qda.cjs.map → stacks-fhzwsn5d.cjs.map} +5 -4
- package/dist/shared/{stacks-wqgepfab.js → stacks-g11v9a35.js} +22 -5
- package/dist/shared/stacks-g11v9a35.js.map +10 -0
- package/dist/shared/{stacks-6xmk24yw.js → stacks-gfm3r397.cjs} +20 -7
- package/dist/shared/stacks-gfm3r397.cjs.map +11 -0
- package/dist/shared/{stacks-43cxvnr7.js → stacks-jbmcwky5.js} +3 -3
- package/dist/shared/{stacks-q1mjkt15.js → stacks-msmgyerb.js} +4 -4
- package/dist/shared/{stacks-2h8d2y27.js → stacks-qs5fzts5.js} +17 -3
- package/dist/shared/{stacks-2h8d2y27.js.map → stacks-qs5fzts5.js.map} +5 -4
- package/dist/shared/{stacks-vdfag81a.cjs → stacks-shn9zw99.cjs} +49 -3
- package/dist/shared/stacks-shn9zw99.cjs.map +10 -0
- package/dist/shared/{stacks-4trgpb5a.js → stacks-ssndnbbd.js} +48 -13
- package/dist/shared/stacks-ssndnbbd.js.map +15 -0
- package/dist/shared/{stacks-z1j5d6fd.js → stacks-v150hffx.js} +6 -6
- package/dist/shared/{stacks-ertyhttt.cjs → stacks-wamwv8q8.cjs} +41 -4
- package/dist/shared/stacks-wamwv8q8.cjs.map +15 -0
- package/dist/shared/{stacks-a36n7sjz.js → stacks-x94a1d6s.js} +3 -3
- package/dist/src/accounts/index.js +3 -5
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.d.cts +91 -10
- package/dist/src/actions/index.d.ts +91 -10
- package/dist/src/actions/index.js +13 -15
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.cjs +25 -19
- package/dist/src/bitcoin/index.cjs.map +3 -3
- package/dist/src/bitcoin/index.js +32 -29
- package/dist/src/bitcoin/index.js.map +3 -3
- package/dist/src/bns/index.cjs +4 -16
- package/dist/src/bns/index.cjs.map +3 -3
- package/dist/src/bns/index.js +17 -30
- package/dist/src/bns/index.js.map +3 -3
- package/dist/src/clarity/index.d.cts +50 -1
- package/dist/src/clarity/index.d.ts +50 -1
- package/dist/src/clarity/index.js +8 -7
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/index.d.cts +32 -2
- package/dist/src/index.d.ts +32 -2
- package/dist/src/index.js +12 -15
- package/dist/src/index.js.map +2 -2
- package/dist/src/postconditions/index.d.cts +14 -2
- package/dist/src/postconditions/index.d.ts +14 -2
- package/dist/src/postconditions/index.js +3 -3
- package/dist/src/pox/index.cjs +2 -6
- package/dist/src/pox/index.cjs.map +3 -3
- package/dist/src/pox/index.js +14 -19
- package/dist/src/pox/index.js.map +3 -3
- package/dist/src/sbtc/index.cjs +2 -6
- package/dist/src/sbtc/index.cjs.map +3 -3
- package/dist/src/sbtc/index.js +13 -18
- package/dist/src/sbtc/index.js.map +3 -3
- package/dist/src/stackingdao/index.js +11 -13
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/tools/index.cjs +199 -57
- package/dist/src/tools/index.cjs.map +13 -13
- package/dist/src/tools/index.js +199 -57
- package/dist/src/tools/index.js.map +13 -13
- package/dist/src/transactions/index.cjs +2 -1
- package/dist/src/transactions/index.cjs.map +1 -1
- package/dist/src/transactions/index.d.cts +35 -3
- package/dist/src/transactions/index.d.ts +35 -3
- package/dist/src/transactions/index.js +8 -7
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.cjs +2 -1
- package/dist/src/utils/index.cjs.map +2 -2
- package/dist/src/utils/index.d.cts +5 -1
- package/dist/src/utils/index.d.ts +5 -1
- package/dist/src/utils/index.js +12 -14
- package/dist/src/utils/index.js.map +2 -2
- package/dist/src/x402/index.d.cts +19 -1
- package/dist/src/x402/index.d.ts +19 -1
- package/dist/src/x402/index.js +9 -10
- package/dist/src/x402/index.js.map +2 -2
- package/package.json +4 -2
- package/dist/shared/stacks-4trgpb5a.js.map +0 -15
- package/dist/shared/stacks-6xmk24yw.js.map +0 -10
- package/dist/shared/stacks-8mj5jw77.js.map +0 -10
- package/dist/shared/stacks-9g0jhab3.cjs +0 -40
- package/dist/shared/stacks-9g0jhab3.cjs.map +0 -10
- package/dist/shared/stacks-ertyhttt.cjs.map +0 -15
- package/dist/shared/stacks-fcaefc5b.cjs +0 -16
- package/dist/shared/stacks-fcaefc5b.cjs.map +0 -10
- package/dist/shared/stacks-g7ffp8aj.js.map +0 -13
- package/dist/shared/stacks-nqae5amn.cjs.map +0 -10
- package/dist/shared/stacks-v9jqcpd4.js +0 -18
- package/dist/shared/stacks-v9jqcpd4.js.map +0 -10
- package/dist/shared/stacks-vdfag81a.cjs.map +0 -10
- package/dist/shared/stacks-wqgepfab.js.map +0 -10
- package/dist/shared/stacks-wyxj879g.cjs.map +0 -13
- package/dist/shared/stacks-xxn5ma6g.js +0 -22
- package/dist/shared/stacks-xxn5ma6g.js.map +0 -10
- package/dist/shared/stacks-ya3x01yd.cjs +0 -16
- package/dist/shared/stacks-ya3x01yd.cjs.map +0 -10
- /package/dist/shared/{stacks-0zysn74p.js.map → stacks-2mm20wqf.js.map} +0 -0
- /package/dist/shared/{stacks-1qmx9kt8.js.map → stacks-3kmj5yre.js.map} +0 -0
- /package/dist/shared/{stacks-ttbq8emk.js.map → stacks-502j0efj.js.map} +0 -0
- /package/dist/shared/{stacks-53bjdb6p.js.map → stacks-7nvbv61d.js.map} +0 -0
- /package/dist/shared/{stacks-43cxvnr7.js.map → stacks-jbmcwky5.js.map} +0 -0
- /package/dist/shared/{stacks-q1mjkt15.js.map → stacks-msmgyerb.js.map} +0 -0
- /package/dist/shared/{stacks-z1j5d6fd.js.map → stacks-v150hffx.js.map} +0 -0
- /package/dist/shared/{stacks-a36n7sjz.js.map → stacks-x94a1d6s.js.map} +0 -0
|
@@ -32,6 +32,7 @@ __export(exports_transactions, {
|
|
|
32
32
|
TenureChangeCause: () => TenureChangeCause,
|
|
33
33
|
RECOVERABLE_ECDSA_SIG_LENGTH_BYTES: () => RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,
|
|
34
34
|
PubKeyEncoding: () => PubKeyEncoding,
|
|
35
|
+
PoxConditionCode: () => PoxConditionCode,
|
|
35
36
|
PostConditionPrincipalId: () => PostConditionPrincipalId,
|
|
36
37
|
PostConditionModeWire: () => PostConditionModeWire,
|
|
37
38
|
PayloadType: () => PayloadType,
|
|
@@ -50,5 +51,5 @@ __export(exports_transactions, {
|
|
|
50
51
|
});
|
|
51
52
|
module.exports = __toCommonJS(exports_transactions);
|
|
52
53
|
|
|
53
|
-
//# debugId=
|
|
54
|
+
//# debugId=D7C9025B29ACC3D364756E2164756E21
|
|
54
55
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -83,6 +83,7 @@ declare const ClarityVersion: {
|
|
|
83
83
|
readonly Clarity3: 3
|
|
84
84
|
readonly Clarity4: 4
|
|
85
85
|
readonly Clarity5: 5
|
|
86
|
+
readonly Clarity6: 6
|
|
86
87
|
};
|
|
87
88
|
type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];
|
|
88
89
|
declare const AnchorMode: {
|
|
@@ -121,6 +122,12 @@ declare const NonFungibleConditionCode: {
|
|
|
121
122
|
readonly Sends: 0x10
|
|
122
123
|
readonly DoesNotSend: 0x11
|
|
123
124
|
};
|
|
125
|
+
declare const PoxConditionCode: {
|
|
126
|
+
readonly WillNotPerform: 0x30
|
|
127
|
+
readonly MayPerform: 0x31
|
|
128
|
+
readonly WillPerform: 0x32
|
|
129
|
+
};
|
|
130
|
+
type PoxConditionCode = (typeof PoxConditionCode)[keyof typeof PoxConditionCode];
|
|
124
131
|
declare const PostConditionPrincipalId: {
|
|
125
132
|
readonly Origin: 0x01
|
|
126
133
|
readonly Standard: 0x02
|
|
@@ -130,6 +137,8 @@ declare const AssetType: {
|
|
|
130
137
|
readonly STX: 0x00
|
|
131
138
|
readonly Fungible: 0x01
|
|
132
139
|
readonly NonFungible: 0x02
|
|
140
|
+
readonly Staking: 0x03
|
|
141
|
+
readonly Pox: 0x04
|
|
133
142
|
};
|
|
134
143
|
declare const AuthFieldType: {
|
|
135
144
|
readonly PublicKeyCompressed: 0x00
|
|
@@ -245,7 +254,7 @@ type StacksTransaction = {
|
|
|
245
254
|
postConditions: PostConditionWire[]
|
|
246
255
|
payload: TransactionPayload
|
|
247
256
|
};
|
|
248
|
-
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;
|
|
257
|
+
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire | StakingPostConditionWire | PoxPostConditionWire;
|
|
249
258
|
type StxPostConditionWire = {
|
|
250
259
|
type: "stx"
|
|
251
260
|
principal: PostConditionPrincipalWire
|
|
@@ -266,6 +275,17 @@ type NftPostConditionWire = {
|
|
|
266
275
|
conditionCode: number
|
|
267
276
|
assetId: ClarityValue
|
|
268
277
|
};
|
|
278
|
+
type StakingPostConditionWire = {
|
|
279
|
+
type: "staking"
|
|
280
|
+
principal: PostConditionPrincipalWire
|
|
281
|
+
conditionCode: number
|
|
282
|
+
amount: bigint
|
|
283
|
+
};
|
|
284
|
+
type PoxPostConditionWire = {
|
|
285
|
+
type: "pox"
|
|
286
|
+
principal: PostConditionPrincipalWire
|
|
287
|
+
conditionCode: PoxConditionCode
|
|
288
|
+
};
|
|
269
289
|
type PostConditionPrincipalWire = {
|
|
270
290
|
type: "origin"
|
|
271
291
|
} | {
|
|
@@ -388,7 +408,19 @@ type NftPostCondition = {
|
|
|
388
408
|
asset: string
|
|
389
409
|
assetId: ClarityValue
|
|
390
410
|
};
|
|
391
|
-
type
|
|
411
|
+
type StakingPostCondition = {
|
|
412
|
+
type: "staking-postcondition"
|
|
413
|
+
address: string
|
|
414
|
+
condition: FungibleComparator
|
|
415
|
+
amount: string | bigint | number
|
|
416
|
+
};
|
|
417
|
+
type PoxComparator = "will-not-perform" | "may-perform" | "will-perform";
|
|
418
|
+
type PoxPostCondition = {
|
|
419
|
+
type: "pox-postcondition"
|
|
420
|
+
address: string
|
|
421
|
+
condition: PoxComparator
|
|
422
|
+
};
|
|
423
|
+
type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition;
|
|
392
424
|
type IntegerType = number | string | bigint | Uint8Array;
|
|
393
425
|
type MultiSigOptions = {
|
|
394
426
|
publicKeys?: string[]
|
|
@@ -454,4 +486,4 @@ declare function signMultiSigWithAccount(tx: StacksTransaction, account: LocalAc
|
|
|
454
486
|
declare function finalizeMultiSig(tx: StacksTransaction, publicKeys: string[]): StacksTransaction;
|
|
455
487
|
/** Combine independently-signed non-sequential multi-sig transactions */
|
|
456
488
|
declare function combineMultiSigSignatures(baseTx: StacksTransaction, signedTxs: StacksTransaction[]): StacksTransaction;
|
|
457
|
-
export { signTransactionWithAccount, signTransaction, signSponsorWithAccount, signSponsor, signMultiSigWithAccount, signMultiSig, signBegin, sigHashPreSign, sigHashPostSign, serializeTransactionHex, serializeTransaction, replayMultiSigSigHash, nextSignature, makeMultiSigAddress, isNonSequential, getTransactionId, getOriginSigHash, finalizeMultiSig, deserializeTransaction, createStandardAuth, createSponsoredAuth, createSingleSigSpendingCondition, createMultiSigSpendingCondition, combineMultiSigSignatures, buildTokenTransfer, buildContractDeploy, buildContractCall, VRF_PROOF_BYTES_LENGTH, TransactionPayload, TransactionAuthField, TokenTransferPayload, TenureChangePayload, TenureChangeCause as TenureChangeCauseType, TenureChangeCause, StandardAuthorization, StacksTransaction, SponsoredAuthorization, SpendingCondition, SmartContractPayload, SingleSigSpendingCondition, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, PubKeyEncoding, PostConditionWire, PostConditionPrincipalId, PostConditionModeWire, PoisonMicroblockPayload, PayloadType, NonFungibleConditionCode, NakamotoCoinbasePayload, MultiSigSpendingCondition, MultiSigHashMode, MICROBLOCK_HEADER_BYTES_LENGTH, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, FungibleConditionCode, ContractCallPayload, CoinbaseToAltRecipientPayload, CoinbasePayload, ClarityVersion, COINBASE_BYTES_LENGTH, BuildTokenTransferOptions, BuildContractDeployOptions, BuildContractCallOptions, Authorization, AuthType, AuthFieldType, AssetType, AnchorMode, AddressHashMode };
|
|
489
|
+
export { signTransactionWithAccount, signTransaction, signSponsorWithAccount, signSponsor, signMultiSigWithAccount, signMultiSig, signBegin, sigHashPreSign, sigHashPostSign, serializeTransactionHex, serializeTransaction, replayMultiSigSigHash, nextSignature, makeMultiSigAddress, isNonSequential, getTransactionId, getOriginSigHash, finalizeMultiSig, deserializeTransaction, createStandardAuth, createSponsoredAuth, createSingleSigSpendingCondition, createMultiSigSpendingCondition, combineMultiSigSignatures, buildTokenTransfer, buildContractDeploy, buildContractCall, VRF_PROOF_BYTES_LENGTH, TransactionPayload, TransactionAuthField, TokenTransferPayload, TenureChangePayload, TenureChangeCause as TenureChangeCauseType, TenureChangeCause, StxPostConditionWire, StandardAuthorization, StakingPostConditionWire, StacksTransaction, SponsoredAuthorization, SpendingCondition, SmartContractPayload, SingleSigSpendingCondition, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, PubKeyEncoding, PoxPostConditionWire, PoxConditionCode, PostConditionWire, PostConditionPrincipalId, PostConditionModeWire, PoisonMicroblockPayload, PayloadType, NonFungibleConditionCode, NftPostConditionWire, NakamotoCoinbasePayload, MultiSigSpendingCondition, MultiSigHashMode, MICROBLOCK_HEADER_BYTES_LENGTH, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, FungibleConditionCode, FtPostConditionWire, ContractCallPayload, CoinbaseToAltRecipientPayload, CoinbasePayload, ClarityVersion, COINBASE_BYTES_LENGTH, BuildTokenTransferOptions, BuildContractDeployOptions, BuildContractCallOptions, Authorization, AuthType, AuthFieldType, AssetType, AnchorMode, AddressHashMode };
|
|
@@ -83,6 +83,7 @@ declare const ClarityVersion: {
|
|
|
83
83
|
readonly Clarity3: 3
|
|
84
84
|
readonly Clarity4: 4
|
|
85
85
|
readonly Clarity5: 5
|
|
86
|
+
readonly Clarity6: 6
|
|
86
87
|
};
|
|
87
88
|
type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];
|
|
88
89
|
declare const AnchorMode: {
|
|
@@ -121,6 +122,12 @@ declare const NonFungibleConditionCode: {
|
|
|
121
122
|
readonly Sends: 0x10
|
|
122
123
|
readonly DoesNotSend: 0x11
|
|
123
124
|
};
|
|
125
|
+
declare const PoxConditionCode: {
|
|
126
|
+
readonly WillNotPerform: 0x30
|
|
127
|
+
readonly MayPerform: 0x31
|
|
128
|
+
readonly WillPerform: 0x32
|
|
129
|
+
};
|
|
130
|
+
type PoxConditionCode = (typeof PoxConditionCode)[keyof typeof PoxConditionCode];
|
|
124
131
|
declare const PostConditionPrincipalId: {
|
|
125
132
|
readonly Origin: 0x01
|
|
126
133
|
readonly Standard: 0x02
|
|
@@ -130,6 +137,8 @@ declare const AssetType: {
|
|
|
130
137
|
readonly STX: 0x00
|
|
131
138
|
readonly Fungible: 0x01
|
|
132
139
|
readonly NonFungible: 0x02
|
|
140
|
+
readonly Staking: 0x03
|
|
141
|
+
readonly Pox: 0x04
|
|
133
142
|
};
|
|
134
143
|
declare const AuthFieldType: {
|
|
135
144
|
readonly PublicKeyCompressed: 0x00
|
|
@@ -245,7 +254,7 @@ type StacksTransaction = {
|
|
|
245
254
|
postConditions: PostConditionWire[]
|
|
246
255
|
payload: TransactionPayload
|
|
247
256
|
};
|
|
248
|
-
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;
|
|
257
|
+
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire | StakingPostConditionWire | PoxPostConditionWire;
|
|
249
258
|
type StxPostConditionWire = {
|
|
250
259
|
type: "stx"
|
|
251
260
|
principal: PostConditionPrincipalWire
|
|
@@ -266,6 +275,17 @@ type NftPostConditionWire = {
|
|
|
266
275
|
conditionCode: number
|
|
267
276
|
assetId: ClarityValue
|
|
268
277
|
};
|
|
278
|
+
type StakingPostConditionWire = {
|
|
279
|
+
type: "staking"
|
|
280
|
+
principal: PostConditionPrincipalWire
|
|
281
|
+
conditionCode: number
|
|
282
|
+
amount: bigint
|
|
283
|
+
};
|
|
284
|
+
type PoxPostConditionWire = {
|
|
285
|
+
type: "pox"
|
|
286
|
+
principal: PostConditionPrincipalWire
|
|
287
|
+
conditionCode: PoxConditionCode
|
|
288
|
+
};
|
|
269
289
|
type PostConditionPrincipalWire = {
|
|
270
290
|
type: "origin"
|
|
271
291
|
} | {
|
|
@@ -388,7 +408,19 @@ type NftPostCondition = {
|
|
|
388
408
|
asset: string
|
|
389
409
|
assetId: ClarityValue
|
|
390
410
|
};
|
|
391
|
-
type
|
|
411
|
+
type StakingPostCondition = {
|
|
412
|
+
type: "staking-postcondition"
|
|
413
|
+
address: string
|
|
414
|
+
condition: FungibleComparator
|
|
415
|
+
amount: string | bigint | number
|
|
416
|
+
};
|
|
417
|
+
type PoxComparator = "will-not-perform" | "may-perform" | "will-perform";
|
|
418
|
+
type PoxPostCondition = {
|
|
419
|
+
type: "pox-postcondition"
|
|
420
|
+
address: string
|
|
421
|
+
condition: PoxComparator
|
|
422
|
+
};
|
|
423
|
+
type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition;
|
|
392
424
|
type IntegerType = number | string | bigint | Uint8Array;
|
|
393
425
|
type MultiSigOptions = {
|
|
394
426
|
publicKeys?: string[]
|
|
@@ -454,4 +486,4 @@ declare function signMultiSigWithAccount(tx: StacksTransaction, account: LocalAc
|
|
|
454
486
|
declare function finalizeMultiSig(tx: StacksTransaction, publicKeys: string[]): StacksTransaction;
|
|
455
487
|
/** Combine independently-signed non-sequential multi-sig transactions */
|
|
456
488
|
declare function combineMultiSigSignatures(baseTx: StacksTransaction, signedTxs: StacksTransaction[]): StacksTransaction;
|
|
457
|
-
export { signTransactionWithAccount, signTransaction, signSponsorWithAccount, signSponsor, signMultiSigWithAccount, signMultiSig, signBegin, sigHashPreSign, sigHashPostSign, serializeTransactionHex, serializeTransaction, replayMultiSigSigHash, nextSignature, makeMultiSigAddress, isNonSequential, getTransactionId, getOriginSigHash, finalizeMultiSig, deserializeTransaction, createStandardAuth, createSponsoredAuth, createSingleSigSpendingCondition, createMultiSigSpendingCondition, combineMultiSigSignatures, buildTokenTransfer, buildContractDeploy, buildContractCall, VRF_PROOF_BYTES_LENGTH, TransactionPayload, TransactionAuthField, TokenTransferPayload, TenureChangePayload, TenureChangeCause as TenureChangeCauseType, TenureChangeCause, StandardAuthorization, StacksTransaction, SponsoredAuthorization, SpendingCondition, SmartContractPayload, SingleSigSpendingCondition, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, PubKeyEncoding, PostConditionWire, PostConditionPrincipalId, PostConditionModeWire, PoisonMicroblockPayload, PayloadType, NonFungibleConditionCode, NakamotoCoinbasePayload, MultiSigSpendingCondition, MultiSigHashMode, MICROBLOCK_HEADER_BYTES_LENGTH, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, FungibleConditionCode, ContractCallPayload, CoinbaseToAltRecipientPayload, CoinbasePayload, ClarityVersion, COINBASE_BYTES_LENGTH, BuildTokenTransferOptions, BuildContractDeployOptions, BuildContractCallOptions, Authorization, AuthType, AuthFieldType, AssetType, AnchorMode, AddressHashMode };
|
|
489
|
+
export { signTransactionWithAccount, signTransaction, signSponsorWithAccount, signSponsor, signMultiSigWithAccount, signMultiSig, signBegin, sigHashPreSign, sigHashPostSign, serializeTransactionHex, serializeTransaction, replayMultiSigSigHash, nextSignature, makeMultiSigAddress, isNonSequential, getTransactionId, getOriginSigHash, finalizeMultiSig, deserializeTransaction, createStandardAuth, createSponsoredAuth, createSingleSigSpendingCondition, createMultiSigSpendingCondition, combineMultiSigSignatures, buildTokenTransfer, buildContractDeploy, buildContractCall, VRF_PROOF_BYTES_LENGTH, TransactionPayload, TransactionAuthField, TokenTransferPayload, TenureChangePayload, TenureChangeCause as TenureChangeCauseType, TenureChangeCause, StxPostConditionWire, StandardAuthorization, StakingPostConditionWire, StacksTransaction, SponsoredAuthorization, SpendingCondition, SmartContractPayload, SingleSigSpendingCondition, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, PubKeyEncoding, PoxPostConditionWire, PoxConditionCode, PostConditionWire, PostConditionPrincipalId, PostConditionModeWire, PoisonMicroblockPayload, PayloadType, NonFungibleConditionCode, NftPostConditionWire, NakamotoCoinbasePayload, MultiSigSpendingCondition, MultiSigHashMode, MICROBLOCK_HEADER_BYTES_LENGTH, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, FungibleConditionCode, FtPostConditionWire, ContractCallPayload, CoinbaseToAltRecipientPayload, CoinbasePayload, ClarityVersion, COINBASE_BYTES_LENGTH, BuildTokenTransferOptions, BuildContractDeployOptions, BuildContractCallOptions, Authorization, AuthType, AuthFieldType, AssetType, AnchorMode, AddressHashMode };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deserializeTransaction
|
|
3
|
-
} from "../../shared/stacks-
|
|
3
|
+
} from "../../shared/stacks-g11v9a35.js";
|
|
4
4
|
import {
|
|
5
5
|
AddressHashMode,
|
|
6
6
|
AnchorMode,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
PayloadType,
|
|
18
18
|
PostConditionModeWire,
|
|
19
19
|
PostConditionPrincipalId,
|
|
20
|
+
PoxConditionCode,
|
|
20
21
|
PubKeyEncoding,
|
|
21
22
|
RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,
|
|
22
23
|
TenureChangeCause,
|
|
@@ -47,11 +48,10 @@ import {
|
|
|
47
48
|
signSponsorWithAccount,
|
|
48
49
|
signTransaction,
|
|
49
50
|
signTransactionWithAccount
|
|
50
|
-
} from "../../shared/stacks-
|
|
51
|
-
import"../../shared/stacks-
|
|
52
|
-
import"../../shared/stacks-
|
|
53
|
-
import"../../shared/stacks-
|
|
54
|
-
import"../../shared/stacks-2h8d2y27.js";
|
|
51
|
+
} from "../../shared/stacks-ssndnbbd.js";
|
|
52
|
+
import"../../shared/stacks-2mm20wqf.js";
|
|
53
|
+
import"../../shared/stacks-azp00pve.js";
|
|
54
|
+
import"../../shared/stacks-qs5fzts5.js";
|
|
55
55
|
import"../../shared/stacks-cfazrteq.js";
|
|
56
56
|
export {
|
|
57
57
|
signTransactionWithAccount,
|
|
@@ -85,6 +85,7 @@ export {
|
|
|
85
85
|
TenureChangeCause,
|
|
86
86
|
RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,
|
|
87
87
|
PubKeyEncoding,
|
|
88
|
+
PoxConditionCode,
|
|
88
89
|
PostConditionPrincipalId,
|
|
89
90
|
PostConditionModeWire,
|
|
90
91
|
PayloadType,
|
|
@@ -102,5 +103,5 @@ export {
|
|
|
102
103
|
AddressHashMode
|
|
103
104
|
};
|
|
104
105
|
|
|
105
|
-
//# debugId=
|
|
106
|
+
//# debugId=AE530DDA13A7DED764756E2164756E21
|
|
106
107
|
//# sourceMappingURL=index.js.map
|
package/dist/src/utils/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ __export(exports_utils, {
|
|
|
24
24
|
readUInt32BE: () => readUInt32BE,
|
|
25
25
|
readUInt16BE: () => readUInt16BE,
|
|
26
26
|
randomBytes: () => randomBytes,
|
|
27
|
+
publicKeyToAddress: () => publicKeyToAddress,
|
|
27
28
|
parseUnits: () => parseUnits,
|
|
28
29
|
parseStx: () => parseStx,
|
|
29
30
|
parseSignature: () => parseSignature,
|
|
@@ -164,5 +165,5 @@ function randomBytes(length) {
|
|
|
164
165
|
return import_secp256k12.etc.randomBytes(length ?? 32);
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
//# debugId=
|
|
168
|
+
//# debugId=C42746B9BE1DE3FC64756E2164756E21
|
|
168
169
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { Signature as NobleSignature, verify } from \"@noble/secp256k1\";\nimport { c32address } from \"./address.ts\";\nimport { AddressVersion } from \"./constants.ts\";\nimport { concatBytes, hexToBytes, utf8ToBytes } from \"./encoding.ts\";\nimport { hashP2PKH } from \"./hash.ts\";\n\nexport interface RecoverableSignature {\n\t/** Recovery id (0–3) */\n\trecovery: number;\n\t/** 32-byte r value as hex */\n\tr: string;\n\t/** 32-byte s value as hex */\n\ts: string;\n}\n\n// --- Format conversion ---\n\n/**\n * Parse a 65-byte VRS hex signature into components.\n * VRS format: recovery (1 byte) + r (32 bytes) + s (32 bytes)\n */\nexport function parseSignature(hex: string): RecoverableSignature {\n\tconst clean = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n\tif (clean.length !== 130) {\n\t\tthrow new Error(\n\t\t\t`Invalid signature length: expected 130 hex chars, got ${clean.length}`,\n\t\t);\n\t}\n\treturn {\n\t\trecovery: Number.parseInt(clean.slice(0, 2), 16),\n\t\tr: clean.slice(2, 66),\n\t\ts: clean.slice(66, 130),\n\t};\n}\n\n/**\n * Serialize a recoverable signature to 65-byte VRS hex (130 chars).\n */\nexport function serializeSignature(sig: RecoverableSignature): string {\n\tconst v = sig.recovery.toString(16).padStart(2, \"0\");\n\treturn v + sig.r + sig.s;\n}\n\n/** Convert VRS hex to RSV hex: r+s (128 chars) + recovery (2 chars). */\nexport function signatureVrsToRsv(vrs: string): string {\n\tconst clean = vrs.startsWith(\"0x\") ? vrs.slice(2) : vrs;\n\treturn clean.slice(2) + clean.slice(0, 2);\n}\n\n/** Convert RSV hex to VRS hex: recovery (2 chars) + r+s (128 chars). */\nexport function signatureRsvToVrs(rsv: string): string {\n\tconst clean = rsv.startsWith(\"0x\") ? rsv.slice(2) : rsv;\n\treturn clean.slice(-2) + clean.slice(0, -2);\n}\n\n// --- Recovery ---\n\n/**\n * Recover a public key from a message hash and VRS signature.\n * @returns hex-encoded public key (33 bytes compressed, or 65 bytes uncompressed)\n */\nexport function recoverPublicKey(\n\thash: Uint8Array | string,\n\tsignature: string,\n\tcompressed = true,\n): string {\n\tconst parsed = parseSignature(signature);\n\tconst rs = parsed.r + parsed.s;\n\tconst sig = NobleSignature.fromCompact(rs).addRecoveryBit(parsed.recovery);\n\tconst msgHash = typeof hash === \"string\" ? hexToBytes(hash) : hash;\n\tconst point = sig.recoverPublicKey(msgHash);\n\treturn point.toHex(compressed);\n}\n\n/**\n * Recover a Stacks address from a message hash and VRS signature.\n * @param addressVersion defaults to MainnetSingleSig (22)\n */\nexport function recoverAddress(\n\thash: Uint8Array | string,\n\tsignature: string,\n\taddressVersion: number = AddressVersion.MainnetSingleSig,\n): string {\n\tconst pubkey = recoverPublicKey(hash, signature, true);\n\tconst pubkeyHash = hashP2PKH(hexToBytes(pubkey));\n\treturn c32address(addressVersion, pubkeyHash);\n}\n\n// --- Verification ---\n\n/**\n * Verify an ECDSA signature against a message hash and public key.\n * Accepts compact (64-byte) signature as hex or Uint8Array.\n */\nexport function verifySignature(\n\thash: Uint8Array | string,\n\tsignature: string | Uint8Array,\n\tpublicKey: string | Uint8Array,\n): boolean {\n\treturn verify(signature, hash, publicKey, { lowS: false });\n}\n\n/** Bitcoin-style varint encoding for message length prefix. */\nfunction encodeVarint(n: number): Uint8Array {\n\tif (n < 0xfd) return new Uint8Array([n]);\n\tif (n <= 0xffff) {\n\t\tconst buf = new Uint8Array(3);\n\t\tbuf[0] = 0xfd;\n\t\tbuf[1] = n & 0xff;\n\t\tbuf[2] = (n >> 8) & 0xff;\n\t\treturn buf;\n\t}\n\tconst buf = new Uint8Array(5);\n\tbuf[0] = 0xfe;\n\tbuf[1] = n & 0xff;\n\tbuf[2] = (n >> 8) & 0xff;\n\tbuf[3] = (n >> 16) & 0xff;\n\tbuf[4] = (n >> 24) & 0xff;\n\treturn buf;\n}\n\nconst STACKS_MESSAGE_PREFIX = \"\\x17Stacks Signed Message:\\n\";\nconst LEGACY_MESSAGE_PREFIX = \"\\x18Stacks Message Signing:\\n\";\n\n/** Hash a message with the Stacks structured message prefix. */\nfunction hashMessage(message: string | Uint8Array, prefix: string): Uint8Array {\n\tconst messageBytes =\n\t\ttypeof message === \"string\" ? utf8ToBytes(message) : message;\n\tconst prefixBytes = utf8ToBytes(prefix);\n\tconst lengthBytes = encodeVarint(messageBytes.length);\n\treturn sha256(concatBytes(prefixBytes, lengthBytes, messageBytes));\n}\n\n/**\n * Verify a signed Stacks message.\n * Parses a VRS signature, extracts r+s for verification.\n * Falls back to legacy prefix if standard prefix fails.\n */\nexport function verifyMessageSignature(\n\tmessage: string | Uint8Array,\n\tsignature: string,\n\tpublicKey: string,\n): boolean {\n\tconst parsed = parseSignature(signature);\n\tconst compactSig = parsed.r + parsed.s;\n\n\tconst msgHash = hashMessage(message, STACKS_MESSAGE_PREFIX);\n\tif (verify(compactSig, msgHash, publicKey, { lowS: false })) return true;\n\n\t// Fallback to legacy prefix\n\tif (typeof message === \"string\") {\n\t\tconst legacyHash = hashMessage(message, LEGACY_MESSAGE_PREFIX);\n\t\tif (verify(compactSig, legacyHash, publicKey, { lowS: false })) return true;\n\t}\n\n\treturn false;\n}\n",
|
|
6
6
|
"import { Point, etc } from \"@noble/secp256k1\";\nimport { bytesToHex, hexToBytes } from \"./encoding.ts\";\n\n/** Compress a public key to 33 bytes (hex). */\nexport function compressPublicKey(publicKey: string | Uint8Array): string {\n\tconst hex = typeof publicKey === \"string\" ? publicKey : bytesToHex(publicKey);\n\treturn Point.fromHex(hex).toHex(true);\n}\n\n/** Uncompress a public key to 65 bytes (hex). */\nexport function uncompressPublicKey(publicKey: string | Uint8Array): string {\n\tconst hex = typeof publicKey === \"string\" ? publicKey : bytesToHex(publicKey);\n\treturn Point.fromHex(hex).toHex(false);\n}\n\n/** Check if a public key is in compressed format (starts with 0x02 or 0x03). */\nexport function isCompressedPublicKey(publicKey: string | Uint8Array): boolean {\n\tconst bytes =\n\t\ttypeof publicKey === \"string\" ? hexToBytes(publicKey) : publicKey;\n\treturn bytes.length === 33 && (bytes[0] === 0x02 || bytes[0] === 0x03);\n}\n\n/** Generate cryptographically secure random bytes. Defaults to 32 bytes. */\nexport function randomBytes(length?: number): Uint8Array {\n\treturn etc.randomBytes(length ?? 32);\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": "
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAuB,IAAvB;AACoD,IAApD;AAqBO,SAAS,cAAc,CAAC,KAAmC;AAAA,EACjE,MAAM,QAAQ,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,EACpD,IAA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AW,EAAE,MAAM,MAAM,CAAC;AAAA,IAAG,OAAO;AAAA,EAGpE,IAAI,OAAO,YAAY,UAAU;AAAA,IAChC,MAAM,aAAa,YAAY,SAAS,qBAAqB;AAAA,IAC7D,IAAI,wBAAO,YAAY,YAAY,WAAW,EAAE,MAAM,MAAM,CAAC;AAAA,MAAG,OAAO;AAAA,EACxE;AAAA,EAEA,OAAO;AAAA;;AC5JmB,IAA3B;AAIO,SAAS,iBAAiB,CAAC,WAAwC;AAAA,EACzE,MAAM,MAAM,OAAO,cAAc,WAAW,YAAY,WAAW,SAAS;AAAA,EAC5E,OAAO,wBAAM,QAAQ,GAAG,EAAE,MAAM,IAAI;AAAA;AAI9B,SAAS,mBAAmB,CAAC,WAAwC;AAAA,EAC3E,MAAM,MAAM,OAAO,cAAc,WAAW,YAAY,WAAW,SAAS;AAAA,EAC5E,OAAO,wBAAM,QAAQ,GAAG,EAAE,MAAM,KAAK;AAAA;AAI/B,SAAS,qBAAqB,CAAC,WAAyC;AAAA,EAC9E,MAAM,QACL,OAAO,cAAc,WAAW,WAAW,SAAS,IAAI;AAAA,EACzD,OAAO,MAAM,WAAW,OAAO,MAAM,OAAO,KAAQ,MAAM,OAAO;AAAA;AAI3D,SAAS,WAAW,CAAC,QAA6B;AAAA,EACxD,OAAO,sBAAI,YAAY,UAAU,EAAE;AAAA;",
|
|
9
|
+
"debugId": "C42746B9BE1DE3FC64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -31,6 +31,10 @@ declare function txidFromBytes(data: Uint8Array): string;
|
|
|
31
31
|
declare function hashP2PKH(input: Uint8Array): string;
|
|
32
32
|
declare function c32address(version: number, hash160hex: string): string;
|
|
33
33
|
declare function c32addressDecode(c32addr: string): [number, string];
|
|
34
|
+
/**
|
|
35
|
+
* Derive the single-sig Stacks address for a compressed public key.
|
|
36
|
+
*/
|
|
37
|
+
declare function publicKeyToAddress(publicKey: string | Uint8Array, network?: "mainnet" | "testnet"): string;
|
|
34
38
|
declare function validateStacksAddress(address: string): boolean;
|
|
35
39
|
/** Alias for validateStacksAddress — matches future.md naming. */
|
|
36
40
|
declare const isValidAddress: (address: string) => boolean;
|
|
@@ -137,4 +141,4 @@ declare function uncompressPublicKey(publicKey: string | Uint8Array): string;
|
|
|
137
141
|
declare function isCompressedPublicKey(publicKey: string | Uint8Array): boolean;
|
|
138
142
|
/** Generate cryptographically secure random bytes. Defaults to 32 bytes. */
|
|
139
143
|
declare function randomBytes(length?: number): Uint8Array;
|
|
140
|
-
export { writeUInt8, writeUInt32BE, writeUInt16BE, without0x, with0x, verifySignature, verifyMessageSignature, validateStacksAddress, utf8ToBytes, uncompressPublicKey, txidFromBytes, toTwos, signatureVrsToRsv, signatureRsvToVrs, sha512_256, sha256, serializeSignature, ripemd160, recoverPublicKey, recoverAddress, readUInt32BE, readUInt16BE, randomBytes, parseUnits, parseStx, parseSignature, parseContractId, isValidAddress, isCompressedPublicKey, isClarityName, isAddressEqual, intToHex, intToBytes, intToBigInt, hexToBytes, hashP2PKH, hash160, getContractAddress, fromTwos, formatUnits, formatStx, concatBytes, compressPublicKey, c32addressDecode, c32address, bytesToUtf8, bytesToTwosBigInt, bytesToHex, bytesToAscii, bigIntToBytes, asciiToBytes, addressToVersion, ZERO_ADDRESS, TESTNET_ZERO_ADDRESS, RecoverableSignature, MIN_I128, MICROSTX_PER_STX, MAX_U128, MAX_I128, IntegerType, AddressVersion };
|
|
144
|
+
export { writeUInt8, writeUInt32BE, writeUInt16BE, without0x, with0x, verifySignature, verifyMessageSignature, validateStacksAddress, utf8ToBytes, uncompressPublicKey, txidFromBytes, toTwos, signatureVrsToRsv, signatureRsvToVrs, sha512_256, sha256, serializeSignature, ripemd160, recoverPublicKey, recoverAddress, readUInt32BE, readUInt16BE, randomBytes, publicKeyToAddress, parseUnits, parseStx, parseSignature, parseContractId, isValidAddress, isCompressedPublicKey, isClarityName, isAddressEqual, intToHex, intToBytes, intToBigInt, hexToBytes, hashP2PKH, hash160, getContractAddress, fromTwos, formatUnits, formatStx, concatBytes, compressPublicKey, c32addressDecode, c32address, bytesToUtf8, bytesToTwosBigInt, bytesToHex, bytesToAscii, bigIntToBytes, asciiToBytes, addressToVersion, ZERO_ADDRESS, TESTNET_ZERO_ADDRESS, RecoverableSignature, MIN_I128, MICROSTX_PER_STX, MAX_U128, MAX_I128, IntegerType, AddressVersion };
|
|
@@ -31,6 +31,10 @@ declare function txidFromBytes(data: Uint8Array): string;
|
|
|
31
31
|
declare function hashP2PKH(input: Uint8Array): string;
|
|
32
32
|
declare function c32address(version: number, hash160hex: string): string;
|
|
33
33
|
declare function c32addressDecode(c32addr: string): [number, string];
|
|
34
|
+
/**
|
|
35
|
+
* Derive the single-sig Stacks address for a compressed public key.
|
|
36
|
+
*/
|
|
37
|
+
declare function publicKeyToAddress(publicKey: string | Uint8Array, network?: "mainnet" | "testnet"): string;
|
|
34
38
|
declare function validateStacksAddress(address: string): boolean;
|
|
35
39
|
/** Alias for validateStacksAddress — matches future.md naming. */
|
|
36
40
|
declare const isValidAddress: (address: string) => boolean;
|
|
@@ -137,4 +141,4 @@ declare function uncompressPublicKey(publicKey: string | Uint8Array): string;
|
|
|
137
141
|
declare function isCompressedPublicKey(publicKey: string | Uint8Array): boolean;
|
|
138
142
|
/** Generate cryptographically secure random bytes. Defaults to 32 bytes. */
|
|
139
143
|
declare function randomBytes(length?: number): Uint8Array;
|
|
140
|
-
export { writeUInt8, writeUInt32BE, writeUInt16BE, without0x, with0x, verifySignature, verifyMessageSignature, validateStacksAddress, utf8ToBytes, uncompressPublicKey, txidFromBytes, toTwos, signatureVrsToRsv, signatureRsvToVrs, sha512_256, sha256, serializeSignature, ripemd160, recoverPublicKey, recoverAddress, readUInt32BE, readUInt16BE, randomBytes, parseUnits, parseStx, parseSignature, parseContractId, isValidAddress, isCompressedPublicKey, isClarityName, isAddressEqual, intToHex, intToBytes, intToBigInt, hexToBytes, hashP2PKH, hash160, getContractAddress, fromTwos, formatUnits, formatStx, concatBytes, compressPublicKey, c32addressDecode, c32address, bytesToUtf8, bytesToTwosBigInt, bytesToHex, bytesToAscii, bigIntToBytes, asciiToBytes, addressToVersion, ZERO_ADDRESS, TESTNET_ZERO_ADDRESS, RecoverableSignature, MIN_I128, MICROSTX_PER_STX, MAX_U128, MAX_I128, IntegerType, AddressVersion };
|
|
144
|
+
export { writeUInt8, writeUInt32BE, writeUInt16BE, without0x, with0x, verifySignature, verifyMessageSignature, validateStacksAddress, utf8ToBytes, uncompressPublicKey, txidFromBytes, toTwos, signatureVrsToRsv, signatureRsvToVrs, sha512_256, sha256, serializeSignature, ripemd160, recoverPublicKey, recoverAddress, readUInt32BE, readUInt16BE, randomBytes, publicKeyToAddress, parseUnits, parseStx, parseSignature, parseContractId, isValidAddress, isCompressedPublicKey, isClarityName, isAddressEqual, intToHex, intToBytes, intToBigInt, hexToBytes, hashP2PKH, hash160, getContractAddress, fromTwos, formatUnits, formatStx, concatBytes, compressPublicKey, c32addressDecode, c32address, bytesToUtf8, bytesToTwosBigInt, bytesToHex, bytesToAscii, bigIntToBytes, asciiToBytes, addressToVersion, ZERO_ADDRESS, TESTNET_ZERO_ADDRESS, RecoverableSignature, MIN_I128, MICROSTX_PER_STX, MAX_U128, MAX_I128, IntegerType, AddressVersion };
|
package/dist/src/utils/index.js
CHANGED
|
@@ -11,25 +11,16 @@ import {
|
|
|
11
11
|
MICROSTX_PER_STX,
|
|
12
12
|
MIN_I128,
|
|
13
13
|
TESTNET_ZERO_ADDRESS,
|
|
14
|
-
ZERO_ADDRESS
|
|
15
|
-
} from "../../shared/stacks-v9jqcpd4.js";
|
|
16
|
-
import {
|
|
17
|
-
hash160,
|
|
18
|
-
hashP2PKH,
|
|
19
|
-
ripemd160,
|
|
20
|
-
sha256,
|
|
21
|
-
sha512_256,
|
|
22
|
-
txidFromBytes
|
|
23
|
-
} from "../../shared/stacks-xxn5ma6g.js";
|
|
24
|
-
import {
|
|
14
|
+
ZERO_ADDRESS,
|
|
25
15
|
addressToVersion,
|
|
26
16
|
getContractAddress,
|
|
27
17
|
isAddressEqual,
|
|
28
18
|
isClarityName,
|
|
29
19
|
isValidAddress,
|
|
30
20
|
parseContractId,
|
|
21
|
+
publicKeyToAddress,
|
|
31
22
|
validateStacksAddress
|
|
32
|
-
} from "../../shared/stacks-
|
|
23
|
+
} from "../../shared/stacks-azp00pve.js";
|
|
33
24
|
import {
|
|
34
25
|
asciiToBytes,
|
|
35
26
|
bigIntToBytes,
|
|
@@ -41,20 +32,26 @@ import {
|
|
|
41
32
|
c32addressDecode,
|
|
42
33
|
concatBytes,
|
|
43
34
|
fromTwos,
|
|
35
|
+
hash160,
|
|
36
|
+
hashP2PKH,
|
|
44
37
|
hexToBytes,
|
|
45
38
|
intToBigInt,
|
|
46
39
|
intToBytes,
|
|
47
40
|
intToHex,
|
|
48
41
|
readUInt16BE,
|
|
49
42
|
readUInt32BE,
|
|
43
|
+
ripemd160,
|
|
44
|
+
sha256,
|
|
45
|
+
sha512_256,
|
|
50
46
|
toTwos,
|
|
47
|
+
txidFromBytes,
|
|
51
48
|
utf8ToBytes,
|
|
52
49
|
with0x,
|
|
53
50
|
without0x,
|
|
54
51
|
writeUInt16BE,
|
|
55
52
|
writeUInt32BE,
|
|
56
53
|
writeUInt8
|
|
57
|
-
} from "../../shared/stacks-
|
|
54
|
+
} from "../../shared/stacks-qs5fzts5.js";
|
|
58
55
|
import"../../shared/stacks-cfazrteq.js";
|
|
59
56
|
// src/utils/signature.ts
|
|
60
57
|
import { sha256 as sha2562 } from "@noble/hashes/sha2.js";
|
|
@@ -180,6 +177,7 @@ export {
|
|
|
180
177
|
readUInt32BE,
|
|
181
178
|
readUInt16BE,
|
|
182
179
|
randomBytes,
|
|
180
|
+
publicKeyToAddress,
|
|
183
181
|
parseUnits,
|
|
184
182
|
parseStx,
|
|
185
183
|
parseSignature,
|
|
@@ -218,5 +216,5 @@ export {
|
|
|
218
216
|
AddressVersion
|
|
219
217
|
};
|
|
220
218
|
|
|
221
|
-
//# debugId=
|
|
219
|
+
//# debugId=F99004DF2704D3DE64756E2164756E21
|
|
222
220
|
//# sourceMappingURL=index.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { Signature as NobleSignature, verify } from \"@noble/secp256k1\";\nimport { c32address } from \"./address.ts\";\nimport { AddressVersion } from \"./constants.ts\";\nimport { concatBytes, hexToBytes, utf8ToBytes } from \"./encoding.ts\";\nimport { hashP2PKH } from \"./hash.ts\";\n\nexport interface RecoverableSignature {\n\t/** Recovery id (0–3) */\n\trecovery: number;\n\t/** 32-byte r value as hex */\n\tr: string;\n\t/** 32-byte s value as hex */\n\ts: string;\n}\n\n// --- Format conversion ---\n\n/**\n * Parse a 65-byte VRS hex signature into components.\n * VRS format: recovery (1 byte) + r (32 bytes) + s (32 bytes)\n */\nexport function parseSignature(hex: string): RecoverableSignature {\n\tconst clean = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n\tif (clean.length !== 130) {\n\t\tthrow new Error(\n\t\t\t`Invalid signature length: expected 130 hex chars, got ${clean.length}`,\n\t\t);\n\t}\n\treturn {\n\t\trecovery: Number.parseInt(clean.slice(0, 2), 16),\n\t\tr: clean.slice(2, 66),\n\t\ts: clean.slice(66, 130),\n\t};\n}\n\n/**\n * Serialize a recoverable signature to 65-byte VRS hex (130 chars).\n */\nexport function serializeSignature(sig: RecoverableSignature): string {\n\tconst v = sig.recovery.toString(16).padStart(2, \"0\");\n\treturn v + sig.r + sig.s;\n}\n\n/** Convert VRS hex to RSV hex: r+s (128 chars) + recovery (2 chars). */\nexport function signatureVrsToRsv(vrs: string): string {\n\tconst clean = vrs.startsWith(\"0x\") ? vrs.slice(2) : vrs;\n\treturn clean.slice(2) + clean.slice(0, 2);\n}\n\n/** Convert RSV hex to VRS hex: recovery (2 chars) + r+s (128 chars). */\nexport function signatureRsvToVrs(rsv: string): string {\n\tconst clean = rsv.startsWith(\"0x\") ? rsv.slice(2) : rsv;\n\treturn clean.slice(-2) + clean.slice(0, -2);\n}\n\n// --- Recovery ---\n\n/**\n * Recover a public key from a message hash and VRS signature.\n * @returns hex-encoded public key (33 bytes compressed, or 65 bytes uncompressed)\n */\nexport function recoverPublicKey(\n\thash: Uint8Array | string,\n\tsignature: string,\n\tcompressed = true,\n): string {\n\tconst parsed = parseSignature(signature);\n\tconst rs = parsed.r + parsed.s;\n\tconst sig = NobleSignature.fromCompact(rs).addRecoveryBit(parsed.recovery);\n\tconst msgHash = typeof hash === \"string\" ? hexToBytes(hash) : hash;\n\tconst point = sig.recoverPublicKey(msgHash);\n\treturn point.toHex(compressed);\n}\n\n/**\n * Recover a Stacks address from a message hash and VRS signature.\n * @param addressVersion defaults to MainnetSingleSig (22)\n */\nexport function recoverAddress(\n\thash: Uint8Array | string,\n\tsignature: string,\n\taddressVersion: number = AddressVersion.MainnetSingleSig,\n): string {\n\tconst pubkey = recoverPublicKey(hash, signature, true);\n\tconst pubkeyHash = hashP2PKH(hexToBytes(pubkey));\n\treturn c32address(addressVersion, pubkeyHash);\n}\n\n// --- Verification ---\n\n/**\n * Verify an ECDSA signature against a message hash and public key.\n * Accepts compact (64-byte) signature as hex or Uint8Array.\n */\nexport function verifySignature(\n\thash: Uint8Array | string,\n\tsignature: string | Uint8Array,\n\tpublicKey: string | Uint8Array,\n): boolean {\n\treturn verify(signature, hash, publicKey, { lowS: false });\n}\n\n/** Bitcoin-style varint encoding for message length prefix. */\nfunction encodeVarint(n: number): Uint8Array {\n\tif (n < 0xfd) return new Uint8Array([n]);\n\tif (n <= 0xffff) {\n\t\tconst buf = new Uint8Array(3);\n\t\tbuf[0] = 0xfd;\n\t\tbuf[1] = n & 0xff;\n\t\tbuf[2] = (n >> 8) & 0xff;\n\t\treturn buf;\n\t}\n\tconst buf = new Uint8Array(5);\n\tbuf[0] = 0xfe;\n\tbuf[1] = n & 0xff;\n\tbuf[2] = (n >> 8) & 0xff;\n\tbuf[3] = (n >> 16) & 0xff;\n\tbuf[4] = (n >> 24) & 0xff;\n\treturn buf;\n}\n\nconst STACKS_MESSAGE_PREFIX = \"\\x17Stacks Signed Message:\\n\";\nconst LEGACY_MESSAGE_PREFIX = \"\\x18Stacks Message Signing:\\n\";\n\n/** Hash a message with the Stacks structured message prefix. */\nfunction hashMessage(message: string | Uint8Array, prefix: string): Uint8Array {\n\tconst messageBytes =\n\t\ttypeof message === \"string\" ? utf8ToBytes(message) : message;\n\tconst prefixBytes = utf8ToBytes(prefix);\n\tconst lengthBytes = encodeVarint(messageBytes.length);\n\treturn sha256(concatBytes(prefixBytes, lengthBytes, messageBytes));\n}\n\n/**\n * Verify a signed Stacks message.\n * Parses a VRS signature, extracts r+s for verification.\n * Falls back to legacy prefix if standard prefix fails.\n */\nexport function verifyMessageSignature(\n\tmessage: string | Uint8Array,\n\tsignature: string,\n\tpublicKey: string,\n): boolean {\n\tconst parsed = parseSignature(signature);\n\tconst compactSig = parsed.r + parsed.s;\n\n\tconst msgHash = hashMessage(message, STACKS_MESSAGE_PREFIX);\n\tif (verify(compactSig, msgHash, publicKey, { lowS: false })) return true;\n\n\t// Fallback to legacy prefix\n\tif (typeof message === \"string\") {\n\t\tconst legacyHash = hashMessage(message, LEGACY_MESSAGE_PREFIX);\n\t\tif (verify(compactSig, legacyHash, publicKey, { lowS: false })) return true;\n\t}\n\n\treturn false;\n}\n",
|
|
6
6
|
"import { Point, etc } from \"@noble/secp256k1\";\nimport { bytesToHex, hexToBytes } from \"./encoding.ts\";\n\n/** Compress a public key to 33 bytes (hex). */\nexport function compressPublicKey(publicKey: string | Uint8Array): string {\n\tconst hex = typeof publicKey === \"string\" ? publicKey : bytesToHex(publicKey);\n\treturn Point.fromHex(hex).toHex(true);\n}\n\n/** Uncompress a public key to 65 bytes (hex). */\nexport function uncompressPublicKey(publicKey: string | Uint8Array): string {\n\tconst hex = typeof publicKey === \"string\" ? publicKey : bytesToHex(publicKey);\n\treturn Point.fromHex(hex).toHex(false);\n}\n\n/** Check if a public key is in compressed format (starts with 0x02 or 0x03). */\nexport function isCompressedPublicKey(publicKey: string | Uint8Array): boolean {\n\tconst bytes =\n\t\ttypeof publicKey === \"string\" ? hexToBytes(publicKey) : publicKey;\n\treturn bytes.length === 33 && (bytes[0] === 0x02 || bytes[0] === 0x03);\n}\n\n/** Generate cryptographically secure random bytes. Defaults to 32 bytes. */\nexport function randomBytes(length?: number): Uint8Array {\n\treturn etc.randomBytes(length ?? 32);\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": "
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAS;AACT,sBAAS;AAqBF,SAAS,cAAc,CAAC,KAAmC;AAAA,EACjE,MAAM,QAAQ,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,EACpD,IAAI,MAAM,WAAW,KAAK;AAAA,IACzB,MAAM,IAAI,MACT,yDAAyD,MAAM,QAChE;AAAA,EACD;AAAA,EACA,OAAO;AAAA,IACN,UAAU,OAAO,SAAS,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;AAAA,IAC/C,GAAG,MAAM,MAAM,GAAG,EAAE;AAAA,IACpB,GAAG,MAAM,MAAM,IAAI,GAAG;AAAA,EACvB;AAAA;AAMM,SAAS,kBAAkB,CAAC,KAAmC;AAAA,EACrE,MAAM,IAAI,IAAI,SAAS,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,EACnD,OAAO,IAAI,IAAI,IAAI,IAAI;AAAA;AAIjB,SAAS,iBAAiB,CAAC,KAAqB;AAAA,EACtD,MAAM,QAAQ,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,EACpD,OAAO,MAAM,MAAM,CAAC,IAAI,MAAM,MAAM,GAAG,CAAC;AAAA;AAIlC,SAAS,iBAAiB,CAAC,KAAqB;AAAA,EACtD,MAAM,QAAQ,IAAI,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A,EACzD,OAAO,MAAM,WAAW,OAAO,MAAM,OAAO,KAAQ,MAAM,OAAO;AAAA;AAI3D,SAAS,WAAW,CAAC,QAA6B;AAAA,EACxD,OAAO,IAAI,YAAY,UAAU,EAAE;AAAA;",
|
|
9
|
+
"debugId": "F99004DF2704D3DE64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -125,6 +125,7 @@ declare const ClarityVersion: {
|
|
|
125
125
|
readonly Clarity3: 3
|
|
126
126
|
readonly Clarity4: 4
|
|
127
127
|
readonly Clarity5: 5
|
|
128
|
+
readonly Clarity6: 6
|
|
128
129
|
};
|
|
129
130
|
type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];
|
|
130
131
|
declare const AnchorMode: {
|
|
@@ -152,6 +153,12 @@ declare const PubKeyEncoding: {
|
|
|
152
153
|
readonly Uncompressed: 0x01
|
|
153
154
|
};
|
|
154
155
|
type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];
|
|
156
|
+
declare const PoxConditionCode: {
|
|
157
|
+
readonly WillNotPerform: 0x30
|
|
158
|
+
readonly MayPerform: 0x31
|
|
159
|
+
readonly WillPerform: 0x32
|
|
160
|
+
};
|
|
161
|
+
type PoxConditionCode = (typeof PoxConditionCode)[keyof typeof PoxConditionCode];
|
|
155
162
|
declare const TenureChangeCause: {
|
|
156
163
|
readonly BlockFound: 0x00
|
|
157
164
|
readonly Extended: 0x01
|
|
@@ -254,7 +261,7 @@ type StacksTransaction = {
|
|
|
254
261
|
postConditions: PostConditionWire[]
|
|
255
262
|
payload: TransactionPayload
|
|
256
263
|
};
|
|
257
|
-
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;
|
|
264
|
+
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire | StakingPostConditionWire | PoxPostConditionWire;
|
|
258
265
|
type StxPostConditionWire = {
|
|
259
266
|
type: "stx"
|
|
260
267
|
principal: PostConditionPrincipalWire
|
|
@@ -275,6 +282,17 @@ type NftPostConditionWire = {
|
|
|
275
282
|
conditionCode: number
|
|
276
283
|
assetId: ClarityValue
|
|
277
284
|
};
|
|
285
|
+
type StakingPostConditionWire = {
|
|
286
|
+
type: "staking"
|
|
287
|
+
principal: PostConditionPrincipalWire
|
|
288
|
+
conditionCode: number
|
|
289
|
+
amount: bigint
|
|
290
|
+
};
|
|
291
|
+
type PoxPostConditionWire = {
|
|
292
|
+
type: "pox"
|
|
293
|
+
principal: PostConditionPrincipalWire
|
|
294
|
+
conditionCode: PoxConditionCode
|
|
295
|
+
};
|
|
278
296
|
type PostConditionPrincipalWire = {
|
|
279
297
|
type: "origin"
|
|
280
298
|
} | {
|
package/dist/src/x402/index.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ declare const ClarityVersion: {
|
|
|
125
125
|
readonly Clarity3: 3
|
|
126
126
|
readonly Clarity4: 4
|
|
127
127
|
readonly Clarity5: 5
|
|
128
|
+
readonly Clarity6: 6
|
|
128
129
|
};
|
|
129
130
|
type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];
|
|
130
131
|
declare const AnchorMode: {
|
|
@@ -152,6 +153,12 @@ declare const PubKeyEncoding: {
|
|
|
152
153
|
readonly Uncompressed: 0x01
|
|
153
154
|
};
|
|
154
155
|
type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];
|
|
156
|
+
declare const PoxConditionCode: {
|
|
157
|
+
readonly WillNotPerform: 0x30
|
|
158
|
+
readonly MayPerform: 0x31
|
|
159
|
+
readonly WillPerform: 0x32
|
|
160
|
+
};
|
|
161
|
+
type PoxConditionCode = (typeof PoxConditionCode)[keyof typeof PoxConditionCode];
|
|
155
162
|
declare const TenureChangeCause: {
|
|
156
163
|
readonly BlockFound: 0x00
|
|
157
164
|
readonly Extended: 0x01
|
|
@@ -254,7 +261,7 @@ type StacksTransaction = {
|
|
|
254
261
|
postConditions: PostConditionWire[]
|
|
255
262
|
payload: TransactionPayload
|
|
256
263
|
};
|
|
257
|
-
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;
|
|
264
|
+
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire | StakingPostConditionWire | PoxPostConditionWire;
|
|
258
265
|
type StxPostConditionWire = {
|
|
259
266
|
type: "stx"
|
|
260
267
|
principal: PostConditionPrincipalWire
|
|
@@ -275,6 +282,17 @@ type NftPostConditionWire = {
|
|
|
275
282
|
conditionCode: number
|
|
276
283
|
assetId: ClarityValue
|
|
277
284
|
};
|
|
285
|
+
type StakingPostConditionWire = {
|
|
286
|
+
type: "staking"
|
|
287
|
+
principal: PostConditionPrincipalWire
|
|
288
|
+
conditionCode: number
|
|
289
|
+
amount: bigint
|
|
290
|
+
};
|
|
291
|
+
type PoxPostConditionWire = {
|
|
292
|
+
type: "pox"
|
|
293
|
+
principal: PostConditionPrincipalWire
|
|
294
|
+
conditionCode: PoxConditionCode
|
|
295
|
+
};
|
|
278
296
|
type PostConditionPrincipalWire = {
|
|
279
297
|
type: "origin"
|
|
280
298
|
} | {
|
package/dist/src/x402/index.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sponsorTransaction
|
|
3
|
-
} from "../../shared/stacks-
|
|
3
|
+
} from "../../shared/stacks-3kmj5yre.js";
|
|
4
4
|
import {
|
|
5
5
|
sendTransaction
|
|
6
|
-
} from "../../shared/stacks-
|
|
6
|
+
} from "../../shared/stacks-502j0efj.js";
|
|
7
7
|
import"../../shared/stacks-709tra19.js";
|
|
8
8
|
import {
|
|
9
9
|
Pc
|
|
10
|
-
} from "../../shared/stacks-
|
|
10
|
+
} from "../../shared/stacks-x94a1d6s.js";
|
|
11
11
|
import {
|
|
12
12
|
deserializeTransaction
|
|
13
|
-
} from "../../shared/stacks-
|
|
13
|
+
} from "../../shared/stacks-g11v9a35.js";
|
|
14
14
|
import {
|
|
15
15
|
MEMO_MAX_LENGTH_BYTES,
|
|
16
16
|
buildContractCall,
|
|
17
17
|
buildTokenTransfer
|
|
18
|
-
} from "../../shared/stacks-
|
|
18
|
+
} from "../../shared/stacks-ssndnbbd.js";
|
|
19
19
|
import {
|
|
20
20
|
Cl
|
|
21
|
-
} from "../../shared/stacks-
|
|
22
|
-
import"../../shared/stacks-xxn5ma6g.js";
|
|
21
|
+
} from "../../shared/stacks-2mm20wqf.js";
|
|
23
22
|
import {
|
|
24
23
|
parseContractId
|
|
25
|
-
} from "../../shared/stacks-
|
|
24
|
+
} from "../../shared/stacks-azp00pve.js";
|
|
26
25
|
import {
|
|
27
26
|
utf8ToBytes
|
|
28
|
-
} from "../../shared/stacks-
|
|
27
|
+
} from "../../shared/stacks-qs5fzts5.js";
|
|
29
28
|
import"../../shared/stacks-cfazrteq.js";
|
|
30
29
|
|
|
31
30
|
// src/x402/build.ts
|
|
@@ -84,5 +83,5 @@ export {
|
|
|
84
83
|
buildExactTransfer
|
|
85
84
|
};
|
|
86
85
|
|
|
87
|
-
//# debugId=
|
|
86
|
+
//# debugId=13AC05D31AD1CF8964756E2164756E21
|
|
88
87
|
//# 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 { 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};\n\nexport type SponsorAndBroadcastResult = {\n\ttxid: string;\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, { transaction: sponsored });\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": "
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDO,SAAS,kBAAkB,CACjC,SACoB;AAAA,EACpB,QAAQ,OAAO,QAAQ,OAAO,OAAO,gBAAgB,cAAc,UAClE;AAAA,EAED,IAAI,YAAY,QAAQ,KAAK,EAAE,aAAa,uBAAuB;AAAA,IAClE,MAAM,IAAI,MACT,0BAA0B,wCAC3B;AAAA,EACD;AAAA,EAEA,IAAI,MAAM,SAAS,OAAO;AAAA,IAKzB,OAAO,mBAAmB;AAAA,MACzB,WAAW;AAAA,MACX;AAAA,MACA,MAAM,QAAQ;AAAA,MACd,KAAK;AAAA,MACL,OAAO;AAAA,MACP,WAAW;AAAA,MACX;AAAA,MACA,WAAW;AAAA,IACZ,CAAC;AAAA,EACF;AAAA,EAEA,OAAO,iBAAiB,gBAAgB,gBAAgB,MAAM,UAAU;AAAA,EACxE,MAAM,iBAAkC;AAAA,IACvC,GAAG,UAAU,KAAK,EAChB,WAAW,MAAM,EACjB,GAAG,MAAM,YAAY,MAAM,SAAS;AAAA,EACvC;AAAA,EAEA,OAAO,kBAAkB;AAAA,IACxB;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,cAAc;AAAA,MACb,GAAG,KAAK,MAAM;AAAA,MACd,GAAG,UAAU,KAAK;AAAA,MAClB,GAAG,UAAU,KAAK;AAAA,MAClB,GAAG,KAAK,GAAG,eAAe,QAAQ,KAAK,CAAC;AAAA,IACzC;AAAA,IACA,KAAK;AAAA,IACL,OAAO;AAAA,IACP,WAAW;AAAA,IACX;AAAA,IACA,mBAAmB;AAAA,IACnB;AAAA,IACA,WAAW;AAAA,EACZ,CAAC;AAAA;;AC9EF,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,EAAE,aAAa,UAAU,CAAC;AAAA;",
|
|
9
|
+
"debugId": "13AC05D31AD1CF8964756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/stacks",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
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": [
|
|
113
|
+
"files": [
|
|
114
|
+
"dist"
|
|
115
|
+
],
|
|
114
116
|
"scripts": {
|
|
115
117
|
"build": "bunup",
|
|
116
118
|
"test": "bun test",
|