@secondlayer/stacks 4.0.0 → 4.2.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 +4 -0
- package/dist/shared/{stacks-zwgsbbb2.cjs → stacks-0nedd34w.cjs} +18 -13
- package/dist/shared/{stacks-zwgsbbb2.cjs.map → stacks-0nedd34w.cjs.map} +7 -6
- package/dist/shared/stacks-1arrcd11.js +48 -0
- package/dist/shared/stacks-1arrcd11.js.map +10 -0
- package/dist/shared/stacks-9mqveyjv.cjs.map +2 -2
- package/dist/shared/{stacks-dr5en54r.cjs → stacks-9qcr921s.cjs} +42 -5
- package/dist/shared/stacks-9qcr921s.cjs.map +10 -0
- package/dist/shared/stacks-enpj9krt.cjs +38 -0
- package/dist/shared/stacks-enpj9krt.cjs.map +10 -0
- package/dist/shared/{stacks-90jcxs98.js → stacks-fb75yew8.js} +8 -6
- package/dist/shared/{stacks-90jcxs98.js.map → stacks-fb75yew8.js.map} +3 -3
- package/dist/shared/{stacks-rw2xbtdv.js → stacks-gxq2pbky.js} +2 -2
- package/dist/shared/{stacks-rw2xbtdv.js.map → stacks-gxq2pbky.js.map} +1 -1
- package/dist/shared/{stacks-jx146qf1.js → stacks-hnqt5rz4.js} +27 -377
- package/dist/shared/stacks-hnqt5rz4.js.map +13 -0
- package/dist/shared/{stacks-z3vztaz1.js → stacks-jpt52csy.js} +3 -3
- package/dist/shared/stacks-jpt52csy.js.map +10 -0
- package/dist/shared/{stacks-thkhfwz8.js → stacks-rndfw2vh.js} +30 -23
- package/dist/shared/{stacks-thkhfwz8.js.map → stacks-rndfw2vh.js.map} +7 -6
- package/dist/shared/{stacks-fse1f76h.js → stacks-rpqtgpyj.js} +42 -8
- package/dist/shared/stacks-rpqtgpyj.js.map +10 -0
- package/dist/shared/{stacks-g2qnr5qn.cjs → stacks-rryme9bv.cjs} +11 -364
- package/dist/shared/stacks-rryme9bv.cjs.map +13 -0
- package/dist/shared/{stacks-byyex2zk.cjs → stacks-ta1gar0b.cjs} +7 -2
- package/dist/shared/{stacks-byyex2zk.cjs.map → stacks-ta1gar0b.cjs.map} +2 -2
- package/dist/shared/stacks-tdsp5gsb.cjs.map +2 -2
- package/dist/shared/stacks-vea7nde7.cjs +731 -0
- package/dist/shared/stacks-vea7nde7.cjs.map +13 -0
- package/dist/shared/stacks-w23294am.js +760 -0
- package/dist/shared/stacks-w23294am.js.map +13 -0
- package/dist/src/accounts/index.d.cts +1 -1
- package/dist/src/accounts/index.d.ts +1 -1
- package/dist/src/actions/index.cjs +2 -1
- package/dist/src/actions/index.cjs.map +1 -1
- package/dist/src/actions/index.d.cts +21 -12
- package/dist/src/actions/index.d.ts +21 -12
- package/dist/src/actions/index.js +9 -6
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.d.cts +29 -29
- package/dist/src/bitcoin/index.d.ts +29 -29
- package/dist/src/bitcoin/index.js +3 -2
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.d.cts +1 -1
- package/dist/src/bns/index.d.ts +1 -1
- package/dist/src/bns/index.js +8 -6
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/clarity/index.d.cts +37 -1
- package/dist/src/clarity/index.d.ts +37 -1
- package/dist/src/clarity/index.js +14 -2
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/index.cjs +2 -1
- package/dist/src/index.cjs.map +4 -4
- package/dist/src/index.d.cts +23 -14
- package/dist/src/index.d.ts +23 -14
- package/dist/src/index.js +8 -5
- package/dist/src/index.js.map +4 -4
- package/dist/src/postconditions/index.d.cts +66 -3
- package/dist/src/postconditions/index.d.ts +66 -3
- package/dist/src/postconditions/index.js +13 -2
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.d.cts +1 -1
- package/dist/src/pox/index.d.ts +1 -1
- package/dist/src/pox/index.js +6 -5
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/pox5/index.cjs +213 -14
- package/dist/src/pox5/index.cjs.map +8 -7
- package/dist/src/pox5/index.d.cts +88 -5
- package/dist/src/pox5/index.d.ts +88 -5
- package/dist/src/pox5/index.js +220 -17
- package/dist/src/pox5/index.js.map +8 -7
- package/dist/src/sbtc/index.d.cts +1 -1
- package/dist/src/sbtc/index.d.ts +1 -1
- package/dist/src/sbtc/index.js +5 -4
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/stackingdao/index.d.cts +1 -1
- package/dist/src/stackingdao/index.d.ts +1 -1
- package/dist/src/stackingdao/index.js +6 -5
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.d.cts +1 -1
- package/dist/src/subscriptions/index.d.ts +1 -1
- package/dist/src/tools/index.cjs +500 -361
- package/dist/src/tools/index.cjs.map +13 -10
- package/dist/src/tools/index.d.cts +1 -1
- package/dist/src/tools/index.d.ts +1 -1
- package/dist/src/tools/index.js +500 -361
- package/dist/src/tools/index.js.map +13 -10
- package/dist/src/transactions/index.cjs +3 -1
- package/dist/src/transactions/index.cjs.map +1 -1
- package/dist/src/transactions/index.d.cts +16 -9
- package/dist/src/transactions/index.d.ts +16 -9
- package/dist/src/transactions/index.js +31 -27
- package/dist/src/transactions/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/shared/stacks-dr5en54r.cjs.map +0 -10
- package/dist/shared/stacks-fse1f76h.js.map +0 -10
- package/dist/shared/stacks-g2qnr5qn.cjs.map +0 -15
- package/dist/shared/stacks-gkf9tsws.js +0 -285
- package/dist/shared/stacks-gkf9tsws.js.map +0 -10
- package/dist/shared/stacks-jx146qf1.js.map +0 -15
- package/dist/shared/stacks-qjgh6pqr.cjs +0 -258
- package/dist/shared/stacks-qjgh6pqr.cjs.map +0 -10
- package/dist/shared/stacks-z3vztaz1.js.map +0 -10
|
@@ -12,6 +12,7 @@ __export(exports_transactions, {
|
|
|
12
12
|
sigHashPostSign: () => sigHashPostSign,
|
|
13
13
|
serializeTransactionHex: () => serializeTransactionHex,
|
|
14
14
|
serializeTransaction: () => serializeTransaction,
|
|
15
|
+
serializePostConditionWire: () => serializePostConditionWire,
|
|
15
16
|
replayMultiSigSigHash: () => replayMultiSigSigHash,
|
|
16
17
|
nextSignature: () => nextSignature,
|
|
17
18
|
makeMultiSigAddress: () => makeMultiSigAddress,
|
|
@@ -20,6 +21,7 @@ __export(exports_transactions, {
|
|
|
20
21
|
getOriginSigHash: () => getOriginSigHash,
|
|
21
22
|
finalizeMultiSig: () => finalizeMultiSig,
|
|
22
23
|
deserializeTransaction: () => deserializeTransaction,
|
|
24
|
+
deserializePostConditionWire: () => deserializePostConditionWire,
|
|
23
25
|
createStandardAuth: () => createStandardAuth,
|
|
24
26
|
createSponsoredAuth: () => createSponsoredAuth,
|
|
25
27
|
createSingleSigSpendingCondition: () => createSingleSigSpendingCondition,
|
|
@@ -51,5 +53,5 @@ __export(exports_transactions, {
|
|
|
51
53
|
});
|
|
52
54
|
module.exports = __toCommonJS(exports_transactions);
|
|
53
55
|
|
|
54
|
-
//# debugId=
|
|
56
|
+
//# debugId=230ACFF33EBA8B8B64756E2164756E21
|
|
55
57
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -95,6 +95,7 @@ type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];
|
|
|
95
95
|
declare const PostConditionModeWire: {
|
|
96
96
|
readonly Allow: 0x01
|
|
97
97
|
readonly Deny: 0x02
|
|
98
|
+
readonly Originator: 0x03
|
|
98
99
|
};
|
|
99
100
|
type PostConditionModeWire = (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];
|
|
100
101
|
declare const AddressHashMode: {
|
|
@@ -121,6 +122,7 @@ declare const FungibleConditionCode: {
|
|
|
121
122
|
declare const NonFungibleConditionCode: {
|
|
122
123
|
readonly Sends: 0x10
|
|
123
124
|
readonly DoesNotSend: 0x11
|
|
125
|
+
readonly MaybeSent: 0x12
|
|
124
126
|
};
|
|
125
127
|
declare const PoxConditionCode: {
|
|
126
128
|
readonly WillNotPerform: 0x30
|
|
@@ -325,7 +327,7 @@ type LocalAccount = {
|
|
|
325
327
|
publicKey: string
|
|
326
328
|
/** Raw ECDSA sign over a hash */
|
|
327
329
|
sign(hash: Uint8Array): Uint8Array
|
|
328
|
-
/** Sign a
|
|
330
|
+
/** Sign a raw UTF-8 / byte message (`sha256(bytes)`). Not SIP-018. */
|
|
329
331
|
signMessage(message: string | Uint8Array): string
|
|
330
332
|
};
|
|
331
333
|
/** Account with a user-provided signing function (sync or async). */
|
|
@@ -392,7 +394,7 @@ type StacksChain = {
|
|
|
392
394
|
}
|
|
393
395
|
};
|
|
394
396
|
type FungibleComparator = "eq" | "gt" | "gte" | "lt" | "lte";
|
|
395
|
-
type NonFungibleComparator = "sent" | "not-sent";
|
|
397
|
+
type NonFungibleComparator = "sent" | "not-sent" | "maybe-sent";
|
|
396
398
|
type StxPostCondition = {
|
|
397
399
|
type: "stx-postcondition"
|
|
398
400
|
address: string
|
|
@@ -426,6 +428,9 @@ type PoxPostCondition = {
|
|
|
426
428
|
condition: PoxComparator
|
|
427
429
|
};
|
|
428
430
|
type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition;
|
|
431
|
+
/** Serialized PC hex is accepted anywhere a `PostCondition` object is. */
|
|
432
|
+
type PostConditionInput = PostCondition | string;
|
|
433
|
+
type PostConditionMode = "allow" | "deny" | "originator";
|
|
429
434
|
type IntegerType = number | string | bigint | Uint8Array;
|
|
430
435
|
type MultiSigOptions = {
|
|
431
436
|
publicKeys?: string[]
|
|
@@ -440,8 +445,8 @@ type BuildTokenTransferOptions = MultiSigOptions & {
|
|
|
440
445
|
nonce: IntegerType
|
|
441
446
|
publicKey?: string
|
|
442
447
|
chain?: StacksChain
|
|
443
|
-
postConditionMode?:
|
|
444
|
-
postConditions?:
|
|
448
|
+
postConditionMode?: PostConditionMode
|
|
449
|
+
postConditions?: PostConditionInput[]
|
|
445
450
|
sponsored?: boolean
|
|
446
451
|
};
|
|
447
452
|
type BuildContractCallOptions = MultiSigOptions & {
|
|
@@ -453,8 +458,8 @@ type BuildContractCallOptions = MultiSigOptions & {
|
|
|
453
458
|
nonce: IntegerType
|
|
454
459
|
publicKey?: string
|
|
455
460
|
chain?: StacksChain
|
|
456
|
-
postConditionMode?:
|
|
457
|
-
postConditions?:
|
|
461
|
+
postConditionMode?: PostConditionMode
|
|
462
|
+
postConditions?: PostConditionInput[]
|
|
458
463
|
sponsored?: boolean
|
|
459
464
|
};
|
|
460
465
|
type BuildContractDeployOptions = MultiSigOptions & {
|
|
@@ -465,15 +470,17 @@ type BuildContractDeployOptions = MultiSigOptions & {
|
|
|
465
470
|
nonce: IntegerType
|
|
466
471
|
publicKey?: string
|
|
467
472
|
chain?: StacksChain
|
|
468
|
-
postConditionMode?:
|
|
469
|
-
postConditions?:
|
|
473
|
+
postConditionMode?: PostConditionMode
|
|
474
|
+
postConditions?: PostConditionInput[]
|
|
470
475
|
sponsored?: boolean
|
|
471
476
|
};
|
|
472
477
|
declare function buildTokenTransfer(options: BuildTokenTransferOptions): StacksTransaction;
|
|
473
478
|
declare function buildContractCall(options: BuildContractCallOptions): StacksTransaction;
|
|
474
479
|
declare function buildContractDeploy(options: BuildContractDeployOptions): StacksTransaction;
|
|
480
|
+
declare function serializePostConditionWire(pc: PostConditionWire): Uint8Array;
|
|
475
481
|
declare function serializeTransaction(tx: StacksTransaction): Uint8Array;
|
|
476
482
|
declare function serializeTransactionHex(tx: StacksTransaction): string;
|
|
483
|
+
declare function deserializePostConditionWire(input: string | Uint8Array): PostConditionWire;
|
|
477
484
|
declare function deserializeTransaction(input: string | Uint8Array, meta?: {
|
|
478
485
|
_multisig?: {
|
|
479
486
|
publicKeys: string[]
|
|
@@ -495,4 +502,4 @@ declare function signMultiSigWithAccount(tx: StacksTransaction, account: LocalAc
|
|
|
495
502
|
declare function finalizeMultiSig(tx: StacksTransaction, publicKeys: string[]): StacksTransaction;
|
|
496
503
|
/** Combine independently-signed non-sequential multi-sig transactions */
|
|
497
504
|
declare function combineMultiSigSignatures(baseTx: StacksTransaction, signedTxs: StacksTransaction[]): StacksTransaction;
|
|
498
|
-
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 };
|
|
505
|
+
export { signTransactionWithAccount, signTransaction, signSponsorWithAccount, signSponsor, signMultiSigWithAccount, signMultiSig, signBegin, sigHashPreSign, sigHashPostSign, serializeTransactionHex, serializeTransaction, serializePostConditionWire, replayMultiSigSigHash, nextSignature, makeMultiSigAddress, isNonSequential, getTransactionId, getOriginSigHash, finalizeMultiSig, deserializeTransaction, deserializePostConditionWire, 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 };
|
|
@@ -95,6 +95,7 @@ type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];
|
|
|
95
95
|
declare const PostConditionModeWire: {
|
|
96
96
|
readonly Allow: 0x01
|
|
97
97
|
readonly Deny: 0x02
|
|
98
|
+
readonly Originator: 0x03
|
|
98
99
|
};
|
|
99
100
|
type PostConditionModeWire = (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];
|
|
100
101
|
declare const AddressHashMode: {
|
|
@@ -121,6 +122,7 @@ declare const FungibleConditionCode: {
|
|
|
121
122
|
declare const NonFungibleConditionCode: {
|
|
122
123
|
readonly Sends: 0x10
|
|
123
124
|
readonly DoesNotSend: 0x11
|
|
125
|
+
readonly MaybeSent: 0x12
|
|
124
126
|
};
|
|
125
127
|
declare const PoxConditionCode: {
|
|
126
128
|
readonly WillNotPerform: 0x30
|
|
@@ -325,7 +327,7 @@ type LocalAccount = {
|
|
|
325
327
|
publicKey: string
|
|
326
328
|
/** Raw ECDSA sign over a hash */
|
|
327
329
|
sign(hash: Uint8Array): Uint8Array
|
|
328
|
-
/** Sign a
|
|
330
|
+
/** Sign a raw UTF-8 / byte message (`sha256(bytes)`). Not SIP-018. */
|
|
329
331
|
signMessage(message: string | Uint8Array): string
|
|
330
332
|
};
|
|
331
333
|
/** Account with a user-provided signing function (sync or async). */
|
|
@@ -392,7 +394,7 @@ type StacksChain = {
|
|
|
392
394
|
}
|
|
393
395
|
};
|
|
394
396
|
type FungibleComparator = "eq" | "gt" | "gte" | "lt" | "lte";
|
|
395
|
-
type NonFungibleComparator = "sent" | "not-sent";
|
|
397
|
+
type NonFungibleComparator = "sent" | "not-sent" | "maybe-sent";
|
|
396
398
|
type StxPostCondition = {
|
|
397
399
|
type: "stx-postcondition"
|
|
398
400
|
address: string
|
|
@@ -426,6 +428,9 @@ type PoxPostCondition = {
|
|
|
426
428
|
condition: PoxComparator
|
|
427
429
|
};
|
|
428
430
|
type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition;
|
|
431
|
+
/** Serialized PC hex is accepted anywhere a `PostCondition` object is. */
|
|
432
|
+
type PostConditionInput = PostCondition | string;
|
|
433
|
+
type PostConditionMode = "allow" | "deny" | "originator";
|
|
429
434
|
type IntegerType = number | string | bigint | Uint8Array;
|
|
430
435
|
type MultiSigOptions = {
|
|
431
436
|
publicKeys?: string[]
|
|
@@ -440,8 +445,8 @@ type BuildTokenTransferOptions = MultiSigOptions & {
|
|
|
440
445
|
nonce: IntegerType
|
|
441
446
|
publicKey?: string
|
|
442
447
|
chain?: StacksChain
|
|
443
|
-
postConditionMode?:
|
|
444
|
-
postConditions?:
|
|
448
|
+
postConditionMode?: PostConditionMode
|
|
449
|
+
postConditions?: PostConditionInput[]
|
|
445
450
|
sponsored?: boolean
|
|
446
451
|
};
|
|
447
452
|
type BuildContractCallOptions = MultiSigOptions & {
|
|
@@ -453,8 +458,8 @@ type BuildContractCallOptions = MultiSigOptions & {
|
|
|
453
458
|
nonce: IntegerType
|
|
454
459
|
publicKey?: string
|
|
455
460
|
chain?: StacksChain
|
|
456
|
-
postConditionMode?:
|
|
457
|
-
postConditions?:
|
|
461
|
+
postConditionMode?: PostConditionMode
|
|
462
|
+
postConditions?: PostConditionInput[]
|
|
458
463
|
sponsored?: boolean
|
|
459
464
|
};
|
|
460
465
|
type BuildContractDeployOptions = MultiSigOptions & {
|
|
@@ -465,15 +470,17 @@ type BuildContractDeployOptions = MultiSigOptions & {
|
|
|
465
470
|
nonce: IntegerType
|
|
466
471
|
publicKey?: string
|
|
467
472
|
chain?: StacksChain
|
|
468
|
-
postConditionMode?:
|
|
469
|
-
postConditions?:
|
|
473
|
+
postConditionMode?: PostConditionMode
|
|
474
|
+
postConditions?: PostConditionInput[]
|
|
470
475
|
sponsored?: boolean
|
|
471
476
|
};
|
|
472
477
|
declare function buildTokenTransfer(options: BuildTokenTransferOptions): StacksTransaction;
|
|
473
478
|
declare function buildContractCall(options: BuildContractCallOptions): StacksTransaction;
|
|
474
479
|
declare function buildContractDeploy(options: BuildContractDeployOptions): StacksTransaction;
|
|
480
|
+
declare function serializePostConditionWire(pc: PostConditionWire): Uint8Array;
|
|
475
481
|
declare function serializeTransaction(tx: StacksTransaction): Uint8Array;
|
|
476
482
|
declare function serializeTransactionHex(tx: StacksTransaction): string;
|
|
483
|
+
declare function deserializePostConditionWire(input: string | Uint8Array): PostConditionWire;
|
|
477
484
|
declare function deserializeTransaction(input: string | Uint8Array, meta?: {
|
|
478
485
|
_multisig?: {
|
|
479
486
|
publicKeys: string[]
|
|
@@ -495,4 +502,4 @@ declare function signMultiSigWithAccount(tx: StacksTransaction, account: LocalAc
|
|
|
495
502
|
declare function finalizeMultiSig(tx: StacksTransaction, publicKeys: string[]): StacksTransaction;
|
|
496
503
|
/** Combine independently-signed non-sequential multi-sig transactions */
|
|
497
504
|
declare function combineMultiSigSignatures(baseTx: StacksTransaction, signedTxs: StacksTransaction[]): StacksTransaction;
|
|
498
|
-
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 };
|
|
505
|
+
export { signTransactionWithAccount, signTransaction, signSponsorWithAccount, signSponsor, signMultiSigWithAccount, signMultiSig, signBegin, sigHashPreSign, sigHashPostSign, serializeTransactionHex, serializeTransaction, serializePostConditionWire, replayMultiSigSigHash, nextSignature, makeMultiSigAddress, isNonSequential, getTransactionId, getOriginSigHash, finalizeMultiSig, deserializeTransaction, deserializePostConditionWire, 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,27 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
deserializeTransaction
|
|
3
|
-
} from "../../shared/stacks-gkf9tsws.js";
|
|
4
|
-
import {
|
|
5
|
-
AddressHashMode,
|
|
6
|
-
AnchorMode,
|
|
7
|
-
AssetType,
|
|
8
|
-
AuthFieldType,
|
|
9
|
-
AuthType,
|
|
10
|
-
COINBASE_BYTES_LENGTH,
|
|
11
|
-
ClarityVersion,
|
|
12
|
-
FungibleConditionCode,
|
|
13
|
-
MAX_STRING_LENGTH_BYTES,
|
|
14
|
-
MEMO_MAX_LENGTH_BYTES,
|
|
15
|
-
MICROBLOCK_HEADER_BYTES_LENGTH,
|
|
16
|
-
NonFungibleConditionCode,
|
|
17
|
-
PayloadType,
|
|
18
|
-
PostConditionModeWire,
|
|
19
|
-
PostConditionPrincipalId,
|
|
20
|
-
PoxConditionCode,
|
|
21
|
-
PubKeyEncoding,
|
|
22
|
-
RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,
|
|
23
|
-
TenureChangeCause,
|
|
24
|
-
VRF_PROOF_BYTES_LENGTH,
|
|
25
2
|
buildContractCall,
|
|
26
3
|
buildContractDeploy,
|
|
27
4
|
buildTokenTransfer,
|
|
@@ -37,8 +14,6 @@ import {
|
|
|
37
14
|
makeMultiSigAddress,
|
|
38
15
|
nextSignature,
|
|
39
16
|
replayMultiSigSigHash,
|
|
40
|
-
serializeTransaction,
|
|
41
|
-
serializeTransactionHex,
|
|
42
17
|
sigHashPostSign,
|
|
43
18
|
sigHashPreSign,
|
|
44
19
|
signBegin,
|
|
@@ -48,7 +23,34 @@ import {
|
|
|
48
23
|
signSponsorWithAccount,
|
|
49
24
|
signTransaction,
|
|
50
25
|
signTransactionWithAccount
|
|
51
|
-
} from "../../shared/stacks-
|
|
26
|
+
} from "../../shared/stacks-hnqt5rz4.js";
|
|
27
|
+
import {
|
|
28
|
+
AddressHashMode,
|
|
29
|
+
AnchorMode,
|
|
30
|
+
AssetType,
|
|
31
|
+
AuthFieldType,
|
|
32
|
+
AuthType,
|
|
33
|
+
COINBASE_BYTES_LENGTH,
|
|
34
|
+
ClarityVersion,
|
|
35
|
+
FungibleConditionCode,
|
|
36
|
+
MAX_STRING_LENGTH_BYTES,
|
|
37
|
+
MEMO_MAX_LENGTH_BYTES,
|
|
38
|
+
MICROBLOCK_HEADER_BYTES_LENGTH,
|
|
39
|
+
NonFungibleConditionCode,
|
|
40
|
+
PayloadType,
|
|
41
|
+
PostConditionModeWire,
|
|
42
|
+
PostConditionPrincipalId,
|
|
43
|
+
PoxConditionCode,
|
|
44
|
+
PubKeyEncoding,
|
|
45
|
+
RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,
|
|
46
|
+
TenureChangeCause,
|
|
47
|
+
VRF_PROOF_BYTES_LENGTH,
|
|
48
|
+
deserializePostConditionWire,
|
|
49
|
+
deserializeTransaction,
|
|
50
|
+
serializePostConditionWire,
|
|
51
|
+
serializeTransaction,
|
|
52
|
+
serializeTransactionHex
|
|
53
|
+
} from "../../shared/stacks-w23294am.js";
|
|
52
54
|
import"../../shared/stacks-ttdk2g2f.js";
|
|
53
55
|
import"../../shared/stacks-bfan7ex7.js";
|
|
54
56
|
import"../../shared/stacks-qs5fzts5.js";
|
|
@@ -64,6 +66,7 @@ export {
|
|
|
64
66
|
sigHashPostSign,
|
|
65
67
|
serializeTransactionHex,
|
|
66
68
|
serializeTransaction,
|
|
69
|
+
serializePostConditionWire,
|
|
67
70
|
replayMultiSigSigHash,
|
|
68
71
|
nextSignature,
|
|
69
72
|
makeMultiSigAddress,
|
|
@@ -72,6 +75,7 @@ export {
|
|
|
72
75
|
getOriginSigHash,
|
|
73
76
|
finalizeMultiSig,
|
|
74
77
|
deserializeTransaction,
|
|
78
|
+
deserializePostConditionWire,
|
|
75
79
|
createStandardAuth,
|
|
76
80
|
createSponsoredAuth,
|
|
77
81
|
createSingleSigSpendingCondition,
|
|
@@ -102,5 +106,5 @@ export {
|
|
|
102
106
|
AddressHashMode
|
|
103
107
|
};
|
|
104
108
|
|
|
105
|
-
//# debugId=
|
|
109
|
+
//# debugId=61F01E35BB39953064756E2164756E21
|
|
106
110
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/stacks",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
|
+
"description": "Typed Stacks client for TypeScript — read contracts, decode Clarity, build and send transactions.",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -8,7 +9,6 @@
|
|
|
8
9
|
"directory": "packages/stacks"
|
|
9
10
|
},
|
|
10
11
|
"homepage": "https://github.com/ryanwaits/secondlayer/tree/main/packages/stacks#readme",
|
|
11
|
-
"description": "A viem-style SDK for the Stacks blockchain",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "./dist/src/index.cjs",
|
|
14
14
|
"module": "./dist/src/index.js",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/postconditions/builder.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { ClarityValue } from \"../clarity/types.ts\";\nimport { parseContractId, validateStacksAddress } from \"../utils/address.ts\";\nimport { type IntegerType, intToBigInt } from \"../utils/encoding.ts\";\nimport type {\n\tFtPostCondition,\n\tFungibleComparator,\n\tNftPostCondition,\n\tNonFungibleComparator,\n\tStxPostCondition,\n} from \"./types.ts\";\n\nclass PartialPcWithPrincipal {\n\tconstructor(private address: string) {}\n\n\twillSendEq(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"eq\");\n\t}\n\twillSendGte(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"gte\");\n\t}\n\twillSendGt(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"gt\");\n\t}\n\twillSendLte(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"lte\");\n\t}\n\twillSendLt(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"lt\");\n\t}\n\twillSendAsset() {\n\t\treturn new PartialPcNftWithCode(this.address, \"sent\");\n\t}\n\twillNotSendAsset() {\n\t\treturn new PartialPcNftWithCode(this.address, \"not-sent\");\n\t}\n}\n\nclass PartialPcFtWithCode {\n\tconstructor(\n\t\tprivate address: string,\n\t\tprivate amount: IntegerType,\n\t\tprivate code: FungibleComparator,\n\t) {}\n\n\tustx(): StxPostCondition {\n\t\treturn {\n\t\t\ttype: \"stx-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tamount: intToBigInt(this.amount).toString(),\n\t\t};\n\t}\n\n\tft(contractId: string, tokenName: string): FtPostCondition {\n\t\tconst [address, name] = contractId.split(\".\");\n\t\tif (!address || !validateStacksAddress(address) || !name) {\n\t\t\tthrow new Error(`Invalid contract id: ${contractId}`);\n\t\t}\n\t\treturn {\n\t\t\ttype: \"ft-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tamount: intToBigInt(this.amount).toString(),\n\t\t\tasset: `${contractId}::${tokenName}`,\n\t\t};\n\t}\n}\n\nclass PartialPcNftWithCode {\n\tconstructor(\n\t\tprivate address: string,\n\t\tprivate code: NonFungibleComparator,\n\t) {}\n\n\tnft(\n\t\tassetOrContractId: string,\n\t\ttokenNameOrAssetId: string | ClarityValue,\n\t\tassetId?: ClarityValue,\n\t): NftPostCondition {\n\t\tlet contractAddress: string;\n\t\tlet contractName: string;\n\t\tlet tokenName: string;\n\t\tlet id: ClarityValue;\n\n\t\tif (assetId !== undefined) {\n\t\t\t// 3 args: contractId, tokenName, assetId\n\t\t\t[contractAddress, contractName] = parseContractId(assetOrContractId);\n\t\t\ttokenName = tokenNameOrAssetId as string;\n\t\t\tid = assetId;\n\t\t} else {\n\t\t\t// 2 args: assetString (addr.contract::token), assetId\n\t\t\tconst [principal, tName] = assetOrContractId.split(\"::\");\n\t\t\tif (!principal || !tName)\n\t\t\t\tthrow new Error(`Invalid asset name: ${assetOrContractId}`);\n\t\t\t[contractAddress, contractName] = parseContractId(principal);\n\t\t\ttokenName = tName;\n\t\t\tid = tokenNameOrAssetId as ClarityValue;\n\t\t}\n\n\t\tif (!validateStacksAddress(contractAddress)) {\n\t\t\tthrow new Error(`Invalid contract address: ${contractAddress}`);\n\t\t}\n\n\t\treturn {\n\t\t\ttype: \"nft-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tasset: `${contractAddress}.${contractName}::${tokenName}`,\n\t\t\tassetId: id,\n\t\t};\n\t}\n}\n\nexport const Pc = {\n\tprincipal(address: string) {\n\t\tconst [addr, name] = address.split(\".\");\n\t\tif (\n\t\t\t!addr ||\n\t\t\t!validateStacksAddress(addr) ||\n\t\t\t(typeof name === \"string\" && !name)\n\t\t) {\n\t\t\tthrow new Error(`Invalid principal: ${address}`);\n\t\t}\n\t\treturn new PartialPcWithPrincipal(address);\n\t},\n\torigin() {\n\t\treturn new PartialPcWithPrincipal(\"origin\");\n\t},\n};\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;;;AAWA,MAAM,uBAAuB;AAAA,EACR;AAAA,EAApB,WAAW,CAAS,SAAiB;AAAA,IAAjB;AAAA;AAAA,EAEpB,UAAU,CAAC,QAAqB;AAAA,IAC/B,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,IAAI;AAAA;AAAA,EAE1D,WAAW,CAAC,QAAqB;AAAA,IAChC,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,KAAK;AAAA;AAAA,EAE3D,UAAU,CAAC,QAAqB;AAAA,IAC/B,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,IAAI;AAAA;AAAA,EAE1D,WAAW,CAAC,QAAqB;AAAA,IAChC,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,KAAK;AAAA;AAAA,EAE3D,UAAU,CAAC,QAAqB;AAAA,IAC/B,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,IAAI;AAAA;AAAA,EAE1D,aAAa,GAAG;AAAA,IACf,OAAO,IAAI,qBAAqB,KAAK,SAAS,MAAM;AAAA;AAAA,EAErD,gBAAgB,GAAG;AAAA,IAClB,OAAO,IAAI,qBAAqB,KAAK,SAAS,UAAU;AAAA;AAE1D;AAAA;AAEA,MAAM,oBAAoB;AAA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AAS;AAAA,MAC3D,YAAY;AAAA,MACZ,KAAK;AAAA;AAAA,IAGN,IAAI,CAAC,sBAAsB,eAAe,GAAG;AAAA,MAC5C,MAAM,IAAI,MAAM,6BAA6B,iBAAiB;AAAA,IAC/D;AAAA,IAEA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS,KAAK;AAAA,MACd,WAAW,KAAK;AAAA,MAChB,OAAO,GAAG,mBAAmB,iBAAiB;AAAA,MAC9C,SAAS;AAAA,IACV;AAAA;AAEF;AAEO,IAAM,KAAK;AAAA,EACjB,SAAS,CAAC,SAAiB;AAAA,IAC1B,OAAO,MAAM,QAAQ,QAAQ,MAAM,GAAG;AAAA,IACtC,IACC,CAAC,QACD,CAAC,sBAAsB,IAAI,KAC1B,OAAO,SAAS,YAAY,CAAC,MAC7B;AAAA,MACD,MAAM,IAAI,MAAM,sBAAsB,SAAS;AAAA,IAChD;AAAA,IACA,OAAO,IAAI,uBAAuB,OAAO;AAAA;AAAA,EAE1C,MAAM,GAAG;AAAA,IACR,OAAO,IAAI,uBAAuB,QAAQ;AAAA;AAE5C;",
|
|
8
|
-
"debugId": "60B2774FE4E4DD2564756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/postconditions/builder.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { ClarityValue } from \"../clarity/types.ts\";\nimport { parseContractId, validateStacksAddress } from \"../utils/address.ts\";\nimport { type IntegerType, intToBigInt } from \"../utils/encoding.ts\";\nimport type {\n\tFtPostCondition,\n\tFungibleComparator,\n\tNftPostCondition,\n\tNonFungibleComparator,\n\tStxPostCondition,\n} from \"./types.ts\";\n\nclass PartialPcWithPrincipal {\n\tconstructor(private address: string) {}\n\n\twillSendEq(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"eq\");\n\t}\n\twillSendGte(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"gte\");\n\t}\n\twillSendGt(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"gt\");\n\t}\n\twillSendLte(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"lte\");\n\t}\n\twillSendLt(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"lt\");\n\t}\n\twillSendAsset() {\n\t\treturn new PartialPcNftWithCode(this.address, \"sent\");\n\t}\n\twillNotSendAsset() {\n\t\treturn new PartialPcNftWithCode(this.address, \"not-sent\");\n\t}\n}\n\nclass PartialPcFtWithCode {\n\tconstructor(\n\t\tprivate address: string,\n\t\tprivate amount: IntegerType,\n\t\tprivate code: FungibleComparator,\n\t) {}\n\n\tustx(): StxPostCondition {\n\t\treturn {\n\t\t\ttype: \"stx-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tamount: intToBigInt(this.amount).toString(),\n\t\t};\n\t}\n\n\tft(contractId: string, tokenName: string): FtPostCondition {\n\t\tconst [address, name] = contractId.split(\".\");\n\t\tif (!address || !validateStacksAddress(address) || !name) {\n\t\t\tthrow new Error(`Invalid contract id: ${contractId}`);\n\t\t}\n\t\treturn {\n\t\t\ttype: \"ft-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tamount: intToBigInt(this.amount).toString(),\n\t\t\tasset: `${contractId}::${tokenName}`,\n\t\t};\n\t}\n}\n\nclass PartialPcNftWithCode {\n\tconstructor(\n\t\tprivate address: string,\n\t\tprivate code: NonFungibleComparator,\n\t) {}\n\n\tnft(\n\t\tassetOrContractId: string,\n\t\ttokenNameOrAssetId: string | ClarityValue,\n\t\tassetId?: ClarityValue,\n\t): NftPostCondition {\n\t\tlet contractAddress: string;\n\t\tlet contractName: string;\n\t\tlet tokenName: string;\n\t\tlet id: ClarityValue;\n\n\t\tif (assetId !== undefined) {\n\t\t\t// 3 args: contractId, tokenName, assetId\n\t\t\t[contractAddress, contractName] = parseContractId(assetOrContractId);\n\t\t\ttokenName = tokenNameOrAssetId as string;\n\t\t\tid = assetId;\n\t\t} else {\n\t\t\t// 2 args: assetString (addr.contract::token), assetId\n\t\t\tconst [principal, tName] = assetOrContractId.split(\"::\");\n\t\t\tif (!principal || !tName)\n\t\t\t\tthrow new Error(`Invalid asset name: ${assetOrContractId}`);\n\t\t\t[contractAddress, contractName] = parseContractId(principal);\n\t\t\ttokenName = tName;\n\t\t\tid = tokenNameOrAssetId as ClarityValue;\n\t\t}\n\n\t\tif (!validateStacksAddress(contractAddress)) {\n\t\t\tthrow new Error(`Invalid contract address: ${contractAddress}`);\n\t\t}\n\n\t\treturn {\n\t\t\ttype: \"nft-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tasset: `${contractAddress}.${contractName}::${tokenName}`,\n\t\t\tassetId: id,\n\t\t};\n\t}\n}\n\nexport const Pc = {\n\tprincipal(address: string) {\n\t\tconst [addr, name] = address.split(\".\");\n\t\tif (\n\t\t\t!addr ||\n\t\t\t!validateStacksAddress(addr) ||\n\t\t\t(typeof name === \"string\" && !name)\n\t\t) {\n\t\t\tthrow new Error(`Invalid principal: ${address}`);\n\t\t}\n\t\treturn new PartialPcWithPrincipal(address);\n\t},\n\torigin() {\n\t\treturn new PartialPcWithPrincipal(\"origin\");\n\t},\n};\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;;;;AAWA,MAAM,uBAAuB;AAAA,EACR;AAAA,EAApB,WAAW,CAAS,SAAiB;AAAA,IAAjB;AAAA;AAAA,EAEpB,UAAU,CAAC,QAAqB;AAAA,IAC/B,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,IAAI;AAAA;AAAA,EAE1D,WAAW,CAAC,QAAqB;AAAA,IAChC,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,KAAK;AAAA;AAAA,EAE3D,UAAU,CAAC,QAA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1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/transactions/types.ts", "../src/transactions/wire/serialize.ts", "../src/transactions/authorization.ts", "../src/transactions/multisig.ts", "../src/transactions/build.ts", "../src/transactions/signer.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { ClarityValue } from \"../clarity/types.ts\";\n\n// Auth types\nexport const AuthType = {\n\tStandard: 0x04,\n\tSponsored: 0x05,\n} as const;\nexport type AuthType = (typeof AuthType)[keyof typeof AuthType];\n\n// Payload types\nexport const PayloadType = {\n\tTokenTransfer: 0x00,\n\tSmartContract: 0x01,\n\tContractCall: 0x02,\n\tPoisonMicroblock: 0x03,\n\tCoinbase: 0x04,\n\tCoinbaseToAltRecipient: 0x05,\n\tVersionedSmartContract: 0x06,\n\tTenureChange: 0x07,\n\tNakamotoCoinbase: 0x08,\n} as const;\nexport type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];\n\n// Clarity version\nexport const ClarityVersion = {\n\tClarity1: 1,\n\tClarity2: 2,\n\tClarity3: 3,\n\tClarity4: 4,\n\tClarity5: 5,\n\tClarity6: 6, // SIP-044, Epoch 4.0\n} as const;\nexport type ClarityVersion =\n\t(typeof ClarityVersion)[keyof typeof ClarityVersion];\n\n// Anchor mode (deprecated post-Nakamoto, but needed for wire format)\nexport const AnchorMode = {\n\tOnChainOnly: 0x01,\n\tOffChainOnly: 0x02,\n\tAny: 0x03,\n} as const;\nexport type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];\n\n// Post condition mode\nexport const PostConditionModeWire = {\n\tAllow: 0x01,\n\tDeny: 0x02,\n} as const;\nexport type PostConditionModeWire =\n\t(typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];\n\n// Address hash modes\nexport const AddressHashMode = {\n\tP2PKH: 0x00,\n\tP2SH: 0x01,\n\tP2WPKH: 0x02,\n\tP2WSH: 0x03,\n\tP2SH_NonSequential: 0x05, // SIP-027\n\tP2WSH_P2SH_NonSequential: 0x07, // SIP-027\n} as const;\nexport type AddressHashMode =\n\t(typeof AddressHashMode)[keyof typeof AddressHashMode];\n\n// Pub key encoding\nexport const PubKeyEncoding = {\n\tCompressed: 0x00,\n\tUncompressed: 0x01,\n} as const;\nexport type PubKeyEncoding =\n\t(typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];\n\n// Fungible condition codes (wire format)\nexport const FungibleConditionCode = {\n\tEqual: 0x01,\n\tGreater: 0x02,\n\tGreaterEqual: 0x03,\n\tLess: 0x04,\n\tLessEqual: 0x05,\n} as const;\n\n// Non-fungible condition codes (wire format)\nexport const NonFungibleConditionCode = {\n\tSends: 0x10,\n\tDoesNotSend: 0x11,\n} as const;\n\n// PoX condition codes (wire format, SIP-045)\nexport const PoxConditionCode = {\n\tWillNotPerform: 0x30,\n\tMayPerform: 0x31,\n\tWillPerform: 0x32,\n} as const;\nexport type PoxConditionCode =\n\t(typeof PoxConditionCode)[keyof typeof PoxConditionCode];\n\n// Post condition principal types\nexport const PostConditionPrincipalId = {\n\tOrigin: 0x01,\n\tStandard: 0x02,\n\tContract: 0x03,\n} as const;\n\n// Post condition asset types\nexport const AssetType = {\n\tSTX: 0x00,\n\tFungible: 0x01,\n\tNonFungible: 0x02,\n\tStaking: 0x03, // SIP-045\n\tPox: 0x04, // SIP-045\n} as const;\n\n// Auth field types\nexport const AuthFieldType = {\n\tPublicKeyCompressed: 0x00,\n\tPublicKeyUncompressed: 0x01,\n\tSignatureCompressed: 0x02,\n\tSignatureUncompressed: 0x03,\n} as const;\n\nexport const RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;\nexport const MEMO_MAX_LENGTH_BYTES = 34;\nexport const MAX_STRING_LENGTH_BYTES = 128;\nexport const COINBASE_BYTES_LENGTH = 32;\nexport const VRF_PROOF_BYTES_LENGTH = 80;\nexport const MICROBLOCK_HEADER_BYTES_LENGTH = 132; // 1 + 2 + 32 + 32 + 65\n\n// Tenure change cause\nexport const TenureChangeCause = {\n\tBlockFound: 0x00,\n\tExtended: 0x01,\n\tExtendedRuntime: 0x02,\n\tExtendedReadCount: 0x03,\n\tExtendedReadLength: 0x04,\n\tExtendedWriteCount: 0x05,\n\tExtendedWriteLength: 0x06,\n} as const;\nexport type TenureChangeCause =\n\t(typeof TenureChangeCause)[keyof typeof TenureChangeCause];\n\n// Token transfer payload\nexport type TokenTransferPayload = {\n\tpayloadType: typeof PayloadType.TokenTransfer;\n\trecipient: ClarityValue; // PrincipalCV\n\tamount: bigint;\n\tmemo: string;\n};\n\n// Contract call payload\nexport type ContractCallPayload = {\n\tpayloadType: typeof PayloadType.ContractCall;\n\tcontractAddress: string;\n\tcontractName: string;\n\tfunctionName: string;\n\tfunctionArgs: ClarityValue[];\n};\n\n// Smart contract deploy payload\nexport type SmartContractPayload = {\n\tpayloadType:\n\t\t| typeof PayloadType.SmartContract\n\t\t| typeof PayloadType.VersionedSmartContract;\n\tclarityVersion?: ClarityVersion;\n\tcontractName: string;\n\tcodeBody: string;\n};\n\n// Coinbase payload (appears in every pre-Nakamoto block)\nexport type CoinbasePayload = {\n\tpayloadType: typeof PayloadType.Coinbase;\n\tcoinbaseBuffer: string; // 32 bytes hex\n};\n\n// Coinbase to alt recipient payload\nexport type CoinbaseToAltRecipientPayload = {\n\tpayloadType: typeof PayloadType.CoinbaseToAltRecipient;\n\tcoinbaseBuffer: string; // 32 bytes hex\n\trecipient: ClarityValue; // PrincipalCV\n};\n\n// Poison microblock payload\nexport type PoisonMicroblockPayload = {\n\tpayloadType: typeof PayloadType.PoisonMicroblock;\n\theader1: string; // 132 bytes hex (raw microblock header)\n\theader2: string; // 132 bytes hex (raw microblock header)\n};\n\n// Tenure change payload (Nakamoto)\nexport type TenureChangePayload = {\n\tpayloadType: typeof PayloadType.TenureChange;\n\ttenureConsensusHash: string; // 20 bytes hex\n\tprevTenureConsensusHash: string; // 20 bytes hex\n\tburnViewConsensusHash: string; // 20 bytes hex\n\tpreviousTenureEnd: string; // 32 bytes hex\n\tpreviousTenureBlocks: number; // u32\n\tcause: TenureChangeCause;\n\tpubkeyHash: string; // 20 bytes hex\n};\n\n// Nakamoto coinbase payload\nexport type NakamotoCoinbasePayload = {\n\tpayloadType: typeof PayloadType.NakamotoCoinbase;\n\tcoinbaseBuffer: string; // 32 bytes hex\n\trecipient: ClarityValue | null; // Optional PrincipalCV\n\tvrfProof: string; // 80 bytes hex\n};\n\nexport type TransactionPayload =\n\t| TokenTransferPayload\n\t| ContractCallPayload\n\t| SmartContractPayload\n\t| CoinbasePayload\n\t| CoinbaseToAltRecipientPayload\n\t| PoisonMicroblockPayload\n\t| TenureChangePayload\n\t| NakamotoCoinbasePayload;\n\n// Spending condition\nexport type SingleSigSpendingCondition = {\n\thashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH;\n\tsigner: string; // hash160 hex\n\tnonce: bigint;\n\tfee: bigint;\n\tkeyEncoding: PubKeyEncoding;\n\tsignature: string; // 65-byte recoverable sig hex\n};\n\nexport type TransactionAuthField = {\n\tpubKeyEncoding: PubKeyEncoding;\n\ttype: \"publicKey\" | \"signature\";\n\tdata: string; // hex\n};\n\nexport type MultiSigHashMode =\n\t| typeof AddressHashMode.P2SH\n\t| typeof AddressHashMode.P2WSH\n\t| typeof AddressHashMode.P2SH_NonSequential\n\t| typeof AddressHashMode.P2WSH_P2SH_NonSequential;\n\nexport type MultiSigSpendingCondition = {\n\thashMode: MultiSigHashMode;\n\tsigner: string;\n\tnonce: bigint;\n\tfee: bigint;\n\tfields: TransactionAuthField[];\n\tsignaturesRequired: number;\n};\n\nexport type SpendingCondition =\n\t| SingleSigSpendingCondition\n\t| MultiSigSpendingCondition;\n\nexport type StandardAuthorization = {\n\tauthType: typeof AuthType.Standard;\n\tspendingCondition: SpendingCondition;\n};\n\nexport type SponsoredAuthorization = {\n\tauthType: typeof AuthType.Sponsored;\n\tspendingCondition: SpendingCondition;\n\tsponsorSpendingCondition: SpendingCondition;\n};\n\nexport type Authorization = StandardAuthorization | SponsoredAuthorization;\n\n// Full transaction\nexport type StacksTransaction = {\n\tversion: number;\n\tchainId: number;\n\tauth: Authorization;\n\tanchorMode: AnchorMode;\n\tpostConditionMode: PostConditionModeWire;\n\tpostConditions: PostConditionWire[];\n\tpayload: TransactionPayload;\n\t/** Multi-sig signer metadata — not part of the wire format, preserved\n\t * through serialize/deserialize round-trip for auto-detection. */\n\t_multisig?: { publicKeys: string[] };\n};\n\n// Wire post condition types\nexport type PostConditionWire =\n\t| StxPostConditionWire\n\t| FtPostConditionWire\n\t| NftPostConditionWire\n\t| StakingPostConditionWire\n\t| PoxPostConditionWire;\n\nexport type StxPostConditionWire = {\n\ttype: \"stx\";\n\tprincipal: PostConditionPrincipalWire;\n\tconditionCode: number;\n\tamount: bigint;\n};\n\nexport type FtPostConditionWire = {\n\ttype: \"ft\";\n\tprincipal: PostConditionPrincipalWire;\n\tasset: AssetInfoWire;\n\tconditionCode: number;\n\tamount: bigint;\n};\n\nexport type NftPostConditionWire = {\n\ttype: \"nft\";\n\tprincipal: PostConditionPrincipalWire;\n\tasset: AssetInfoWire;\n\tconditionCode: number;\n\tassetId: ClarityValue;\n};\n\n// SIP-045: gates stake/register-for-bond/stake-update; same shape as STX\nexport type StakingPostConditionWire = {\n\ttype: \"staking\";\n\tprincipal: PostConditionPrincipalWire;\n\tconditionCode: number;\n\tamount: bigint;\n};\n\n// SIP-045: gates non-locking PoX state changes (unstake, announce-l1-early-exit, …); no amount\nexport type PoxPostConditionWire = {\n\ttype: \"pox\";\n\tprincipal: PostConditionPrincipalWire;\n\tconditionCode: PoxConditionCode;\n};\n\nexport type PostConditionPrincipalWire =\n\t| { type: \"origin\" }\n\t| { type: \"standard\"; address: string }\n\t| { type: \"contract\"; address: string; contractName: string };\n\nexport type AssetInfoWire = {\n\taddress: string;\n\tcontractName: string;\n\tassetName: string;\n};\n",
|
|
6
|
-
"import { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport { c32addressDecode } from \"../../utils/c32.ts\";\nimport {\n\tasciiToBytes,\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToBytes,\n\tintToHex,\n\tutf8ToBytes,\n\twriteUInt8,\n\twriteUInt16BE,\n\twriteUInt32BE,\n} from \"../../utils/encoding.ts\";\nimport {\n\ttype AssetInfoWire,\n\tAssetType,\n\tAuthType,\n\ttype Authorization,\n\ttype CoinbasePayload,\n\ttype CoinbaseToAltRecipientPayload,\n\tMEMO_MAX_LENGTH_BYTES,\n\ttype MultiSigSpendingCondition,\n\ttype NakamotoCoinbasePayload,\n\tPayloadType,\n\ttype PoisonMicroblockPayload,\n\tPostConditionPrincipalId,\n\ttype PostConditionPrincipalWire,\n\ttype PostConditionWire,\n\ttype SingleSigSpendingCondition,\n\ttype SpendingCondition,\n\ttype StacksTransaction,\n\ttype TenureChangePayload as TenureChangePayloadType,\n\ttype TransactionAuthField,\n\ttype TransactionPayload,\n} from \"../types.ts\";\n\n// Address serialization: version (1 byte) + hash160 (20 bytes)\nfunction serializeAddress(c32Address: string): Uint8Array {\n\tconst [version, hash160] = c32addressDecode(c32Address);\n\treturn concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\n// LP string: length prefix (n bytes) + content bytes\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n\tconst content = utf8ToBytes(str);\n\tconst prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n\treturn concatBytes(prefix, content);\n}\n\n// LP string for code body (4-byte prefix)\nfunction serializeLPStringLong(str: string): Uint8Array {\n\treturn serializeLPString(str, 4);\n}\n\n// Memo: flat 34-byte field (no length prefix) per SIP-005\nfunction serializeMemo(memo: string): Uint8Array {\n\tconst content = asciiToBytes(memo);\n\tconst padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);\n\tpadded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));\n\treturn padded;\n}\n\nfunction serializeSpendingCondition(condition: SpendingCondition): Uint8Array {\n\tconst parts: Uint8Array[] = [\n\t\twriteUInt8(condition.hashMode),\n\t\thexToBytes(condition.signer), // 20 bytes\n\t\tintToBytes(condition.nonce, 8),\n\t\tintToBytes(condition.fee, 8),\n\t];\n\n\tif (\"signature\" in condition) {\n\t\t// Single sig\n\t\tconst sc = condition as SingleSigSpendingCondition;\n\t\tparts.push(writeUInt8(sc.keyEncoding));\n\t\tparts.push(hexToBytes(sc.signature)); // 65 bytes\n\t} else {\n\t\t// Multi sig\n\t\tconst mc = condition as MultiSigSpendingCondition;\n\t\t// Fields as LP list\n\t\tparts.push(writeUInt32BE(mc.fields.length));\n\t\tfor (const field of mc.fields) {\n\t\t\tparts.push(serializeAuthField(field));\n\t\t}\n\t\tparts.push(writeUInt16BE(mc.signaturesRequired));\n\t}\n\n\treturn concatBytes(...parts);\n}\n\nfunction serializeAuthField(field: TransactionAuthField): Uint8Array {\n\tif (field.type === \"publicKey\") {\n\t\tconst typeId = field.pubKeyEncoding === 0x00 ? 0x00 : 0x01;\n\t\treturn concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n\t}\n\tconst typeId = field.pubKeyEncoding === 0x00 ? 0x02 : 0x03;\n\treturn concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n}\n\nfunction serializeAuthorization(auth: Authorization): Uint8Array {\n\tconst parts: Uint8Array[] = [writeUInt8(auth.authType)];\n\tparts.push(serializeSpendingCondition(auth.spendingCondition));\n\tif (auth.authType === AuthType.Sponsored) {\n\t\tparts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));\n\t}\n\treturn concatBytes(...parts);\n}\n\nfunction serializePrincipal(principal: PostConditionPrincipalWire): Uint8Array {\n\tswitch (principal.type) {\n\t\tcase \"origin\":\n\t\t\treturn writeUInt8(PostConditionPrincipalId.Origin);\n\t\tcase \"standard\":\n\t\t\treturn concatBytes(\n\t\t\t\twriteUInt8(PostConditionPrincipalId.Standard),\n\t\t\t\tserializeAddress(principal.address),\n\t\t\t);\n\t\tcase \"contract\":\n\t\t\treturn concatBytes(\n\t\t\t\twriteUInt8(PostConditionPrincipalId.Contract),\n\t\t\t\tserializeAddress(principal.address),\n\t\t\t\tserializeLPString(principal.contractName),\n\t\t\t);\n\t}\n}\n\nfunction serializeAssetInfo(asset: AssetInfoWire): Uint8Array {\n\treturn concatBytes(\n\t\tserializeAddress(asset.address),\n\t\tserializeLPString(asset.contractName),\n\t\tserializeLPString(asset.assetName),\n\t);\n}\n\nfunction serializePostCondition(pc: PostConditionWire): Uint8Array {\n\t// Wire order: asset_type first, then principal (per SIP-005)\n\tconst parts: Uint8Array[] = [];\n\n\tswitch (pc.type) {\n\t\tcase \"stx\":\n\t\t\tparts.push(writeUInt8(AssetType.STX));\n\t\t\tparts.push(serializePrincipal(pc.principal));\n\t\t\tparts.push(writeUInt8(pc.conditionCode));\n\t\t\tparts.push(intToBytes(pc.amount, 8));\n\t\t\tbreak;\n\t\tcase \"ft\":\n\t\t\tparts.push(writeUInt8(AssetType.Fungible));\n\t\t\tparts.push(serializePrincipal(pc.principal));\n\t\t\tparts.push(serializeAssetInfo(pc.asset));\n\t\t\tparts.push(writeUInt8(pc.conditionCode));\n\t\t\tparts.push(intToBytes(pc.amount, 8));\n\t\t\tbreak;\n\t\tcase \"nft\":\n\t\t\tparts.push(writeUInt8(AssetType.NonFungible));\n\t\t\tparts.push(serializePrincipal(pc.principal));\n\t\t\tparts.push(serializeAssetInfo(pc.asset));\n\t\t\tparts.push(serializeCVBytes(pc.assetId));\n\t\t\tparts.push(writeUInt8(pc.conditionCode));\n\t\t\tbreak;\n\t\tcase \"staking\":\n\t\t\t// SIP-045: same body as STX (fungible condition code + amount)\n\t\t\tparts.push(writeUInt8(AssetType.Staking));\n\t\t\tparts.push(serializePrincipal(pc.principal));\n\t\t\tparts.push(writeUInt8(pc.conditionCode));\n\t\t\tparts.push(intToBytes(pc.amount, 8));\n\t\t\tbreak;\n\t\tcase \"pox\":\n\t\t\t// SIP-045: PoX condition code only, no amount\n\t\t\tparts.push(writeUInt8(AssetType.Pox));\n\t\t\tparts.push(serializePrincipal(pc.principal));\n\t\t\tparts.push(writeUInt8(pc.conditionCode));\n\t\t\tbreak;\n\t}\n\n\treturn concatBytes(...parts);\n}\n\nfunction serializePostConditions(pcs: PostConditionWire[]): Uint8Array {\n\tconst parts: Uint8Array[] = [writeUInt32BE(pcs.length)];\n\tfor (const pc of pcs) {\n\t\tparts.push(serializePostCondition(pc));\n\t}\n\treturn concatBytes(...parts);\n}\n\nexport function serializePayload(payload: TransactionPayload): Uint8Array {\n\tconst parts: Uint8Array[] = [writeUInt8(payload.payloadType)];\n\n\tswitch (payload.payloadType) {\n\t\tcase PayloadType.TokenTransfer:\n\t\t\tparts.push(serializeCVBytes(payload.recipient));\n\t\t\tparts.push(intToBytes(payload.amount, 8));\n\t\t\tparts.push(serializeMemo(payload.memo));\n\t\t\tbreak;\n\n\t\tcase PayloadType.ContractCall:\n\t\t\tparts.push(serializeAddress(payload.contractAddress));\n\t\t\tparts.push(serializeLPString(payload.contractName));\n\t\t\tparts.push(serializeLPString(payload.functionName));\n\t\t\tparts.push(writeUInt32BE(payload.functionArgs.length));\n\t\t\tfor (const arg of payload.functionArgs) {\n\t\t\t\tparts.push(serializeCVBytes(arg));\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase PayloadType.SmartContract:\n\t\t\tparts.push(serializeLPString(payload.contractName));\n\t\t\tparts.push(serializeLPStringLong(payload.codeBody));\n\t\t\tbreak;\n\n\t\tcase PayloadType.VersionedSmartContract:\n\t\t\tparts.push(writeUInt8(payload.clarityVersion ?? 2));\n\t\t\tparts.push(serializeLPString(payload.contractName));\n\t\t\tparts.push(serializeLPStringLong(payload.codeBody));\n\t\t\tbreak;\n\n\t\tcase PayloadType.Coinbase:\n\t\t\tparts.push(hexToBytes((payload as CoinbasePayload).coinbaseBuffer));\n\t\t\tbreak;\n\n\t\tcase PayloadType.CoinbaseToAltRecipient: {\n\t\t\tconst cbAlt = payload as CoinbaseToAltRecipientPayload;\n\t\t\tparts.push(hexToBytes(cbAlt.coinbaseBuffer));\n\t\t\tparts.push(serializeCVBytes(cbAlt.recipient));\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PayloadType.PoisonMicroblock: {\n\t\t\tconst pm = payload as PoisonMicroblockPayload;\n\t\t\tparts.push(hexToBytes(pm.header1));\n\t\t\tparts.push(hexToBytes(pm.header2));\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PayloadType.TenureChange: {\n\t\t\tconst tc = payload as TenureChangePayloadType;\n\t\t\tparts.push(hexToBytes(tc.tenureConsensusHash));\n\t\t\tparts.push(hexToBytes(tc.prevTenureConsensusHash));\n\t\t\tparts.push(hexToBytes(tc.burnViewConsensusHash));\n\t\t\tparts.push(hexToBytes(tc.previousTenureEnd));\n\t\t\tparts.push(writeUInt32BE(tc.previousTenureBlocks));\n\t\t\tparts.push(writeUInt8(tc.cause));\n\t\t\tparts.push(hexToBytes(tc.pubkeyHash));\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PayloadType.NakamotoCoinbase: {\n\t\t\tconst nc = payload as NakamotoCoinbasePayload;\n\t\t\tparts.push(hexToBytes(nc.coinbaseBuffer));\n\t\t\tif (nc.recipient) {\n\t\t\t\tparts.push(serializeCVBytes({ type: \"some\", value: nc.recipient }));\n\t\t\t} else {\n\t\t\t\tparts.push(serializeCVBytes({ type: \"none\" }));\n\t\t\t}\n\t\t\tparts.push(hexToBytes(nc.vrfProof));\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn concatBytes(...parts);\n}\n\n// Memoization cache: transactions are immutable in practice (fields are set\n// once during build/signing), so the serialized bytes for a given transaction\n// object never change. The signing flow serializes the same object several\n// times (txid, sighash, sponsor sighash); caching avoids that redundant work.\n// Any in-place mutation MUST call clearTxCache — see setUnsignedFee.\nconst _txCache = new WeakMap<StacksTransaction, Uint8Array>();\n\n/** Invalidate the memoized serialization of a mutated transaction */\nexport function clearTxCache(tx: StacksTransaction): void {\n\t_txCache.delete(tx);\n}\n\nexport function serializeTransaction(tx: StacksTransaction): Uint8Array {\n\tconst cached = _txCache.get(tx);\n\tif (cached) return cached;\n\tconst bytes = concatBytes(\n\t\twriteUInt8(tx.version),\n\t\twriteUInt32BE(tx.chainId),\n\t\tserializeAuthorization(tx.auth),\n\t\twriteUInt8(tx.anchorMode),\n\t\twriteUInt8(tx.postConditionMode),\n\t\tserializePostConditions(tx.postConditions),\n\t\tserializePayload(tx.payload),\n\t);\n\t_txCache.set(tx, bytes);\n\treturn bytes;\n}\n\nexport function serializeTransactionHex(tx: StacksTransaction): string {\n\treturn bytesToHex(serializeTransaction(tx));\n}\n\n/** Serialize a transaction, returning the wire bytes plus the out-of-band\n * `_multisig` metadata so callers can preserve it across a round-trip\n * (the wire format itself does not carry it). */\nexport function serializeTransactionWithMeta(tx: StacksTransaction): {\n\tbytes: Uint8Array;\n\t_multisig?: { publicKeys: string[] };\n} {\n\treturn { bytes: serializeTransaction(tx), _multisig: tx._multisig };\n}\n",
|
|
7
|
-
"import { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { etc, getPublicKey as nobleGetPublicKey, sign } from \"@noble/secp256k1\";\nimport {\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToBytes,\n\tintToHex,\n} from \"../utils/encoding.ts\";\nimport { hashP2PKH, txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tAddressHashMode,\n\tAuthType,\n\ttype Authorization,\n\tPubKeyEncoding,\n\tRECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n\ttype SingleSigSpendingCondition,\n\ttype SpendingCondition,\n\ttype SponsoredAuthorization,\n\ttype StandardAuthorization,\n} from \"./types.ts\";\n\n// Ensure sync signing is available\netc.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {\n\tconst h = hmac.create(sha256, key);\n\tfor (const msg of msgs) h.update(msg);\n\treturn h.digest();\n};\n\nconst EMPTY_SIG = bytesToHex(\n\tnew Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES),\n);\n\nexport function createSingleSigSpendingCondition(\n\tpublicKey: string,\n\tnonce: bigint,\n\tfee: bigint,\n): SingleSigSpendingCondition {\n\tconst pubKeyBytes = hexToBytes(publicKey);\n\tconst signer = hashP2PKH(pubKeyBytes);\n\tconst isCompressed = pubKeyBytes.length === 33;\n\n\treturn {\n\t\thashMode: AddressHashMode.P2PKH,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tkeyEncoding: isCompressed\n\t\t\t? PubKeyEncoding.Compressed\n\t\t\t: PubKeyEncoding.Uncompressed,\n\t\tsignature: EMPTY_SIG,\n\t};\n}\n\nexport function createStandardAuth(\n\tspendingCondition: SpendingCondition,\n): StandardAuthorization {\n\treturn { authType: AuthType.Standard, spendingCondition };\n}\n\nexport function createSponsoredAuth(\n\tspendingCondition: SpendingCondition,\n\tsponsorSpendingCondition?: SpendingCondition,\n): SponsoredAuthorization {\n\treturn {\n\t\tauthType: AuthType.Sponsored,\n\t\tspendingCondition,\n\t\tsponsorSpendingCondition:\n\t\t\tsponsorSpendingCondition ??\n\t\t\tcreateSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n),\n\t};\n}\n\nfunction clearCondition(condition: SpendingCondition): SpendingCondition {\n\tif (\"signature\" in condition) {\n\t\treturn {\n\t\t\t...condition,\n\t\t\tnonce: 0n,\n\t\t\tfee: 0n,\n\t\t\tsignature: EMPTY_SIG,\n\t\t};\n\t}\n\treturn {\n\t\t...condition,\n\t\tnonce: 0n,\n\t\tfee: 0n,\n\t\tfields: [],\n\t};\n}\n\n/**\n * The sponsor \"signing sentinel\" used in the initial sighash of a sponsored tx.\n * Its `signer` MUST be 20 zero bytes (an empty address hash160) — NOT the\n * hash160 of a zero public key. Matching the reference (`newInitialSigHash` in\n * @stacks/transactions) is load-bearing: this exact byte layout is folded into\n * the origin's sighash, so any deviation makes the origin signature invalid and\n * the node rejects the tx with `SignatureValidation`.\n */\nfunction sponsorSigningSentinel(): SingleSigSpendingCondition {\n\treturn {\n\t\thashMode: AddressHashMode.P2PKH,\n\t\tsigner: \"00\".repeat(20),\n\t\tnonce: 0n,\n\t\tfee: 0n,\n\t\tkeyEncoding: PubKeyEncoding.Compressed,\n\t\tsignature: EMPTY_SIG,\n\t};\n}\n\nexport function intoInitialSighashAuth(auth: Authorization): Authorization {\n\tif (auth.authType === AuthType.Standard) {\n\t\treturn createStandardAuth(clearCondition(auth.spendingCondition));\n\t}\n\treturn createSponsoredAuth(\n\t\tclearCondition(auth.spendingCondition),\n\t\tsponsorSigningSentinel(),\n\t);\n}\n\n/** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */\nexport function sigHashPreSign(\n\tcurSigHash: string,\n\tauthType: number,\n\tfee: bigint,\n\tnonce: bigint,\n): string {\n\tconst data = concatBytes(\n\t\thexToBytes(curSigHash),\n\t\tnew Uint8Array([authType]),\n\t\tintToBytes(fee, 8),\n\t\tintToBytes(nonce, 8),\n\t);\n\treturn txidFromBytes(data);\n}\n\n/** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */\nexport function sigHashPostSign(\n\tcurSigHash: string,\n\tpubKeyEncoding: number,\n\tsignature: string,\n): string {\n\tconst data = concatBytes(\n\t\thexToBytes(curSigHash),\n\t\tnew Uint8Array([pubKeyEncoding]),\n\t\thexToBytes(signature),\n\t);\n\treturn txidFromBytes(data);\n}\n\n/** Sign with private key and return VRS signature (recoveryId + r + s) */\nfunction signWithKey(privateKey: string, messageHash: string): string {\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst sig = sign(messageHash, keyBytes, { lowS: true });\n\tconst recoveryIdHex = intToHex(sig.recovery, 1);\n\treturn recoveryIdHex + sig.toCompactHex();\n}\n\nexport function nextSignature(\n\tcurSigHash: string,\n\tauthType: number,\n\tfee: bigint,\n\tnonce: bigint,\n\tprivateKey: string,\n): { nextSig: string; nextSigHash: string } {\n\tconst sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);\n\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst pubKey = nobleGetPublicKey(keyBytes, true);\n\tconst isCompressed = pubKey.length === 33;\n\tconst pubKeyEncoding = isCompressed\n\t\t? PubKeyEncoding.Compressed\n\t\t: PubKeyEncoding.Uncompressed;\n\n\tconst nextSig = signWithKey(privateKey, sigHashPre);\n\tconst nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);\n\n\treturn { nextSig, nextSigHash };\n}\n",
|
|
8
|
-
"import {\n\tgetPublicKey as nobleGetPublicKey,\n\tsign as nobleSign,\n} from \"@noble/secp256k1\";\nimport type { CustomAccount, LocalAccount } from \"../accounts/types.ts\";\nimport type { StacksChain } from \"../chains/types.ts\";\nimport { c32address } from \"../utils/c32.ts\";\nimport {\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToHex,\n} from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tintoInitialSighashAuth,\n\tnextSignature,\n\tsigHashPostSign,\n\tsigHashPreSign,\n} from \"./authorization.ts\";\nimport {\n\tAddressHashMode,\n\tAuthType,\n\ttype MultiSigHashMode,\n\ttype MultiSigSpendingCondition,\n\tPubKeyEncoding,\n\ttype StacksTransaction,\n\ttype TransactionAuthField,\n} from \"./types.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\n\n// OP codes for redeem script\nconst OP_CHECKMULTISIG = 0xae;\n\n/** Check if hash mode is non-sequential (SIP-027) */\nexport function isNonSequential(hashMode: number): boolean {\n\treturn (hashMode & 0x04) !== 0;\n}\n\n/** Build a Bitcoin-style redeem script for m-of-n multi-sig */\nfunction makeRedeemScript(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n): Uint8Array {\n\tconst parts: Uint8Array[] = [];\n\tparts.push(new Uint8Array([0x50 + signaturesRequired])); // OP_n\n\tfor (const pk of publicKeys) {\n\t\tconst pkBytes = hexToBytes(pk);\n\t\tparts.push(new Uint8Array([pkBytes.length])); // length prefix (0x21 for compressed)\n\t\tparts.push(pkBytes);\n\t}\n\tparts.push(new Uint8Array([0x50 + publicKeys.length])); // OP_m\n\tparts.push(new Uint8Array([OP_CHECKMULTISIG]));\n\treturn concatBytes(...parts);\n}\n\n/** Derive a multi-sig address from public keys */\nexport function makeMultiSigAddress(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n\tchain?: StacksChain,\n): string {\n\tif (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {\n\t\tthrow new Error(\n\t\t\t`signaturesRequired must be between 1 and ${publicKeys.length}`,\n\t\t);\n\t}\n\tconst redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n\tconst signer = hash160(redeemScript);\n\tconst version = chain?.addressVersion?.multiSig ?? 20; // mainnet default\n\treturn c32address(version, bytesToHex(signer));\n}\n\n/** Create an empty multi-sig spending condition */\nexport function createMultiSigSpendingCondition(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n\tnonce: bigint,\n\tfee: bigint,\n\thashMode: MultiSigHashMode = AddressHashMode.P2SH,\n): MultiSigSpendingCondition {\n\tconst redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n\tconst signer = bytesToHex(hash160(redeemScript));\n\n\treturn {\n\t\thashMode,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tfields: [],\n\t\tsignaturesRequired,\n\t};\n}\n\n/** Compute the initial sighash for a transaction (same as signBegin) */\nfunction initialSigHash(tx: StacksTransaction): string {\n\tconst cleared: StacksTransaction = {\n\t\t...tx,\n\t\tauth: intoInitialSighashAuth(tx.auth),\n\t};\n\treturn txidFromBytes(serializeTransaction(cleared));\n}\n\n/** Compute the presign-sighash used by all non-sequential signers */\nfunction nonSequentialPreSignHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\tconst initHash = initialSigHash(tx);\n\treturn sigHashPreSign(\n\t\tinitHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n}\n\n/** Replay sighash through existing auth fields of a multi-sig tx */\nexport function replayMultiSigSigHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\t// Non-sequential: all signers sign the same presign-sighash, no field chaining\n\tif (isNonSequential(condition.hashMode)) {\n\t\tconst preSign = nonSequentialPreSignHash(tx);\n\t\t// Chain through all fields to get the final sighash\n\t\tlet curSigHash = preSign;\n\t\tfor (const field of condition.fields) {\n\t\t\tcurSigHash = sigHashPostSign(\n\t\t\t\tcurSigHash,\n\t\t\t\tfield.pubKeyEncoding,\n\t\t\t\tfield.data,\n\t\t\t);\n\t\t}\n\t\treturn curSigHash;\n\t}\n\n\t// Sequential: chain through all fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of condition.fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\treturn curSigHash;\n}\n\n/** Sign one position of a multi-sig transaction with a private key */\nexport function signMultiSig(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n\tpublicKeys: string[],\n): StacksTransaction {\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst signerPubKey = bytesToHex(nobleGetPublicKey(keyBytes, true));\n\n\tconst signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n\tif (signerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Private key does not correspond to any signer in the multi-sig\",\n\t\t);\n\t}\n\n\tconst condition = {\n\t\t...(tx.auth.spendingCondition as MultiSigSpendingCondition),\n\t};\n\n\t// Non-sequential: all signers sign the same presign-sighash independently\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn signNonSequential(tx, condition, privateKey);\n\t}\n\n\t// Sequential: existing P2SH behavior\n\treturn signSequential(tx, condition, privateKey, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing: compute presign-sighash from initial tx, sign, append */\nfunction signNonSequential(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\tprivateKey: string,\n): StacksTransaction {\n\tconst fields = [...condition.fields];\n\tconst preSignHash = nonSequentialPreSignHash(tx);\n\n\t// Sign the presign-sighash directly\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst sig = nobleSign(preSignHash, keyBytes, { lowS: true });\n\tconst recoveryIdHex = intToHex(sig.recovery, 1);\n\tconst nextSig = recoveryIdHex + sig.toCompactHex();\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\n\t// Auto-finalize: non-sequential needs no pubkey gap-filling\n\tif (sigCount >= condition.signaturesRequired) {\n\t\treturn {\n\t\t\t...tx,\n\t\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t\t};\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t};\n}\n\n/** Sequential signing: existing P2SH behavior */\nfunction signSequential(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\tprivateKey: string,\n\tpublicKeys: string[],\n\tsignerIndex: number,\n): StacksTransaction {\n\tconst fields = [...condition.fields];\n\n\t// Replay sighash through existing fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\n\t// Fill intervening positions with pubkey fields\n\tfor (let i = fields.length; i < signerIndex; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\t// Sign at signerIndex\n\tconst { nextSig, nextSigHash } = nextSignature(\n\t\tcurSigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t\tprivateKey,\n\t);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\tcurSigHash = nextSigHash;\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\t// Count signatures so far\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\tlet finalCondition = newCondition;\n\n\t// Auto-finalize if enough signatures collected\n\tif (sigCount >= condition.signaturesRequired) {\n\t\tfinalCondition = finalizeMultiSigCondition(\n\t\t\tnewCondition,\n\t\t\tpublicKeys,\n\t\t\tcurSigHash,\n\t\t);\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Sign one position of a multi-sig transaction with an account */\nexport async function signMultiSigWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n\tpublicKeys: string[],\n): Promise<StacksTransaction> {\n\tconst signerPubKey = account.publicKey;\n\n\tconst signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n\tif (signerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Account does not correspond to any signer in the multi-sig\",\n\t\t);\n\t}\n\n\tconst condition = {\n\t\t...(tx.auth.spendingCondition as MultiSigSpendingCondition),\n\t};\n\n\t// Non-sequential: all signers sign the same presign-sighash independently\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn signNonSequentialWithAccount(tx, condition, account);\n\t}\n\n\t// Sequential: existing behavior\n\treturn signSequentialWithAccount(\n\t\ttx,\n\t\tcondition,\n\t\taccount,\n\t\tpublicKeys,\n\t\tsignerIndex,\n\t);\n}\n\n/** Non-sequential signing with account */\nasync function signNonSequentialWithAccount(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tconst fields = [...condition.fields];\n\tconst preSignHash = nonSequentialPreSignHash(tx);\n\n\tconst sigBytes = await account.sign(hexToBytes(preSignHash));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\treturn {\n\t\t...tx,\n\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t};\n}\n\n/** Sequential signing with account */\nasync function signSequentialWithAccount(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\taccount: LocalAccount | CustomAccount,\n\tpublicKeys: string[],\n\tsignerIndex: number,\n): Promise<StacksTransaction> {\n\tconst fields = [...condition.fields];\n\n\t// Replay sighash through existing fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\n\t// Fill intervening positions with pubkey fields\n\tfor (let i = fields.length; i < signerIndex; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\t// Sign at signerIndex\n\tconst preSign = sigHashPreSign(\n\t\tcurSigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n\tconst sigBytes = await account.sign(hexToBytes(preSign));\n\tconst nextSig = bytesToHex(sigBytes);\n\tconst nextSigHash = sigHashPostSign(\n\t\tpreSign,\n\t\tPubKeyEncoding.Compressed,\n\t\tnextSig,\n\t);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\tcurSigHash = nextSigHash;\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\t// Count signatures so far\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\tlet finalCondition = newCondition;\n\n\t// Auto-finalize if enough signatures collected\n\tif (sigCount >= condition.signaturesRequired) {\n\t\tfinalCondition = finalizeMultiSigCondition(\n\t\t\tnewCondition,\n\t\t\tpublicKeys,\n\t\t\tcurSigHash,\n\t\t);\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Fill remaining slots with pubkey fields after all signatures are collected */\nexport function finalizeMultiSig(\n\ttx: StacksTransaction,\n\tpublicKeys: string[],\n): StacksTransaction {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\t// Non-sequential: no pubkey gap-filling needed\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn tx;\n\t}\n\n\tconst curSigHash = replayMultiSigSigHash(tx);\n\tconst finalCondition = finalizeMultiSigCondition(\n\t\tcondition,\n\t\tpublicKeys,\n\t\tcurSigHash,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Internal: finalize remaining pubkey slots (sequential only) */\nfunction finalizeMultiSigCondition(\n\tcondition: MultiSigSpendingCondition,\n\tpublicKeys: string[],\n\tcurSigHash: string,\n): MultiSigSpendingCondition {\n\tconst fields = [...condition.fields];\n\tlet sigHash = curSigHash;\n\n\t// Fill remaining positions\n\tfor (let i = fields.length; i < publicKeys.length; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tsigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tsigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\treturn { ...condition, fields };\n}\n\n/** Combine independently-signed non-sequential multi-sig transactions */\nexport function combineMultiSigSignatures(\n\tbaseTx: StacksTransaction,\n\tsignedTxs: StacksTransaction[],\n): StacksTransaction {\n\tconst condition = baseTx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\tif (!isNonSequential(condition.hashMode)) {\n\t\tthrow new Error(\n\t\t\t\"combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)\",\n\t\t);\n\t}\n\n\t// Collect all signature fields from each signed tx\n\tconst seenSigs = new Set<string>();\n\tconst signatures: TransactionAuthField[] = [];\n\n\tfor (const stx of signedTxs) {\n\t\tconst stxCondition = stx.auth\n\t\t\t.spendingCondition as MultiSigSpendingCondition;\n\t\tfor (const field of stxCondition.fields) {\n\t\t\tif (field.type === \"signature\" && !seenSigs.has(field.data)) {\n\t\t\t\tseenSigs.add(field.data);\n\t\t\t\tsignatures.push(field);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (signatures.length === 0) {\n\t\tthrow new Error(\"No signatures found in the provided transactions\");\n\t}\n\n\tconst newCondition: MultiSigSpendingCondition = {\n\t\t...condition,\n\t\tfields: signatures,\n\t};\n\n\treturn {\n\t\t...baseTx,\n\t\tauth: { ...baseTx.auth, spendingCondition: newCondition },\n\t};\n}\n",
|
|
9
|
-
"import type { StacksChain } from \"../chains/types.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport type { PostCondition } from \"../postconditions/types.ts\";\nimport { parseContractId } from \"../utils/address.ts\";\nimport { type IntegerType, intToBigInt } from \"../utils/encoding.ts\";\nimport {\n\tcreateSingleSigSpendingCondition,\n\tcreateSponsoredAuth,\n\tcreateStandardAuth,\n} from \"./authorization.ts\";\nimport { createMultiSigSpendingCondition } from \"./multisig.ts\";\nimport type { MultiSigHashMode, SpendingCondition } from \"./types.ts\";\nimport {\n\tAnchorMode,\n\ttype ClarityVersion,\n\tFungibleConditionCode,\n\tNonFungibleConditionCode,\n\tPayloadType,\n\tPostConditionModeWire,\n\ttype PostConditionPrincipalWire,\n\ttype PostConditionWire,\n\tPoxConditionCode,\n\ttype StacksTransaction,\n} from \"./types.ts\";\n\ntype MultiSigOptions = {\n\tpublicKeys?: string[];\n\tsignaturesRequired?: number;\n\thashMode?: MultiSigHashMode;\n};\n\nexport type BuildTokenTransferOptions = MultiSigOptions & {\n\trecipient: string;\n\tamount: IntegerType;\n\tmemo?: string;\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n\tsponsored?: boolean;\n};\n\nexport type BuildContractCallOptions = MultiSigOptions & {\n\tcontractAddress: string;\n\tcontractName: string;\n\tfunctionName: string;\n\tfunctionArgs: ClarityValue[];\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n\tsponsored?: boolean;\n};\n\nexport type BuildContractDeployOptions = MultiSigOptions & {\n\tcontractName: string;\n\tcodeBody: string;\n\tclarityVersion?: ClarityVersion;\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n\tsponsored?: boolean;\n};\n\nfunction resolvePcMode(mode?: \"allow\" | \"deny\"): PostConditionModeWire {\n\treturn mode === \"allow\"\n\t\t? PostConditionModeWire.Allow\n\t\t: PostConditionModeWire.Deny;\n}\n\nfunction convertPostConditions(pcs?: PostCondition[]): PostConditionWire[] {\n\tif (!pcs || pcs.length === 0) return [];\n\treturn pcs.map(convertPostCondition);\n}\n\nfunction resolvePrincipal(address: string): PostConditionPrincipalWire {\n\tif (address === \"origin\") return { type: \"origin\" };\n\tconst [addr, name] = address.split(\".\");\n\tif (name) {\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn { type: \"contract\", address: addr!, contractName: name };\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\treturn { type: \"standard\", address: addr! };\n}\n\nconst FUNGIBLE_CODE_MAP: Record<string, number> = {\n\teq: FungibleConditionCode.Equal,\n\tgt: FungibleConditionCode.Greater,\n\tgte: FungibleConditionCode.GreaterEqual,\n\tlt: FungibleConditionCode.Less,\n\tlte: FungibleConditionCode.LessEqual,\n};\n\nfunction convertPostCondition(pc: PostCondition): PostConditionWire {\n\tswitch (pc.type) {\n\t\tcase \"stx-postcondition\":\n\t\t\treturn {\n\t\t\t\ttype: \"stx\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tconditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n\t\t\t\tamount: intToBigInt(pc.amount),\n\t\t\t};\n\t\tcase \"ft-postcondition\": {\n\t\t\tconst [contractId, tokenName] = pc.asset.split(\"::\");\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tconst [addr, name] = parseContractId(contractId!);\n\t\t\treturn {\n\t\t\t\ttype: \"ft\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tasset: { address: addr, contractName: name, assetName: tokenName! },\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tconditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n\t\t\t\tamount: intToBigInt(pc.amount),\n\t\t\t};\n\t\t}\n\t\tcase \"nft-postcondition\": {\n\t\t\tconst [contractId, tokenName] = pc.asset.split(\"::\");\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tconst [addr, name] = parseContractId(contractId!);\n\t\t\treturn {\n\t\t\t\ttype: \"nft\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tasset: { address: addr, contractName: name, assetName: tokenName! },\n\t\t\t\tconditionCode:\n\t\t\t\t\tpc.condition === \"sent\"\n\t\t\t\t\t\t? NonFungibleConditionCode.Sends\n\t\t\t\t\t\t: NonFungibleConditionCode.DoesNotSend,\n\t\t\t\tassetId: pc.assetId,\n\t\t\t};\n\t\t}\n\t\tcase \"staking-postcondition\":\n\t\t\treturn {\n\t\t\t\ttype: \"staking\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tconditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n\t\t\t\tamount: intToBigInt(pc.amount),\n\t\t\t};\n\t\tcase \"pox-postcondition\":\n\t\t\treturn {\n\t\t\t\ttype: \"pox\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\tconditionCode: POX_CODE_MAP[pc.condition],\n\t\t\t};\n\t}\n}\n\nconst POX_CODE_MAP = {\n\t\"will-not-perform\": PoxConditionCode.WillNotPerform,\n\t\"may-perform\": PoxConditionCode.MayPerform,\n\t\"will-perform\": PoxConditionCode.WillPerform,\n} as const;\n\nimport type { Authorization } from \"./types.ts\";\n\nfunction resolveSpendingCondition(\n\topts: MultiSigOptions & { publicKey?: string },\n\tnonce: bigint,\n\tfee: bigint,\n): SpendingCondition {\n\tif (opts.publicKeys) {\n\t\treturn createMultiSigSpendingCondition(\n\t\t\topts.publicKeys,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\topts.signaturesRequired!,\n\t\t\tnonce,\n\t\t\tfee,\n\t\t\topts.hashMode,\n\t\t);\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\treturn createSingleSigSpendingCondition(opts.publicKey!, nonce, fee);\n}\n\nfunction resolveAuth(\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tspendingCondition: any,\n\tsponsored?: boolean,\n): Authorization {\n\treturn sponsored\n\t\t? createSponsoredAuth(spendingCondition)\n\t\t: createStandardAuth(spendingCondition);\n}\n\nfunction resolveVersionAndChainId(chain?: StacksChain): {\n\tversion: number;\n\tchainId: number;\n} {\n\tif (!chain) return { version: 0x00, chainId: 0x00000001 }; // mainnet defaults\n\treturn { version: chain.transactionVersion, chainId: chain.id };\n}\n\nexport function buildTokenTransfer(\n\toptions: BuildTokenTransferOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\tconst recipient = Cl.principal(options.recipient);\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.TokenTransfer,\n\t\t\trecipient,\n\t\t\tamount: intToBigInt(options.amount),\n\t\t\tmemo: options.memo ?? \"\",\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n\nexport function buildContractCall(\n\toptions: BuildContractCallOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.ContractCall,\n\t\t\tcontractAddress: options.contractAddress,\n\t\t\tcontractName: options.contractName,\n\t\t\tfunctionName: options.functionName,\n\t\t\tfunctionArgs: options.functionArgs,\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n\nexport function buildContractDeploy(\n\toptions: BuildContractDeployOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\tconst useVersioned = options.clarityVersion !== undefined;\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: useVersioned\n\t\t\t\t? PayloadType.VersionedSmartContract\n\t\t\t\t: PayloadType.SmartContract,\n\t\t\tclarityVersion: options.clarityVersion,\n\t\t\tcontractName: options.contractName,\n\t\t\tcodeBody: options.codeBody,\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n",
|
|
10
|
-
"import type { CustomAccount, LocalAccount } from \"../accounts/types.ts\";\nimport { bytesToHex, hexToBytes } from \"../utils/encoding.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tintoInitialSighashAuth,\n\tnextSignature,\n\tsigHashPostSign,\n\tsigHashPreSign,\n} from \"./authorization.ts\";\nimport { replayMultiSigSigHash } from \"./multisig.ts\";\nimport {\n\tAuthType,\n\ttype SingleSigSpendingCondition,\n\ttype SponsoredAuthorization,\n\ttype StacksTransaction,\n} from \"./types.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\n\nfunction txid(tx: StacksTransaction): string {\n\treturn txidFromBytes(serializeTransaction(tx));\n}\n\n/** Compute the initial sighash for a transaction */\nexport function signBegin(tx: StacksTransaction): string {\n\tconst cleared: StacksTransaction = {\n\t\t...tx,\n\t\tauth: intoInitialSighashAuth(tx.auth),\n\t};\n\treturn txid(cleared);\n}\n\n/** Sign a single-sig transaction with a private key, returning the signed transaction */\nexport function signTransaction(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n): StacksTransaction {\n\tconst sigHash = signBegin(tx);\n\tconst condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n\t// Origin always signs with AuthType.Standard (even for sponsored txs)\n\tconst { nextSig } = nextSignature(\n\t\tsigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t\tprivateKey,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: {\n\t\t\t\t...condition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Sign a single-sig transaction using an account (LocalAccount or CustomAccount) */\nexport async function signTransactionWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tconst sigHash = signBegin(tx);\n\tconst condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n\t// Origin always signs with AuthType.Standard (even for sponsored txs)\n\tconst sigHashPre = sigHashPreSign(\n\t\tsigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n\n\t// account.sign returns 65-byte VRS (recovery + r + s)\n\tconst sigBytes = await account.sign(hexToBytes(sigHashPre));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: {\n\t\t\t\t...condition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Get the txid of a transaction */\nexport function getTransactionId(tx: StacksTransaction): string {\n\treturn txid(tx);\n}\n\n/** Reconstruct the sighash after origin signing (needed for sponsor signing) */\nexport function getOriginSigHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition;\n\n\t// Multi-sig: replay through all fields\n\tif (\"fields\" in condition) {\n\t\treturn replayMultiSigSigHash(tx);\n\t}\n\n\t// Single-sig\n\tconst initialSigHash = signBegin(tx);\n\tconst sc = condition as SingleSigSpendingCondition;\n\tconst preSign = sigHashPreSign(\n\t\tinitialSigHash,\n\t\tAuthType.Standard,\n\t\tsc.fee,\n\t\tsc.nonce,\n\t);\n\treturn sigHashPostSign(preSign, sc.keyEncoding, sc.signature);\n}\n\n/** Sign a sponsored transaction as the sponsor with a private key */\nexport function signSponsor(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n): StacksTransaction {\n\tif (tx.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must be sponsored\");\n\t}\n\tconst auth = tx.auth as SponsoredAuthorization;\n\tconst sponsorCondition =\n\t\tauth.sponsorSpendingCondition as SingleSigSpendingCondition;\n\tconst originSigHash = getOriginSigHash(tx);\n\n\tconst { nextSig } = nextSignature(\n\t\toriginSigHash,\n\t\tAuthType.Sponsored,\n\t\tsponsorCondition.fee,\n\t\tsponsorCondition.nonce,\n\t\tprivateKey,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: {\n\t\t\t\t...sponsorCondition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Sign a sponsored transaction as the sponsor using an account */\nexport async function signSponsorWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tif (tx.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must be sponsored\");\n\t}\n\tconst auth = tx.auth as SponsoredAuthorization;\n\tconst sponsorCondition =\n\t\tauth.sponsorSpendingCondition as SingleSigSpendingCondition;\n\tconst originSigHash = getOriginSigHash(tx);\n\n\tconst sigHashPre = sigHashPreSign(\n\t\toriginSigHash,\n\t\tAuthType.Sponsored,\n\t\tsponsorCondition.fee,\n\t\tsponsorCondition.nonce,\n\t);\n\n\tconst sigBytes = await account.sign(hexToBytes(sigHashPre));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: {\n\t\t\t\t...sponsorCondition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n"
|
|
11
|
-
],
|
|
12
|
-
"mappings": ";AAGO,IAAM,WAAW;AAAA,EACvB,UAAU;AAAA,EACV,WAAW;AACZ;AAIO,IAAM,cAAc;AAAA,EAC1B,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,cAAc;AAAA,EACd,kBAAkB;AACnB;AAIO,IAAM,iBAAiB;AAAA,EAC7B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACX;AAKO,IAAM,aAAa;AAAA,EACzB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,KAAK;AACN;AAIO,IAAM,wBAAwB;AAAA,EACpC,OAAO;AAAA,EACP,MAAM;AACP;AAKO,IAAM,kBAAkB;AAAA,EAC9B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OA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