@secondlayer/stacks 6.0.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/stacks-esm-0pc6tmf0.js +50 -0
- package/dist/shared/{stacks-qex691bh.js.map → stacks-esm-0pc6tmf0.js.map} +2 -2
- package/dist/shared/{stacks-qt8ehebn.js → stacks-esm-16d82wyc.js} +10 -10
- package/dist/shared/{stacks-qt8ehebn.js.map → stacks-esm-16d82wyc.js.map} +2 -2
- package/dist/shared/{stacks-qs5fzts5.js → stacks-esm-7a0ehykf.js} +43 -43
- package/dist/shared/{stacks-qs5fzts5.js.map → stacks-esm-7a0ehykf.js.map} +2 -2
- package/dist/shared/{stacks-4hs8r4q2.js → stacks-esm-7v18h5dk.js} +4 -4
- package/dist/shared/{stacks-xjkn3en1.cjs.map → stacks-esm-7v18h5dk.js.map} +2 -2
- package/dist/shared/{stacks-71k0vmct.js → stacks-esm-8f5catbf.js} +126 -126
- package/dist/shared/{stacks-71k0vmct.js.map → stacks-esm-8f5catbf.js.map} +2 -2
- package/dist/shared/{stacks-wxfd6r4b.js → stacks-esm-8jt6k8p3.js} +13 -13
- package/dist/shared/{stacks-wxfd6r4b.js.map → stacks-esm-8jt6k8p3.js.map} +2 -2
- package/dist/shared/{stacks-x0qqwrev.js → stacks-esm-a20wyky3.js} +92 -92
- package/dist/shared/{stacks-agk106zs.cjs.map → stacks-esm-a20wyky3.js.map} +2 -2
- package/dist/shared/{stacks-gjz26k6b.js → stacks-esm-b54n1jdx.js} +102 -58
- package/dist/shared/stacks-esm-b54n1jdx.js.map +12 -0
- package/dist/shared/{stacks-9c1yam8b.js → stacks-esm-cmtj5vky.js} +162 -162
- package/dist/shared/{stacks-9c1yam8b.js.map → stacks-esm-cmtj5vky.js.map} +2 -2
- package/dist/shared/{stacks-z90xdr1x.js → stacks-esm-e2qhfgke.js} +36 -36
- package/dist/shared/{stacks-z90xdr1x.js.map → stacks-esm-e2qhfgke.js.map} +2 -2
- package/dist/shared/{stacks-v03zef3g.js → stacks-esm-ea4m4bk7.js} +117 -117
- package/dist/shared/{stacks-v03zef3g.js.map → stacks-esm-ea4m4bk7.js.map} +2 -2
- package/dist/shared/{stacks-69nq48jp.js → stacks-esm-hkw1kvd4.js} +140 -140
- package/dist/shared/{stacks-69nq48jp.js.map → stacks-esm-hkw1kvd4.js.map} +2 -2
- package/dist/shared/{stacks-qcae5852.js → stacks-esm-k108pemv.js} +4 -4
- package/dist/shared/{stacks-qcae5852.js.map → stacks-esm-k108pemv.js.map} +2 -2
- package/dist/shared/stacks-esm-kbz5s6v8.js +84 -0
- package/dist/shared/{stacks-4d7c3x27.js.map → stacks-esm-kbz5s6v8.js.map} +2 -2
- package/dist/shared/{stacks-kg1npstf.js → stacks-esm-mt1thm7k.js} +9 -9
- package/dist/shared/{stacks-kg1npstf.js.map → stacks-esm-mt1thm7k.js.map} +2 -2
- package/dist/shared/{stacks-yvb7rvwk.js → stacks-esm-n1mekwnb.js} +9 -9
- package/dist/shared/{stacks-8vzxax5e.cjs.map → stacks-esm-n1mekwnb.js.map} +2 -2
- package/dist/shared/{stacks-mftyrc60.js → stacks-esm-nt5hf8ht.js} +34 -34
- package/dist/shared/{stacks-mftyrc60.js.map → stacks-esm-nt5hf8ht.js.map} +2 -2
- package/dist/shared/{stacks-51ybf135.js → stacks-esm-phgy8yqf.js} +210 -210
- package/dist/shared/{stacks-51ybf135.js.map → stacks-esm-phgy8yqf.js.map} +2 -2
- package/dist/shared/{stacks-mbt36bzt.js → stacks-esm-pxv6ny92.js} +116 -116
- package/dist/shared/{stacks-mbt36bzt.js.map → stacks-esm-pxv6ny92.js.map} +2 -2
- package/dist/shared/{stacks-8brgfvqx.js → stacks-esm-qfzxhdqz.js} +19 -19
- package/dist/shared/{stacks-8brgfvqx.js.map → stacks-esm-qfzxhdqz.js.map} +2 -2
- package/dist/shared/{stacks-fd4rx56e.js → stacks-esm-snj9s2q8.js} +43 -43
- package/dist/shared/{stacks-fd4rx56e.js.map → stacks-esm-snj9s2q8.js.map} +2 -2
- package/dist/shared/{stacks-yajyej2y.js → stacks-esm-ss9ap75h.js} +28 -28
- package/dist/shared/{stacks-yajyej2y.js.map → stacks-esm-ss9ap75h.js.map} +2 -2
- package/dist/shared/{stacks-1m3m1agc.js → stacks-esm-t88hc019.js} +18 -18
- package/dist/shared/{stacks-1m3m1agc.js.map → stacks-esm-t88hc019.js.map} +2 -2
- package/dist/shared/stacks-esm-tdrdye4y.js +48 -0
- package/dist/shared/{stacks-enpj9krt.cjs.map → stacks-esm-tdrdye4y.js.map} +2 -2
- package/dist/src/accounts/index.cjs +565 -9
- package/dist/src/accounts/index.cjs.map +10 -4
- package/dist/src/accounts/index.d.cts +1 -1
- package/dist/src/accounts/index.d.ts +1 -1
- package/dist/src/accounts/index.js +26 -26
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.cjs +3860 -44
- package/dist/src/actions/index.cjs.map +65 -3
- package/dist/src/actions/index.d.cts +1 -1
- package/dist/src/actions/index.d.ts +1 -1
- package/dist/src/actions/index.js +102 -103
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.cjs +2506 -31
- package/dist/src/bitcoin/index.cjs.map +31 -3
- package/dist/src/bitcoin/index.d.cts +92 -92
- package/dist/src/bitcoin/index.d.ts +92 -92
- package/dist/src/bitcoin/index.js +88 -90
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.cjs +4435 -10
- package/dist/src/bns/index.cjs.map +50 -3
- package/dist/src/bns/index.d.cts +1 -1
- package/dist/src/bns/index.d.ts +1 -1
- package/dist/src/bns/index.js +39 -41
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/chains/index.cjs +141 -5
- package/dist/src/chains/index.cjs.map +5 -3
- package/dist/src/chains/index.d.cts +1 -1
- package/dist/src/chains/index.d.ts +1 -1
- package/dist/src/chains/index.js +12 -12
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/clarity/index.cjs +2021 -1
- package/dist/src/clarity/index.cjs.map +24 -3
- package/dist/src/clarity/index.d.cts +1 -1
- package/dist/src/clarity/index.d.ts +1 -1
- package/dist/src/clarity/index.js +170 -171
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/connect/index.cjs +19 -19
- package/dist/src/connect/index.cjs.map +2 -2
- package/dist/src/connect/index.d.cts +1 -1
- package/dist/src/connect/index.d.ts +1 -1
- package/dist/src/connect/index.js +19 -19
- package/dist/src/connect/index.js.map +2 -2
- package/dist/src/connect/walletconnect/index.cjs +6 -46
- package/dist/src/connect/walletconnect/index.cjs.map +3 -4
- package/dist/src/connect/walletconnect/index.d.cts +1 -1
- package/dist/src/connect/walletconnect/index.d.ts +1 -1
- package/dist/src/connect/walletconnect/index.js +6 -46
- package/dist/src/connect/walletconnect/index.js.map +3 -4
- package/dist/src/filters/index.cjs +727 -1
- package/dist/src/filters/index.cjs.map +11 -3
- package/dist/src/filters/index.d.cts +76 -13
- package/dist/src/filters/index.d.ts +76 -13
- package/dist/src/filters/index.js +30 -26
- package/dist/src/filters/index.js.map +1 -1
- package/dist/src/index.cjs +4000 -126
- package/dist/src/index.cjs.map +69 -4
- package/dist/src/index.d.cts +658 -607
- package/dist/src/index.d.ts +658 -607
- package/dist/src/index.js +219 -219
- package/dist/src/index.js.map +2 -2
- package/dist/src/postconditions/index.cjs +1728 -1
- package/dist/src/postconditions/index.cjs.map +20 -3
- package/dist/src/postconditions/index.d.cts +1 -1
- package/dist/src/postconditions/index.d.ts +1 -1
- package/dist/src/postconditions/index.js +16 -17
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.cjs +3866 -11
- package/dist/src/pox/index.cjs.map +48 -3
- package/dist/src/pox/index.d.cts +1 -1
- package/dist/src/pox/index.d.ts +1 -1
- package/dist/src/pox/index.js +40 -41
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/pox5/index.cjs +4124 -95
- package/dist/src/pox5/index.cjs.map +55 -4
- package/dist/src/pox5/index.d.cts +9 -1
- package/dist/src/pox5/index.d.ts +9 -1
- package/dist/src/pox5/index.js +210 -209
- package/dist/src/pox5/index.js.map +3 -3
- package/dist/src/sbtc/index.cjs +3719 -16
- package/dist/src/sbtc/index.cjs.map +47 -3
- package/dist/src/sbtc/index.d.cts +1 -1
- package/dist/src/sbtc/index.d.ts +1 -1
- package/dist/src/sbtc/index.js +39 -40
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/simnet/index.cjs +16 -16
- package/dist/src/simnet/index.cjs.map +2 -2
- package/dist/src/simnet/index.d.cts +1 -1
- package/dist/src/simnet/index.d.ts +1 -1
- package/dist/src/simnet/index.js +16 -16
- package/dist/src/simnet/index.js.map +2 -2
- package/dist/src/stackingdao/index.cjs +3747 -3
- package/dist/src/stackingdao/index.cjs.map +45 -3
- package/dist/src/stackingdao/index.d.cts +1 -1
- package/dist/src/stackingdao/index.d.ts +1 -1
- package/dist/src/stackingdao/index.js +26 -27
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.cjs +160 -6
- package/dist/src/subscriptions/index.cjs.map +6 -3
- package/dist/src/subscriptions/index.d.cts +1 -1
- package/dist/src/subscriptions/index.d.ts +1 -1
- package/dist/src/subscriptions/index.js +14 -15
- package/dist/src/subscriptions/index.js.map +1 -1
- package/dist/src/transactions/index.cjs +2189 -49
- package/dist/src/transactions/index.cjs.map +23 -3
- package/dist/src/transactions/index.d.cts +1 -1
- package/dist/src/transactions/index.d.ts +1 -1
- package/dist/src/transactions/index.js +104 -105
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.cjs +503 -69
- package/dist/src/utils/index.cjs.map +9 -3
- package/dist/src/utils/index.d.cts +1 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.js +131 -131
- package/dist/src/utils/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/shared/stacks-02actsrx.cjs +0 -17
- package/dist/shared/stacks-02actsrx.cjs.map +0 -10
- package/dist/shared/stacks-03vfm21t.cjs +0 -222
- package/dist/shared/stacks-03vfm21t.cjs.map +0 -12
- package/dist/shared/stacks-24h5k94q.cjs +0 -74
- package/dist/shared/stacks-24h5k94q.cjs.map +0 -11
- package/dist/shared/stacks-37kz5t9f.cjs +0 -764
- package/dist/shared/stacks-37kz5t9f.cjs.map +0 -23
- package/dist/shared/stacks-3mt2q2na.cjs +0 -65
- package/dist/shared/stacks-3mt2q2na.cjs.map +0 -9
- package/dist/shared/stacks-4d7c3x27.js +0 -84
- package/dist/shared/stacks-4hs8r4q2.js.map +0 -10
- package/dist/shared/stacks-8vzxax5e.cjs +0 -45
- package/dist/shared/stacks-agk106zs.cjs +0 -267
- package/dist/shared/stacks-bdgh9n83.cjs +0 -212
- package/dist/shared/stacks-bdgh9n83.cjs.map +0 -11
- package/dist/shared/stacks-dpxnxhqb.cjs +0 -51
- package/dist/shared/stacks-dpxnxhqb.cjs.map +0 -11
- package/dist/shared/stacks-ee53k9j2.cjs +0 -651
- package/dist/shared/stacks-ee53k9j2.cjs.map +0 -13
- package/dist/shared/stacks-enpj9krt.cjs +0 -38
- package/dist/shared/stacks-f35mnrmg.cjs +0 -164
- package/dist/shared/stacks-f35mnrmg.cjs.map +0 -10
- package/dist/shared/stacks-fhzwsn5d.cjs +0 -261
- package/dist/shared/stacks-fhzwsn5d.cjs.map +0 -12
- package/dist/shared/stacks-gjz26k6b.js.map +0 -12
- package/dist/shared/stacks-gza2n1zs.cjs +0 -73
- package/dist/shared/stacks-gza2n1zs.cjs.map +0 -11
- package/dist/shared/stacks-kem68d80.cjs +0 -156
- package/dist/shared/stacks-kem68d80.cjs.map +0 -10
- package/dist/shared/stacks-n98w7g57.cjs +0 -234
- package/dist/shared/stacks-n98w7g57.cjs.map +0 -10
- package/dist/shared/stacks-p337hp6m.cjs +0 -336
- package/dist/shared/stacks-p337hp6m.cjs.map +0 -25
- package/dist/shared/stacks-q34k4vnc.cjs +0 -286
- package/dist/shared/stacks-q34k4vnc.cjs.map +0 -12
- package/dist/shared/stacks-qex691bh.js +0 -50
- package/dist/shared/stacks-rryme9bv.cjs +0 -569
- package/dist/shared/stacks-rryme9bv.cjs.map +0 -13
- package/dist/shared/stacks-s5vej5z6.cjs +0 -410
- package/dist/shared/stacks-s5vej5z6.cjs.map +0 -15
- package/dist/shared/stacks-sdqkapct.cjs +0 -67
- package/dist/shared/stacks-sdqkapct.cjs.map +0 -12
- package/dist/shared/stacks-v2rfr46a.js +0 -48
- package/dist/shared/stacks-v2rfr46a.js.map +0 -10
- package/dist/shared/stacks-vea7nde7.cjs +0 -731
- package/dist/shared/stacks-vea7nde7.cjs.map +0 -13
- package/dist/shared/stacks-wk8yp13j.cjs +0 -33
- package/dist/shared/stacks-wk8yp13j.cjs.map +0 -11
- package/dist/shared/stacks-x0qqwrev.js.map +0 -12
- package/dist/shared/stacks-xjkn3en1.cjs +0 -42
- package/dist/shared/stacks-xnrywjf1.cjs +0 -131
- package/dist/shared/stacks-xnrywjf1.cjs.map +0 -11
- package/dist/shared/stacks-yvb7rvwk.js.map +0 -10
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
+
bytesToHex2,
|
|
3
|
+
hexToBytes2,
|
|
4
|
+
without0x2,
|
|
5
|
+
utf8ToBytes2,
|
|
6
|
+
asciiToBytes2,
|
|
7
|
+
bytesToAscii2,
|
|
8
|
+
concatBytes2,
|
|
9
|
+
intToBigInt2,
|
|
10
|
+
intToBytes2,
|
|
11
|
+
intToHex2,
|
|
12
|
+
writeUInt32BE2,
|
|
13
|
+
writeUInt16BE2,
|
|
14
|
+
writeUInt82,
|
|
15
|
+
c32addressDecode2
|
|
16
|
+
} from "./stacks-esm-7a0ehykf.js";
|
|
17
|
+
import {
|
|
18
|
+
serializeCVBytes2,
|
|
2
19
|
BytesReader,
|
|
3
20
|
readAddress,
|
|
4
|
-
readCV,
|
|
5
21
|
readLPString,
|
|
6
|
-
|
|
7
|
-
} from "./stacks-
|
|
8
|
-
import {
|
|
9
|
-
parseContractId
|
|
10
|
-
} from "./stacks-4d7c3x27.js";
|
|
22
|
+
readCV
|
|
23
|
+
} from "./stacks-esm-hkw1kvd4.js";
|
|
11
24
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
bytesToHex,
|
|
15
|
-
c32addressDecode,
|
|
16
|
-
concatBytes,
|
|
17
|
-
hexToBytes,
|
|
18
|
-
intToBigInt,
|
|
19
|
-
intToBytes,
|
|
20
|
-
intToHex,
|
|
21
|
-
utf8ToBytes,
|
|
22
|
-
without0x,
|
|
23
|
-
writeUInt16BE,
|
|
24
|
-
writeUInt32BE,
|
|
25
|
-
writeUInt8
|
|
26
|
-
} from "./stacks-qs5fzts5.js";
|
|
25
|
+
parseContractId2
|
|
26
|
+
} from "./stacks-esm-kbz5s6v8.js";
|
|
27
27
|
|
|
28
28
|
// src/transactions/types.ts
|
|
29
|
-
var
|
|
29
|
+
var AuthType2 = {
|
|
30
30
|
Standard: 4,
|
|
31
31
|
Sponsored: 5
|
|
32
32
|
};
|
|
33
|
-
var
|
|
33
|
+
var PayloadType2 = {
|
|
34
34
|
TokenTransfer: 0,
|
|
35
35
|
SmartContract: 1,
|
|
36
36
|
ContractCall: 2,
|
|
@@ -41,7 +41,7 @@ var PayloadType = {
|
|
|
41
41
|
TenureChange: 7,
|
|
42
42
|
NakamotoCoinbase: 8
|
|
43
43
|
};
|
|
44
|
-
var
|
|
44
|
+
var ClarityVersion2 = {
|
|
45
45
|
Clarity1: 1,
|
|
46
46
|
Clarity2: 2,
|
|
47
47
|
Clarity3: 3,
|
|
@@ -49,17 +49,17 @@ var ClarityVersion = {
|
|
|
49
49
|
Clarity5: 5,
|
|
50
50
|
Clarity6: 6
|
|
51
51
|
};
|
|
52
|
-
var
|
|
52
|
+
var AnchorMode2 = {
|
|
53
53
|
OnChainOnly: 1,
|
|
54
54
|
OffChainOnly: 2,
|
|
55
55
|
Any: 3
|
|
56
56
|
};
|
|
57
|
-
var
|
|
57
|
+
var PostConditionModeWire2 = {
|
|
58
58
|
Allow: 1,
|
|
59
59
|
Deny: 2,
|
|
60
60
|
Originator: 3
|
|
61
61
|
};
|
|
62
|
-
var
|
|
62
|
+
var AddressHashMode2 = {
|
|
63
63
|
P2PKH: 0,
|
|
64
64
|
P2SH: 1,
|
|
65
65
|
P2WPKH: 2,
|
|
@@ -67,52 +67,52 @@ var AddressHashMode = {
|
|
|
67
67
|
P2SH_NonSequential: 5,
|
|
68
68
|
P2WSH_P2SH_NonSequential: 7
|
|
69
69
|
};
|
|
70
|
-
var
|
|
70
|
+
var PubKeyEncoding2 = {
|
|
71
71
|
Compressed: 0,
|
|
72
72
|
Uncompressed: 1
|
|
73
73
|
};
|
|
74
|
-
var
|
|
74
|
+
var FungibleConditionCode2 = {
|
|
75
75
|
Equal: 1,
|
|
76
76
|
Greater: 2,
|
|
77
77
|
GreaterEqual: 3,
|
|
78
78
|
Less: 4,
|
|
79
79
|
LessEqual: 5
|
|
80
80
|
};
|
|
81
|
-
var
|
|
81
|
+
var NonFungibleConditionCode2 = {
|
|
82
82
|
Sends: 16,
|
|
83
83
|
DoesNotSend: 17,
|
|
84
84
|
MaybeSent: 18
|
|
85
85
|
};
|
|
86
|
-
var
|
|
86
|
+
var PoxConditionCode2 = {
|
|
87
87
|
WillNotPerform: 48,
|
|
88
88
|
MayPerform: 49,
|
|
89
89
|
WillPerform: 50
|
|
90
90
|
};
|
|
91
|
-
var
|
|
91
|
+
var PostConditionPrincipalId2 = {
|
|
92
92
|
Origin: 1,
|
|
93
93
|
Standard: 2,
|
|
94
94
|
Contract: 3
|
|
95
95
|
};
|
|
96
|
-
var
|
|
96
|
+
var AssetType2 = {
|
|
97
97
|
STX: 0,
|
|
98
98
|
Fungible: 1,
|
|
99
99
|
NonFungible: 2,
|
|
100
100
|
Staking: 3,
|
|
101
101
|
Pox: 4
|
|
102
102
|
};
|
|
103
|
-
var
|
|
103
|
+
var AuthFieldType2 = {
|
|
104
104
|
PublicKeyCompressed: 0,
|
|
105
105
|
PublicKeyUncompressed: 1,
|
|
106
106
|
SignatureCompressed: 2,
|
|
107
107
|
SignatureUncompressed: 3
|
|
108
108
|
};
|
|
109
|
-
var
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
var
|
|
113
|
-
var
|
|
114
|
-
var
|
|
115
|
-
var
|
|
109
|
+
var RECOVERABLE_ECDSA_SIG_LENGTH_BYTES2 = 65;
|
|
110
|
+
var MEMO_MAX_LENGTH_BYTES2 = 34;
|
|
111
|
+
var MAX_STRING_LENGTH_BYTES2 = 128;
|
|
112
|
+
var COINBASE_BYTES_LENGTH2 = 32;
|
|
113
|
+
var VRF_PROOF_BYTES_LENGTH2 = 80;
|
|
114
|
+
var MICROBLOCK_HEADER_BYTES_LENGTH2 = 132;
|
|
115
|
+
var TenureChangeCause2 = {
|
|
116
116
|
BlockFound: 0,
|
|
117
117
|
Extended: 1,
|
|
118
118
|
ExtendedRuntime: 2,
|
|
@@ -124,207 +124,207 @@ var TenureChangeCause = {
|
|
|
124
124
|
|
|
125
125
|
// src/transactions/wire/serialize.ts
|
|
126
126
|
function serializeAddress(c32Address) {
|
|
127
|
-
const [version, hash160] =
|
|
128
|
-
return
|
|
127
|
+
const [version, hash160] = c32addressDecode2(c32Address);
|
|
128
|
+
return concatBytes2(new Uint8Array([version]), hexToBytes2(hash160));
|
|
129
129
|
}
|
|
130
130
|
function serializeLPString(str, prefixBytes = 1) {
|
|
131
|
-
const content =
|
|
132
|
-
const prefix =
|
|
133
|
-
return
|
|
131
|
+
const content = utf8ToBytes2(str);
|
|
132
|
+
const prefix = hexToBytes2(intToHex2(content.byteLength, prefixBytes));
|
|
133
|
+
return concatBytes2(prefix, content);
|
|
134
134
|
}
|
|
135
135
|
function serializeLPStringLong(str) {
|
|
136
136
|
return serializeLPString(str, 4);
|
|
137
137
|
}
|
|
138
138
|
function serializeMemo(memo) {
|
|
139
|
-
const content =
|
|
140
|
-
const padded = new Uint8Array(
|
|
141
|
-
padded.set(content.slice(0,
|
|
139
|
+
const content = asciiToBytes2(memo);
|
|
140
|
+
const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES2);
|
|
141
|
+
padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES2));
|
|
142
142
|
return padded;
|
|
143
143
|
}
|
|
144
144
|
function serializeSpendingCondition(condition) {
|
|
145
145
|
const parts = [
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
writeUInt82(condition.hashMode),
|
|
147
|
+
hexToBytes2(condition.signer),
|
|
148
|
+
intToBytes2(condition.nonce, 8),
|
|
149
|
+
intToBytes2(condition.fee, 8)
|
|
150
150
|
];
|
|
151
151
|
if ("signature" in condition) {
|
|
152
152
|
const sc = condition;
|
|
153
|
-
parts.push(
|
|
154
|
-
parts.push(
|
|
153
|
+
parts.push(writeUInt82(sc.keyEncoding));
|
|
154
|
+
parts.push(hexToBytes2(sc.signature));
|
|
155
155
|
} else {
|
|
156
156
|
const mc = condition;
|
|
157
|
-
parts.push(
|
|
157
|
+
parts.push(writeUInt32BE2(mc.fields.length));
|
|
158
158
|
for (const field of mc.fields) {
|
|
159
159
|
parts.push(serializeAuthField(field));
|
|
160
160
|
}
|
|
161
|
-
parts.push(
|
|
161
|
+
parts.push(writeUInt16BE2(mc.signaturesRequired));
|
|
162
162
|
}
|
|
163
|
-
return
|
|
163
|
+
return concatBytes2(...parts);
|
|
164
164
|
}
|
|
165
165
|
function serializeAuthField(field) {
|
|
166
166
|
if (field.type === "publicKey") {
|
|
167
|
-
const
|
|
168
|
-
return
|
|
167
|
+
const typeId = field.pubKeyEncoding === 0 ? 0 : 1;
|
|
168
|
+
return concatBytes2(writeUInt82(typeId), hexToBytes2(field.data));
|
|
169
169
|
}
|
|
170
170
|
const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
|
|
171
|
-
return
|
|
171
|
+
return concatBytes2(writeUInt82(typeId), hexToBytes2(field.data));
|
|
172
172
|
}
|
|
173
173
|
function serializeAuthorization(auth) {
|
|
174
|
-
const parts = [
|
|
174
|
+
const parts = [writeUInt82(auth.authType)];
|
|
175
175
|
parts.push(serializeSpendingCondition(auth.spendingCondition));
|
|
176
|
-
if (auth.authType ===
|
|
176
|
+
if (auth.authType === AuthType2.Sponsored) {
|
|
177
177
|
parts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));
|
|
178
178
|
}
|
|
179
|
-
return
|
|
179
|
+
return concatBytes2(...parts);
|
|
180
180
|
}
|
|
181
181
|
function serializePrincipal(principal) {
|
|
182
182
|
switch (principal.type) {
|
|
183
183
|
case "origin":
|
|
184
|
-
return
|
|
184
|
+
return writeUInt82(PostConditionPrincipalId2.Origin);
|
|
185
185
|
case "standard":
|
|
186
|
-
return
|
|
186
|
+
return concatBytes2(writeUInt82(PostConditionPrincipalId2.Standard), serializeAddress(principal.address));
|
|
187
187
|
case "contract":
|
|
188
|
-
return
|
|
188
|
+
return concatBytes2(writeUInt82(PostConditionPrincipalId2.Contract), serializeAddress(principal.address), serializeLPString(principal.contractName));
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
function serializeAssetInfo(asset) {
|
|
192
|
-
return
|
|
192
|
+
return concatBytes2(serializeAddress(asset.address), serializeLPString(asset.contractName), serializeLPString(asset.assetName));
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function serializePostConditionWire2(pc) {
|
|
195
195
|
const parts = [];
|
|
196
196
|
switch (pc.type) {
|
|
197
197
|
case "stx":
|
|
198
|
-
parts.push(
|
|
198
|
+
parts.push(writeUInt82(AssetType2.STX));
|
|
199
199
|
parts.push(serializePrincipal(pc.principal));
|
|
200
|
-
parts.push(
|
|
201
|
-
parts.push(
|
|
200
|
+
parts.push(writeUInt82(pc.conditionCode));
|
|
201
|
+
parts.push(intToBytes2(pc.amount, 8));
|
|
202
202
|
break;
|
|
203
203
|
case "ft":
|
|
204
|
-
parts.push(
|
|
204
|
+
parts.push(writeUInt82(AssetType2.Fungible));
|
|
205
205
|
parts.push(serializePrincipal(pc.principal));
|
|
206
206
|
parts.push(serializeAssetInfo(pc.asset));
|
|
207
|
-
parts.push(
|
|
208
|
-
parts.push(
|
|
207
|
+
parts.push(writeUInt82(pc.conditionCode));
|
|
208
|
+
parts.push(intToBytes2(pc.amount, 8));
|
|
209
209
|
break;
|
|
210
210
|
case "nft":
|
|
211
|
-
parts.push(
|
|
211
|
+
parts.push(writeUInt82(AssetType2.NonFungible));
|
|
212
212
|
parts.push(serializePrincipal(pc.principal));
|
|
213
213
|
parts.push(serializeAssetInfo(pc.asset));
|
|
214
|
-
parts.push(
|
|
215
|
-
parts.push(
|
|
214
|
+
parts.push(serializeCVBytes2(pc.assetId));
|
|
215
|
+
parts.push(writeUInt82(pc.conditionCode));
|
|
216
216
|
break;
|
|
217
217
|
case "staking":
|
|
218
|
-
parts.push(
|
|
218
|
+
parts.push(writeUInt82(AssetType2.Staking));
|
|
219
219
|
parts.push(serializePrincipal(pc.principal));
|
|
220
|
-
parts.push(
|
|
221
|
-
parts.push(
|
|
220
|
+
parts.push(writeUInt82(pc.conditionCode));
|
|
221
|
+
parts.push(intToBytes2(pc.amount, 8));
|
|
222
222
|
break;
|
|
223
223
|
case "pox":
|
|
224
|
-
parts.push(
|
|
224
|
+
parts.push(writeUInt82(AssetType2.Pox));
|
|
225
225
|
parts.push(serializePrincipal(pc.principal));
|
|
226
|
-
parts.push(
|
|
226
|
+
parts.push(writeUInt82(pc.conditionCode));
|
|
227
227
|
break;
|
|
228
228
|
}
|
|
229
|
-
return
|
|
229
|
+
return concatBytes2(...parts);
|
|
230
230
|
}
|
|
231
231
|
function serializePostConditions(pcs) {
|
|
232
|
-
const parts = [
|
|
232
|
+
const parts = [writeUInt32BE2(pcs.length)];
|
|
233
233
|
for (const pc of pcs)
|
|
234
|
-
parts.push(
|
|
235
|
-
return
|
|
234
|
+
parts.push(serializePostConditionWire2(pc));
|
|
235
|
+
return concatBytes2(...parts);
|
|
236
236
|
}
|
|
237
237
|
function serializePayload(payload) {
|
|
238
|
-
const parts = [
|
|
238
|
+
const parts = [writeUInt82(payload.payloadType)];
|
|
239
239
|
switch (payload.payloadType) {
|
|
240
|
-
case
|
|
241
|
-
parts.push(
|
|
242
|
-
parts.push(
|
|
240
|
+
case PayloadType2.TokenTransfer:
|
|
241
|
+
parts.push(serializeCVBytes2(payload.recipient));
|
|
242
|
+
parts.push(intToBytes2(payload.amount, 8));
|
|
243
243
|
parts.push(serializeMemo(payload.memo));
|
|
244
244
|
break;
|
|
245
|
-
case
|
|
245
|
+
case PayloadType2.ContractCall:
|
|
246
246
|
parts.push(serializeAddress(payload.contractAddress));
|
|
247
247
|
parts.push(serializeLPString(payload.contractName));
|
|
248
248
|
parts.push(serializeLPString(payload.functionName));
|
|
249
|
-
parts.push(
|
|
249
|
+
parts.push(writeUInt32BE2(payload.functionArgs.length));
|
|
250
250
|
for (const arg of payload.functionArgs) {
|
|
251
|
-
parts.push(
|
|
251
|
+
parts.push(serializeCVBytes2(arg));
|
|
252
252
|
}
|
|
253
253
|
break;
|
|
254
|
-
case
|
|
254
|
+
case PayloadType2.SmartContract:
|
|
255
255
|
parts.push(serializeLPString(payload.contractName));
|
|
256
256
|
parts.push(serializeLPStringLong(payload.codeBody));
|
|
257
257
|
break;
|
|
258
|
-
case
|
|
259
|
-
parts.push(
|
|
258
|
+
case PayloadType2.VersionedSmartContract:
|
|
259
|
+
parts.push(writeUInt82(payload.clarityVersion ?? 2));
|
|
260
260
|
parts.push(serializeLPString(payload.contractName));
|
|
261
261
|
parts.push(serializeLPStringLong(payload.codeBody));
|
|
262
262
|
break;
|
|
263
|
-
case
|
|
264
|
-
parts.push(
|
|
263
|
+
case PayloadType2.Coinbase:
|
|
264
|
+
parts.push(hexToBytes2(payload.coinbaseBuffer));
|
|
265
265
|
break;
|
|
266
|
-
case
|
|
266
|
+
case PayloadType2.CoinbaseToAltRecipient: {
|
|
267
267
|
const cbAlt = payload;
|
|
268
|
-
parts.push(
|
|
269
|
-
parts.push(
|
|
268
|
+
parts.push(hexToBytes2(cbAlt.coinbaseBuffer));
|
|
269
|
+
parts.push(serializeCVBytes2(cbAlt.recipient));
|
|
270
270
|
break;
|
|
271
271
|
}
|
|
272
|
-
case
|
|
272
|
+
case PayloadType2.PoisonMicroblock: {
|
|
273
273
|
const pm = payload;
|
|
274
|
-
parts.push(
|
|
275
|
-
parts.push(
|
|
274
|
+
parts.push(hexToBytes2(pm.header1));
|
|
275
|
+
parts.push(hexToBytes2(pm.header2));
|
|
276
276
|
break;
|
|
277
277
|
}
|
|
278
|
-
case
|
|
278
|
+
case PayloadType2.TenureChange: {
|
|
279
279
|
const tc = payload;
|
|
280
|
-
parts.push(
|
|
281
|
-
parts.push(
|
|
282
|
-
parts.push(
|
|
283
|
-
parts.push(
|
|
284
|
-
parts.push(
|
|
285
|
-
parts.push(
|
|
286
|
-
parts.push(
|
|
280
|
+
parts.push(hexToBytes2(tc.tenureConsensusHash));
|
|
281
|
+
parts.push(hexToBytes2(tc.prevTenureConsensusHash));
|
|
282
|
+
parts.push(hexToBytes2(tc.burnViewConsensusHash));
|
|
283
|
+
parts.push(hexToBytes2(tc.previousTenureEnd));
|
|
284
|
+
parts.push(writeUInt32BE2(tc.previousTenureBlocks));
|
|
285
|
+
parts.push(writeUInt82(tc.cause));
|
|
286
|
+
parts.push(hexToBytes2(tc.pubkeyHash));
|
|
287
287
|
break;
|
|
288
288
|
}
|
|
289
|
-
case
|
|
289
|
+
case PayloadType2.NakamotoCoinbase: {
|
|
290
290
|
const nc = payload;
|
|
291
|
-
parts.push(
|
|
291
|
+
parts.push(hexToBytes2(nc.coinbaseBuffer));
|
|
292
292
|
if (nc.recipient) {
|
|
293
|
-
parts.push(
|
|
293
|
+
parts.push(serializeCVBytes2({ type: "some", value: nc.recipient }));
|
|
294
294
|
} else {
|
|
295
|
-
parts.push(
|
|
295
|
+
parts.push(serializeCVBytes2({ type: "none" }));
|
|
296
296
|
}
|
|
297
|
-
parts.push(
|
|
297
|
+
parts.push(hexToBytes2(nc.vrfProof));
|
|
298
298
|
break;
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
return
|
|
301
|
+
return concatBytes2(...parts);
|
|
302
302
|
}
|
|
303
303
|
var _txCache = new WeakMap;
|
|
304
304
|
function clearTxCache(tx) {
|
|
305
305
|
_txCache.delete(tx);
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function serializeTransaction2(tx) {
|
|
308
308
|
const cached = _txCache.get(tx);
|
|
309
309
|
if (cached)
|
|
310
310
|
return cached;
|
|
311
|
-
const bytes =
|
|
311
|
+
const bytes = concatBytes2(writeUInt82(tx.version), writeUInt32BE2(tx.chainId), serializeAuthorization(tx.auth), writeUInt82(tx.anchorMode), writeUInt82(tx.postConditionMode), serializePostConditions(tx.postConditions), serializePayload(tx.payload));
|
|
312
312
|
_txCache.set(tx, bytes);
|
|
313
313
|
return bytes;
|
|
314
314
|
}
|
|
315
|
-
function
|
|
316
|
-
return
|
|
315
|
+
function serializeTransactionHex2(tx) {
|
|
316
|
+
return bytesToHex2(serializeTransaction2(tx));
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
// src/transactions/wire/deserialize.ts
|
|
320
320
|
function readSpendingCondition(r) {
|
|
321
321
|
const hashMode = r.readUInt8();
|
|
322
|
-
const signer =
|
|
322
|
+
const signer = bytesToHex2(r.readBytes(20));
|
|
323
323
|
const nonce = r.readBigUInt64BE();
|
|
324
324
|
const fee = r.readBigUInt64BE();
|
|
325
|
-
if (hashMode ===
|
|
325
|
+
if (hashMode === AddressHashMode2.P2PKH || hashMode === AddressHashMode2.P2WPKH) {
|
|
326
326
|
const keyEncoding = r.readUInt8();
|
|
327
|
-
const signature =
|
|
327
|
+
const signature = bytesToHex2(r.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES2));
|
|
328
328
|
return {
|
|
329
329
|
hashMode,
|
|
330
330
|
signer,
|
|
@@ -343,13 +343,13 @@ function readSpendingCondition(r) {
|
|
|
343
343
|
fields.push({
|
|
344
344
|
type: "publicKey",
|
|
345
345
|
pubKeyEncoding: fieldType,
|
|
346
|
-
data:
|
|
346
|
+
data: bytesToHex2(r.readBytes(keyLen))
|
|
347
347
|
});
|
|
348
348
|
} else {
|
|
349
349
|
fields.push({
|
|
350
350
|
type: "signature",
|
|
351
351
|
pubKeyEncoding: fieldType === 2 ? 0 : 1,
|
|
352
|
-
data:
|
|
352
|
+
data: bytesToHex2(r.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES2))
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
355
|
}
|
|
@@ -366,12 +366,12 @@ function readSpendingCondition(r) {
|
|
|
366
366
|
function readAuthorization(r) {
|
|
367
367
|
const authType = r.readUInt8();
|
|
368
368
|
const spendingCondition = readSpendingCondition(r);
|
|
369
|
-
if (authType ===
|
|
370
|
-
return { authType:
|
|
369
|
+
if (authType === AuthType2.Standard) {
|
|
370
|
+
return { authType: AuthType2.Standard, spendingCondition };
|
|
371
371
|
}
|
|
372
372
|
const sponsorSpendingCondition = readSpendingCondition(r);
|
|
373
373
|
return {
|
|
374
|
-
authType:
|
|
374
|
+
authType: AuthType2.Sponsored,
|
|
375
375
|
spendingCondition,
|
|
376
376
|
sponsorSpendingCondition
|
|
377
377
|
};
|
|
@@ -386,11 +386,11 @@ function readAssetInfo(r) {
|
|
|
386
386
|
function readPostConditionPrincipal(r) {
|
|
387
387
|
const type = r.readUInt8();
|
|
388
388
|
switch (type) {
|
|
389
|
-
case
|
|
389
|
+
case PostConditionPrincipalId2.Origin:
|
|
390
390
|
return { type: "origin" };
|
|
391
|
-
case
|
|
391
|
+
case PostConditionPrincipalId2.Standard:
|
|
392
392
|
return { type: "standard", address: readAddress(r) };
|
|
393
|
-
case
|
|
393
|
+
case PostConditionPrincipalId2.Contract:
|
|
394
394
|
return {
|
|
395
395
|
type: "contract",
|
|
396
396
|
address: readAddress(r),
|
|
@@ -404,14 +404,14 @@ function readPostCondition(r) {
|
|
|
404
404
|
const assetType = r.readUInt8();
|
|
405
405
|
const principal = readPostConditionPrincipal(r);
|
|
406
406
|
switch (assetType) {
|
|
407
|
-
case
|
|
407
|
+
case AssetType2.STX:
|
|
408
408
|
return {
|
|
409
409
|
type: "stx",
|
|
410
410
|
principal,
|
|
411
411
|
conditionCode: r.readUInt8(),
|
|
412
412
|
amount: r.readBigUInt64BE()
|
|
413
413
|
};
|
|
414
|
-
case
|
|
414
|
+
case AssetType2.Fungible:
|
|
415
415
|
return {
|
|
416
416
|
type: "ft",
|
|
417
417
|
principal,
|
|
@@ -419,7 +419,7 @@ function readPostCondition(r) {
|
|
|
419
419
|
conditionCode: r.readUInt8(),
|
|
420
420
|
amount: r.readBigUInt64BE()
|
|
421
421
|
};
|
|
422
|
-
case
|
|
422
|
+
case AssetType2.NonFungible:
|
|
423
423
|
return {
|
|
424
424
|
type: "nft",
|
|
425
425
|
principal,
|
|
@@ -427,14 +427,14 @@ function readPostCondition(r) {
|
|
|
427
427
|
assetId: readCV(r),
|
|
428
428
|
conditionCode: r.readUInt8()
|
|
429
429
|
};
|
|
430
|
-
case
|
|
430
|
+
case AssetType2.Staking:
|
|
431
431
|
return {
|
|
432
432
|
type: "staking",
|
|
433
433
|
principal,
|
|
434
434
|
conditionCode: r.readUInt8(),
|
|
435
435
|
amount: r.readBigUInt64BE()
|
|
436
436
|
};
|
|
437
|
-
case
|
|
437
|
+
case AssetType2.Pox:
|
|
438
438
|
return {
|
|
439
439
|
type: "pox",
|
|
440
440
|
principal,
|
|
@@ -462,19 +462,19 @@ function readPostConditions(r) {
|
|
|
462
462
|
function readPayload(r) {
|
|
463
463
|
const payloadType = r.readUInt8();
|
|
464
464
|
switch (payloadType) {
|
|
465
|
-
case
|
|
465
|
+
case PayloadType2.TokenTransfer: {
|
|
466
466
|
const recipient = readCV(r);
|
|
467
467
|
const amount = r.readBigUInt64BE();
|
|
468
|
-
const memoBytes = r.readBytes(
|
|
469
|
-
const memo =
|
|
468
|
+
const memoBytes = r.readBytes(MEMO_MAX_LENGTH_BYTES2);
|
|
469
|
+
const memo = bytesToAscii2(memoBytes).replace(/\0+$/, "");
|
|
470
470
|
return {
|
|
471
|
-
payloadType:
|
|
471
|
+
payloadType: PayloadType2.TokenTransfer,
|
|
472
472
|
recipient,
|
|
473
473
|
amount,
|
|
474
474
|
memo
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
|
-
case
|
|
477
|
+
case PayloadType2.ContractCall: {
|
|
478
478
|
const contractAddress = readAddress(r);
|
|
479
479
|
const contractName = readLPString(r);
|
|
480
480
|
const functionName = readLPString(r);
|
|
@@ -483,57 +483,57 @@ function readPayload(r) {
|
|
|
483
483
|
for (let i = 0;i < numArgs; i++)
|
|
484
484
|
functionArgs.push(readCV(r));
|
|
485
485
|
return {
|
|
486
|
-
payloadType:
|
|
486
|
+
payloadType: PayloadType2.ContractCall,
|
|
487
487
|
contractAddress,
|
|
488
488
|
contractName,
|
|
489
489
|
functionName,
|
|
490
490
|
functionArgs
|
|
491
491
|
};
|
|
492
492
|
}
|
|
493
|
-
case
|
|
493
|
+
case PayloadType2.SmartContract: {
|
|
494
494
|
const contractName = readLPString(r);
|
|
495
495
|
const codeBody = readLPString(r, 4);
|
|
496
|
-
return { payloadType:
|
|
496
|
+
return { payloadType: PayloadType2.SmartContract, contractName, codeBody };
|
|
497
497
|
}
|
|
498
|
-
case
|
|
498
|
+
case PayloadType2.VersionedSmartContract: {
|
|
499
499
|
const clarityVersion = r.readUInt8();
|
|
500
500
|
const contractName = readLPString(r);
|
|
501
501
|
const codeBody = readLPString(r, 4);
|
|
502
502
|
return {
|
|
503
|
-
payloadType:
|
|
503
|
+
payloadType: PayloadType2.VersionedSmartContract,
|
|
504
504
|
clarityVersion,
|
|
505
505
|
contractName,
|
|
506
506
|
codeBody
|
|
507
507
|
};
|
|
508
508
|
}
|
|
509
|
-
case
|
|
510
|
-
const coinbaseBuffer =
|
|
511
|
-
return { payloadType:
|
|
509
|
+
case PayloadType2.Coinbase: {
|
|
510
|
+
const coinbaseBuffer = bytesToHex2(r.readBytes(COINBASE_BYTES_LENGTH2));
|
|
511
|
+
return { payloadType: PayloadType2.Coinbase, coinbaseBuffer };
|
|
512
512
|
}
|
|
513
|
-
case
|
|
514
|
-
const coinbaseBuffer =
|
|
513
|
+
case PayloadType2.CoinbaseToAltRecipient: {
|
|
514
|
+
const coinbaseBuffer = bytesToHex2(r.readBytes(COINBASE_BYTES_LENGTH2));
|
|
515
515
|
const recipient = readCV(r);
|
|
516
516
|
return {
|
|
517
|
-
payloadType:
|
|
517
|
+
payloadType: PayloadType2.CoinbaseToAltRecipient,
|
|
518
518
|
coinbaseBuffer,
|
|
519
519
|
recipient
|
|
520
520
|
};
|
|
521
521
|
}
|
|
522
|
-
case
|
|
523
|
-
const header1 =
|
|
524
|
-
const header2 =
|
|
525
|
-
return { payloadType:
|
|
522
|
+
case PayloadType2.PoisonMicroblock: {
|
|
523
|
+
const header1 = bytesToHex2(r.readBytes(MICROBLOCK_HEADER_BYTES_LENGTH2));
|
|
524
|
+
const header2 = bytesToHex2(r.readBytes(MICROBLOCK_HEADER_BYTES_LENGTH2));
|
|
525
|
+
return { payloadType: PayloadType2.PoisonMicroblock, header1, header2 };
|
|
526
526
|
}
|
|
527
|
-
case
|
|
528
|
-
const tenureConsensusHash =
|
|
529
|
-
const prevTenureConsensusHash =
|
|
530
|
-
const burnViewConsensusHash =
|
|
531
|
-
const previousTenureEnd =
|
|
527
|
+
case PayloadType2.TenureChange: {
|
|
528
|
+
const tenureConsensusHash = bytesToHex2(r.readBytes(20));
|
|
529
|
+
const prevTenureConsensusHash = bytesToHex2(r.readBytes(20));
|
|
530
|
+
const burnViewConsensusHash = bytesToHex2(r.readBytes(20));
|
|
531
|
+
const previousTenureEnd = bytesToHex2(r.readBytes(32));
|
|
532
532
|
const previousTenureBlocks = r.readUInt32BE();
|
|
533
533
|
const cause = r.readUInt8();
|
|
534
|
-
const pubkeyHash =
|
|
534
|
+
const pubkeyHash = bytesToHex2(r.readBytes(20));
|
|
535
535
|
return {
|
|
536
|
-
payloadType:
|
|
536
|
+
payloadType: PayloadType2.TenureChange,
|
|
537
537
|
tenureConsensusHash,
|
|
538
538
|
prevTenureConsensusHash,
|
|
539
539
|
burnViewConsensusHash,
|
|
@@ -543,13 +543,13 @@ function readPayload(r) {
|
|
|
543
543
|
pubkeyHash
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
|
-
case
|
|
547
|
-
const coinbaseBuffer =
|
|
546
|
+
case PayloadType2.NakamotoCoinbase: {
|
|
547
|
+
const coinbaseBuffer = bytesToHex2(r.readBytes(COINBASE_BYTES_LENGTH2));
|
|
548
548
|
const optionalCV = readCV(r);
|
|
549
549
|
const recipient = optionalCV.type === "none" ? null : optionalCV.type === "some" ? optionalCV.value : optionalCV;
|
|
550
|
-
const vrfProof =
|
|
550
|
+
const vrfProof = bytesToHex2(r.readBytes(VRF_PROOF_BYTES_LENGTH2));
|
|
551
551
|
return {
|
|
552
|
-
payloadType:
|
|
552
|
+
payloadType: PayloadType2.NakamotoCoinbase,
|
|
553
553
|
coinbaseBuffer,
|
|
554
554
|
recipient,
|
|
555
555
|
vrfProof
|
|
@@ -559,12 +559,12 @@ function readPayload(r) {
|
|
|
559
559
|
throw new Error(`Unknown payload type: ${payloadType}`);
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
|
-
function
|
|
563
|
-
const bytes = typeof input === "string" ?
|
|
562
|
+
function deserializePostConditionWire2(input) {
|
|
563
|
+
const bytes = typeof input === "string" ? hexToBytes2(without0x2(input)) : input;
|
|
564
564
|
return readPostCondition(new BytesReader(bytes));
|
|
565
565
|
}
|
|
566
|
-
function
|
|
567
|
-
const bytes = typeof input === "string" ?
|
|
566
|
+
function deserializeTransaction2(input, meta) {
|
|
567
|
+
const bytes = typeof input === "string" ? hexToBytes2(without0x2(input)) : input;
|
|
568
568
|
const r = new BytesReader(bytes);
|
|
569
569
|
const tx = {
|
|
570
570
|
version: r.readUInt8(),
|
|
@@ -583,46 +583,46 @@ function deserializeTransaction(input, meta) {
|
|
|
583
583
|
|
|
584
584
|
// src/postconditions/convert.ts
|
|
585
585
|
var MAX_U64 = 18446744073709551615n;
|
|
586
|
-
function
|
|
587
|
-
const value =
|
|
586
|
+
function parsePostConditionAmount2(amount) {
|
|
587
|
+
const value = intToBigInt2(amount);
|
|
588
588
|
if (value < 0n || value > MAX_U64) {
|
|
589
589
|
throw new RangeError(`Post-condition amount must be between 0 and ${MAX_U64} (u64 max), received: ${value}`);
|
|
590
590
|
}
|
|
591
591
|
return value;
|
|
592
592
|
}
|
|
593
593
|
var FUNGIBLE_CODE_MAP = {
|
|
594
|
-
eq:
|
|
595
|
-
gt:
|
|
596
|
-
gte:
|
|
597
|
-
lt:
|
|
598
|
-
lte:
|
|
594
|
+
eq: FungibleConditionCode2.Equal,
|
|
595
|
+
gt: FungibleConditionCode2.Greater,
|
|
596
|
+
gte: FungibleConditionCode2.GreaterEqual,
|
|
597
|
+
lt: FungibleConditionCode2.Less,
|
|
598
|
+
lte: FungibleConditionCode2.LessEqual
|
|
599
599
|
};
|
|
600
600
|
var FUNGIBLE_CODE_REVERSE = {
|
|
601
|
-
[
|
|
602
|
-
[
|
|
603
|
-
[
|
|
604
|
-
[
|
|
605
|
-
[
|
|
601
|
+
[FungibleConditionCode2.Equal]: "eq",
|
|
602
|
+
[FungibleConditionCode2.Greater]: "gt",
|
|
603
|
+
[FungibleConditionCode2.GreaterEqual]: "gte",
|
|
604
|
+
[FungibleConditionCode2.Less]: "lt",
|
|
605
|
+
[FungibleConditionCode2.LessEqual]: "lte"
|
|
606
606
|
};
|
|
607
607
|
var NFT_CODE_MAP = {
|
|
608
|
-
sent:
|
|
609
|
-
"not-sent":
|
|
610
|
-
"maybe-sent":
|
|
608
|
+
sent: NonFungibleConditionCode2.Sends,
|
|
609
|
+
"not-sent": NonFungibleConditionCode2.DoesNotSend,
|
|
610
|
+
"maybe-sent": NonFungibleConditionCode2.MaybeSent
|
|
611
611
|
};
|
|
612
612
|
var NFT_CODE_REVERSE = {
|
|
613
|
-
[
|
|
614
|
-
[
|
|
615
|
-
[
|
|
613
|
+
[NonFungibleConditionCode2.Sends]: "sent",
|
|
614
|
+
[NonFungibleConditionCode2.DoesNotSend]: "not-sent",
|
|
615
|
+
[NonFungibleConditionCode2.MaybeSent]: "maybe-sent"
|
|
616
616
|
};
|
|
617
617
|
var POX_CODE_MAP = {
|
|
618
|
-
"will-not-perform":
|
|
619
|
-
"may-perform":
|
|
620
|
-
"will-perform":
|
|
618
|
+
"will-not-perform": PoxConditionCode2.WillNotPerform,
|
|
619
|
+
"may-perform": PoxConditionCode2.MayPerform,
|
|
620
|
+
"will-perform": PoxConditionCode2.WillPerform
|
|
621
621
|
};
|
|
622
622
|
var POX_CODE_REVERSE = {
|
|
623
|
-
[
|
|
624
|
-
[
|
|
625
|
-
[
|
|
623
|
+
[PoxConditionCode2.WillNotPerform]: "will-not-perform",
|
|
624
|
+
[PoxConditionCode2.MayPerform]: "may-perform",
|
|
625
|
+
[PoxConditionCode2.WillPerform]: "will-perform"
|
|
626
626
|
};
|
|
627
627
|
function resolvePrincipal(address) {
|
|
628
628
|
if (address === "origin")
|
|
@@ -646,7 +646,7 @@ function assetToString(asset) {
|
|
|
646
646
|
}
|
|
647
647
|
function parseAsset(asset) {
|
|
648
648
|
const [contractId, tokenName] = asset.split("::");
|
|
649
|
-
const [addr, name] =
|
|
649
|
+
const [addr, name] = parseContractId2(contractId);
|
|
650
650
|
return { address: addr, contractName: name, assetName: tokenName };
|
|
651
651
|
}
|
|
652
652
|
function convertPostCondition(pc) {
|
|
@@ -656,7 +656,7 @@ function convertPostCondition(pc) {
|
|
|
656
656
|
type: "stx",
|
|
657
657
|
principal: resolvePrincipal(pc.address),
|
|
658
658
|
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
659
|
-
amount:
|
|
659
|
+
amount: parsePostConditionAmount2(pc.amount)
|
|
660
660
|
};
|
|
661
661
|
case "ft-postcondition":
|
|
662
662
|
return {
|
|
@@ -664,7 +664,7 @@ function convertPostCondition(pc) {
|
|
|
664
664
|
principal: resolvePrincipal(pc.address),
|
|
665
665
|
asset: parseAsset(pc.asset),
|
|
666
666
|
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
667
|
-
amount:
|
|
667
|
+
amount: parsePostConditionAmount2(pc.amount)
|
|
668
668
|
};
|
|
669
669
|
case "nft-postcondition":
|
|
670
670
|
return {
|
|
@@ -679,7 +679,7 @@ function convertPostCondition(pc) {
|
|
|
679
679
|
type: "staking",
|
|
680
680
|
principal: resolvePrincipal(pc.address),
|
|
681
681
|
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
682
|
-
amount:
|
|
682
|
+
amount: parsePostConditionAmount2(pc.amount)
|
|
683
683
|
};
|
|
684
684
|
case "pox-postcondition":
|
|
685
685
|
return {
|
|
@@ -689,7 +689,7 @@ function convertPostCondition(pc) {
|
|
|
689
689
|
};
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function wireToPostCondition2(wire) {
|
|
693
693
|
switch (wire.type) {
|
|
694
694
|
case "stx":
|
|
695
695
|
return {
|
|
@@ -747,14 +747,14 @@ function poxName(code) {
|
|
|
747
747
|
throw new Error(`Unknown pox post-condition code: ${code}`);
|
|
748
748
|
return name;
|
|
749
749
|
}
|
|
750
|
-
function
|
|
751
|
-
return
|
|
750
|
+
function fromHex2(hex) {
|
|
751
|
+
return wireToPostCondition2(deserializePostConditionWire2(hex));
|
|
752
752
|
}
|
|
753
|
-
function
|
|
754
|
-
return
|
|
753
|
+
function postConditionToHex2(pc) {
|
|
754
|
+
return bytesToHex2(serializePostConditionWire2(convertPostCondition(pc)));
|
|
755
755
|
}
|
|
756
756
|
|
|
757
|
-
export {
|
|
757
|
+
export { AuthType2, PayloadType2, ClarityVersion2, AnchorMode2, PostConditionModeWire2, AddressHashMode2, PubKeyEncoding2, FungibleConditionCode2, NonFungibleConditionCode2, PoxConditionCode2, PostConditionPrincipalId2, AssetType2, AuthFieldType2, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES2, MEMO_MAX_LENGTH_BYTES2, MAX_STRING_LENGTH_BYTES2, COINBASE_BYTES_LENGTH2, VRF_PROOF_BYTES_LENGTH2, MICROBLOCK_HEADER_BYTES_LENGTH2, TenureChangeCause2, serializePostConditionWire2, serializePayload, clearTxCache, serializeTransaction2, serializeTransactionHex2, deserializePostConditionWire2, deserializeTransaction2, parsePostConditionAmount2, convertPostCondition, wireToPostCondition2, fromHex2, postConditionToHex2 };
|
|
758
758
|
|
|
759
|
-
//# debugId=
|
|
760
|
-
//# sourceMappingURL=stacks-
|
|
759
|
+
//# debugId=4AE8108BDE2F69E064756E2164756E21
|
|
760
|
+
//# sourceMappingURL=stacks-esm-phgy8yqf.js.map
|