@secondlayer/stacks 3.3.1 → 4.1.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-1arrcd11.js +48 -0
- package/dist/shared/stacks-1arrcd11.js.map +10 -0
- package/dist/shared/{stacks-6bgh2c9h.js → stacks-27fmgajb.js} +11 -3
- package/dist/shared/{stacks-b221qkst.cjs.map → stacks-27fmgajb.js.map} +4 -3
- package/dist/shared/{stacks-jknrzd6v.js → stacks-2evvn48s.js} +2 -2
- package/dist/shared/stacks-9mqveyjv.cjs.map +2 -2
- package/dist/shared/{stacks-8e5atbps.cjs → stacks-9qcr921s.cjs} +49 -5
- package/dist/shared/stacks-9qcr921s.cjs.map +10 -0
- package/dist/shared/{stacks-r1m1r72q.js → stacks-bw8qvqd1.js} +49 -23
- package/dist/shared/stacks-bw8qvqd1.js.map +27 -0
- package/dist/shared/stacks-enpj9krt.cjs +38 -0
- package/dist/shared/stacks-enpj9krt.cjs.map +10 -0
- package/dist/shared/{stacks-s361pmzs.cjs → stacks-fb75yew8.js} +86 -2
- package/dist/shared/{stacks-9d2d0qjc.js.map → stacks-fb75yew8.js.map} +6 -4
- 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-v1hzk599.js → stacks-jpt52csy.js} +8 -10
- package/dist/shared/stacks-jpt52csy.js.map +10 -0
- package/dist/shared/{stacks-b221qkst.cjs → stacks-nyaw1z2a.cjs} +7 -2
- package/dist/shared/{stacks-6bgh2c9h.js.map → stacks-nyaw1z2a.cjs.map} +4 -3
- package/dist/shared/{stacks-bm49tsh0.js → stacks-rpqtgpyj.js} +42 -9
- 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-9d2d0qjc.js → stacks-tdsp5gsb.cjs} +54 -23
- package/dist/shared/{stacks-s361pmzs.cjs.map → stacks-tdsp5gsb.cjs.map} +6 -4
- 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/shared/{stacks-fvnxj77s.cjs → stacks-y4f7fm03.cjs} +33 -13
- package/dist/shared/{stacks-fvnxj77s.cjs.map → stacks-y4f7fm03.cjs.map} +7 -6
- package/dist/src/accounts/index.d.cts +1 -1
- package/dist/src/accounts/index.d.ts +1 -1
- package/dist/src/actions/index.d.cts +15 -11
- package/dist/src/actions/index.d.ts +15 -11
- package/dist/src/actions/index.js +21 -25
- 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 +5 -6
- 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 +9 -10
- 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.map +2 -2
- package/dist/src/index.d.cts +18 -14
- package/dist/src/index.d.ts +18 -14
- package/dist/src/index.js +22 -27
- package/dist/src/index.js.map +3 -3
- 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 -3
- 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 +7 -9
- 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 +222 -21
- 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 +6 -7
- 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 +7 -9
- 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 +494 -367
- package/dist/src/tools/index.cjs.map +11 -9
- package/dist/src/tools/index.d.cts +1 -1
- package/dist/src/tools/index.d.ts +1 -1
- package/dist/src/tools/index.js +494 -367
- package/dist/src/tools/index.js.map +11 -9
- 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 -7
- package/dist/shared/stacks-1mpmzzyp.js +0 -85
- package/dist/shared/stacks-1mpmzzyp.js.map +0 -11
- package/dist/shared/stacks-44y18a8e.cjs +0 -28
- package/dist/shared/stacks-44y18a8e.cjs.map +0 -10
- package/dist/shared/stacks-8e5atbps.cjs.map +0 -10
- package/dist/shared/stacks-8khy9v27.cjs +0 -7
- package/dist/shared/stacks-8khy9v27.cjs.map +0 -10
- package/dist/shared/stacks-bm49tsh0.js.map +0 -10
- package/dist/shared/stacks-d6pgp4qk.cjs +0 -9
- package/dist/shared/stacks-d6pgp4qk.cjs.map +0 -9
- package/dist/shared/stacks-fh48neva.js +0 -13
- package/dist/shared/stacks-fh48neva.js.map +0 -10
- package/dist/shared/stacks-fjrpnkt3.cjs +0 -55
- package/dist/shared/stacks-fjrpnkt3.cjs.map +0 -11
- 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-r1m1r72q.js.map +0 -26
- package/dist/shared/stacks-v1hzk599.js.map +0 -10
- package/dist/shared/stacks-w8tt1fmt.js +0 -44
- package/dist/shared/stacks-w8tt1fmt.js.map +0 -10
- package/dist/shared/stacks-z53fwfcm.js +0 -3
- package/dist/shared/stacks-z53fwfcm.js.map +0 -9
- package/dist/src/x402/index.cjs +0 -65
- package/dist/src/x402/index.cjs.map +0 -11
- package/dist/src/x402/index.d.cts +0 -501
- package/dist/src/x402/index.d.ts +0 -501
- package/dist/src/x402/index.js +0 -90
- package/dist/src/x402/index.js.map +0 -11
- /package/dist/shared/{stacks-jknrzd6v.js.map → stacks-2evvn48s.js.map} +0 -0
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BytesReader,
|
|
3
|
+
readAddress,
|
|
4
|
+
readCV,
|
|
5
|
+
readLPString,
|
|
6
|
+
serializeCVBytes
|
|
7
|
+
} from "./stacks-ttdk2g2f.js";
|
|
8
|
+
import {
|
|
9
|
+
parseContractId
|
|
10
|
+
} from "./stacks-bfan7ex7.js";
|
|
11
|
+
import {
|
|
12
|
+
asciiToBytes,
|
|
13
|
+
bytesToAscii,
|
|
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";
|
|
27
|
+
|
|
28
|
+
// src/transactions/types.ts
|
|
29
|
+
var AuthType = {
|
|
30
|
+
Standard: 4,
|
|
31
|
+
Sponsored: 5
|
|
32
|
+
};
|
|
33
|
+
var PayloadType = {
|
|
34
|
+
TokenTransfer: 0,
|
|
35
|
+
SmartContract: 1,
|
|
36
|
+
ContractCall: 2,
|
|
37
|
+
PoisonMicroblock: 3,
|
|
38
|
+
Coinbase: 4,
|
|
39
|
+
CoinbaseToAltRecipient: 5,
|
|
40
|
+
VersionedSmartContract: 6,
|
|
41
|
+
TenureChange: 7,
|
|
42
|
+
NakamotoCoinbase: 8
|
|
43
|
+
};
|
|
44
|
+
var ClarityVersion = {
|
|
45
|
+
Clarity1: 1,
|
|
46
|
+
Clarity2: 2,
|
|
47
|
+
Clarity3: 3,
|
|
48
|
+
Clarity4: 4,
|
|
49
|
+
Clarity5: 5,
|
|
50
|
+
Clarity6: 6
|
|
51
|
+
};
|
|
52
|
+
var AnchorMode = {
|
|
53
|
+
OnChainOnly: 1,
|
|
54
|
+
OffChainOnly: 2,
|
|
55
|
+
Any: 3
|
|
56
|
+
};
|
|
57
|
+
var PostConditionModeWire = {
|
|
58
|
+
Allow: 1,
|
|
59
|
+
Deny: 2,
|
|
60
|
+
Originator: 3
|
|
61
|
+
};
|
|
62
|
+
var AddressHashMode = {
|
|
63
|
+
P2PKH: 0,
|
|
64
|
+
P2SH: 1,
|
|
65
|
+
P2WPKH: 2,
|
|
66
|
+
P2WSH: 3,
|
|
67
|
+
P2SH_NonSequential: 5,
|
|
68
|
+
P2WSH_P2SH_NonSequential: 7
|
|
69
|
+
};
|
|
70
|
+
var PubKeyEncoding = {
|
|
71
|
+
Compressed: 0,
|
|
72
|
+
Uncompressed: 1
|
|
73
|
+
};
|
|
74
|
+
var FungibleConditionCode = {
|
|
75
|
+
Equal: 1,
|
|
76
|
+
Greater: 2,
|
|
77
|
+
GreaterEqual: 3,
|
|
78
|
+
Less: 4,
|
|
79
|
+
LessEqual: 5
|
|
80
|
+
};
|
|
81
|
+
var NonFungibleConditionCode = {
|
|
82
|
+
Sends: 16,
|
|
83
|
+
DoesNotSend: 17,
|
|
84
|
+
MaybeSent: 18
|
|
85
|
+
};
|
|
86
|
+
var PoxConditionCode = {
|
|
87
|
+
WillNotPerform: 48,
|
|
88
|
+
MayPerform: 49,
|
|
89
|
+
WillPerform: 50
|
|
90
|
+
};
|
|
91
|
+
var PostConditionPrincipalId = {
|
|
92
|
+
Origin: 1,
|
|
93
|
+
Standard: 2,
|
|
94
|
+
Contract: 3
|
|
95
|
+
};
|
|
96
|
+
var AssetType = {
|
|
97
|
+
STX: 0,
|
|
98
|
+
Fungible: 1,
|
|
99
|
+
NonFungible: 2,
|
|
100
|
+
Staking: 3,
|
|
101
|
+
Pox: 4
|
|
102
|
+
};
|
|
103
|
+
var AuthFieldType = {
|
|
104
|
+
PublicKeyCompressed: 0,
|
|
105
|
+
PublicKeyUncompressed: 1,
|
|
106
|
+
SignatureCompressed: 2,
|
|
107
|
+
SignatureUncompressed: 3
|
|
108
|
+
};
|
|
109
|
+
var RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;
|
|
110
|
+
var MEMO_MAX_LENGTH_BYTES = 34;
|
|
111
|
+
var MAX_STRING_LENGTH_BYTES = 128;
|
|
112
|
+
var COINBASE_BYTES_LENGTH = 32;
|
|
113
|
+
var VRF_PROOF_BYTES_LENGTH = 80;
|
|
114
|
+
var MICROBLOCK_HEADER_BYTES_LENGTH = 132;
|
|
115
|
+
var TenureChangeCause = {
|
|
116
|
+
BlockFound: 0,
|
|
117
|
+
Extended: 1,
|
|
118
|
+
ExtendedRuntime: 2,
|
|
119
|
+
ExtendedReadCount: 3,
|
|
120
|
+
ExtendedReadLength: 4,
|
|
121
|
+
ExtendedWriteCount: 5,
|
|
122
|
+
ExtendedWriteLength: 6
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// src/transactions/wire/serialize.ts
|
|
126
|
+
function serializeAddress(c32Address) {
|
|
127
|
+
const [version, hash160] = c32addressDecode(c32Address);
|
|
128
|
+
return concatBytes(new Uint8Array([version]), hexToBytes(hash160));
|
|
129
|
+
}
|
|
130
|
+
function serializeLPString(str, prefixBytes = 1) {
|
|
131
|
+
const content = utf8ToBytes(str);
|
|
132
|
+
const prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));
|
|
133
|
+
return concatBytes(prefix, content);
|
|
134
|
+
}
|
|
135
|
+
function serializeLPStringLong(str) {
|
|
136
|
+
return serializeLPString(str, 4);
|
|
137
|
+
}
|
|
138
|
+
function serializeMemo(memo) {
|
|
139
|
+
const content = asciiToBytes(memo);
|
|
140
|
+
const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);
|
|
141
|
+
padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));
|
|
142
|
+
return padded;
|
|
143
|
+
}
|
|
144
|
+
function serializeSpendingCondition(condition) {
|
|
145
|
+
const parts = [
|
|
146
|
+
writeUInt8(condition.hashMode),
|
|
147
|
+
hexToBytes(condition.signer),
|
|
148
|
+
intToBytes(condition.nonce, 8),
|
|
149
|
+
intToBytes(condition.fee, 8)
|
|
150
|
+
];
|
|
151
|
+
if ("signature" in condition) {
|
|
152
|
+
const sc = condition;
|
|
153
|
+
parts.push(writeUInt8(sc.keyEncoding));
|
|
154
|
+
parts.push(hexToBytes(sc.signature));
|
|
155
|
+
} else {
|
|
156
|
+
const mc = condition;
|
|
157
|
+
parts.push(writeUInt32BE(mc.fields.length));
|
|
158
|
+
for (const field of mc.fields) {
|
|
159
|
+
parts.push(serializeAuthField(field));
|
|
160
|
+
}
|
|
161
|
+
parts.push(writeUInt16BE(mc.signaturesRequired));
|
|
162
|
+
}
|
|
163
|
+
return concatBytes(...parts);
|
|
164
|
+
}
|
|
165
|
+
function serializeAuthField(field) {
|
|
166
|
+
if (field.type === "publicKey") {
|
|
167
|
+
const typeId2 = field.pubKeyEncoding === 0 ? 0 : 1;
|
|
168
|
+
return concatBytes(writeUInt8(typeId2), hexToBytes(field.data));
|
|
169
|
+
}
|
|
170
|
+
const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
|
|
171
|
+
return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
|
|
172
|
+
}
|
|
173
|
+
function serializeAuthorization(auth) {
|
|
174
|
+
const parts = [writeUInt8(auth.authType)];
|
|
175
|
+
parts.push(serializeSpendingCondition(auth.spendingCondition));
|
|
176
|
+
if (auth.authType === AuthType.Sponsored) {
|
|
177
|
+
parts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));
|
|
178
|
+
}
|
|
179
|
+
return concatBytes(...parts);
|
|
180
|
+
}
|
|
181
|
+
function serializePrincipal(principal) {
|
|
182
|
+
switch (principal.type) {
|
|
183
|
+
case "origin":
|
|
184
|
+
return writeUInt8(PostConditionPrincipalId.Origin);
|
|
185
|
+
case "standard":
|
|
186
|
+
return concatBytes(writeUInt8(PostConditionPrincipalId.Standard), serializeAddress(principal.address));
|
|
187
|
+
case "contract":
|
|
188
|
+
return concatBytes(writeUInt8(PostConditionPrincipalId.Contract), serializeAddress(principal.address), serializeLPString(principal.contractName));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function serializeAssetInfo(asset) {
|
|
192
|
+
return concatBytes(serializeAddress(asset.address), serializeLPString(asset.contractName), serializeLPString(asset.assetName));
|
|
193
|
+
}
|
|
194
|
+
function serializePostConditionWire(pc) {
|
|
195
|
+
const parts = [];
|
|
196
|
+
switch (pc.type) {
|
|
197
|
+
case "stx":
|
|
198
|
+
parts.push(writeUInt8(AssetType.STX));
|
|
199
|
+
parts.push(serializePrincipal(pc.principal));
|
|
200
|
+
parts.push(writeUInt8(pc.conditionCode));
|
|
201
|
+
parts.push(intToBytes(pc.amount, 8));
|
|
202
|
+
break;
|
|
203
|
+
case "ft":
|
|
204
|
+
parts.push(writeUInt8(AssetType.Fungible));
|
|
205
|
+
parts.push(serializePrincipal(pc.principal));
|
|
206
|
+
parts.push(serializeAssetInfo(pc.asset));
|
|
207
|
+
parts.push(writeUInt8(pc.conditionCode));
|
|
208
|
+
parts.push(intToBytes(pc.amount, 8));
|
|
209
|
+
break;
|
|
210
|
+
case "nft":
|
|
211
|
+
parts.push(writeUInt8(AssetType.NonFungible));
|
|
212
|
+
parts.push(serializePrincipal(pc.principal));
|
|
213
|
+
parts.push(serializeAssetInfo(pc.asset));
|
|
214
|
+
parts.push(serializeCVBytes(pc.assetId));
|
|
215
|
+
parts.push(writeUInt8(pc.conditionCode));
|
|
216
|
+
break;
|
|
217
|
+
case "staking":
|
|
218
|
+
parts.push(writeUInt8(AssetType.Staking));
|
|
219
|
+
parts.push(serializePrincipal(pc.principal));
|
|
220
|
+
parts.push(writeUInt8(pc.conditionCode));
|
|
221
|
+
parts.push(intToBytes(pc.amount, 8));
|
|
222
|
+
break;
|
|
223
|
+
case "pox":
|
|
224
|
+
parts.push(writeUInt8(AssetType.Pox));
|
|
225
|
+
parts.push(serializePrincipal(pc.principal));
|
|
226
|
+
parts.push(writeUInt8(pc.conditionCode));
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
return concatBytes(...parts);
|
|
230
|
+
}
|
|
231
|
+
function serializePostConditions(pcs) {
|
|
232
|
+
const parts = [writeUInt32BE(pcs.length)];
|
|
233
|
+
for (const pc of pcs)
|
|
234
|
+
parts.push(serializePostConditionWire(pc));
|
|
235
|
+
return concatBytes(...parts);
|
|
236
|
+
}
|
|
237
|
+
function serializePayload(payload) {
|
|
238
|
+
const parts = [writeUInt8(payload.payloadType)];
|
|
239
|
+
switch (payload.payloadType) {
|
|
240
|
+
case PayloadType.TokenTransfer:
|
|
241
|
+
parts.push(serializeCVBytes(payload.recipient));
|
|
242
|
+
parts.push(intToBytes(payload.amount, 8));
|
|
243
|
+
parts.push(serializeMemo(payload.memo));
|
|
244
|
+
break;
|
|
245
|
+
case PayloadType.ContractCall:
|
|
246
|
+
parts.push(serializeAddress(payload.contractAddress));
|
|
247
|
+
parts.push(serializeLPString(payload.contractName));
|
|
248
|
+
parts.push(serializeLPString(payload.functionName));
|
|
249
|
+
parts.push(writeUInt32BE(payload.functionArgs.length));
|
|
250
|
+
for (const arg of payload.functionArgs) {
|
|
251
|
+
parts.push(serializeCVBytes(arg));
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
case PayloadType.SmartContract:
|
|
255
|
+
parts.push(serializeLPString(payload.contractName));
|
|
256
|
+
parts.push(serializeLPStringLong(payload.codeBody));
|
|
257
|
+
break;
|
|
258
|
+
case PayloadType.VersionedSmartContract:
|
|
259
|
+
parts.push(writeUInt8(payload.clarityVersion ?? 2));
|
|
260
|
+
parts.push(serializeLPString(payload.contractName));
|
|
261
|
+
parts.push(serializeLPStringLong(payload.codeBody));
|
|
262
|
+
break;
|
|
263
|
+
case PayloadType.Coinbase:
|
|
264
|
+
parts.push(hexToBytes(payload.coinbaseBuffer));
|
|
265
|
+
break;
|
|
266
|
+
case PayloadType.CoinbaseToAltRecipient: {
|
|
267
|
+
const cbAlt = payload;
|
|
268
|
+
parts.push(hexToBytes(cbAlt.coinbaseBuffer));
|
|
269
|
+
parts.push(serializeCVBytes(cbAlt.recipient));
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
case PayloadType.PoisonMicroblock: {
|
|
273
|
+
const pm = payload;
|
|
274
|
+
parts.push(hexToBytes(pm.header1));
|
|
275
|
+
parts.push(hexToBytes(pm.header2));
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
case PayloadType.TenureChange: {
|
|
279
|
+
const tc = payload;
|
|
280
|
+
parts.push(hexToBytes(tc.tenureConsensusHash));
|
|
281
|
+
parts.push(hexToBytes(tc.prevTenureConsensusHash));
|
|
282
|
+
parts.push(hexToBytes(tc.burnViewConsensusHash));
|
|
283
|
+
parts.push(hexToBytes(tc.previousTenureEnd));
|
|
284
|
+
parts.push(writeUInt32BE(tc.previousTenureBlocks));
|
|
285
|
+
parts.push(writeUInt8(tc.cause));
|
|
286
|
+
parts.push(hexToBytes(tc.pubkeyHash));
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case PayloadType.NakamotoCoinbase: {
|
|
290
|
+
const nc = payload;
|
|
291
|
+
parts.push(hexToBytes(nc.coinbaseBuffer));
|
|
292
|
+
if (nc.recipient) {
|
|
293
|
+
parts.push(serializeCVBytes({ type: "some", value: nc.recipient }));
|
|
294
|
+
} else {
|
|
295
|
+
parts.push(serializeCVBytes({ type: "none" }));
|
|
296
|
+
}
|
|
297
|
+
parts.push(hexToBytes(nc.vrfProof));
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return concatBytes(...parts);
|
|
302
|
+
}
|
|
303
|
+
var _txCache = new WeakMap;
|
|
304
|
+
function clearTxCache(tx) {
|
|
305
|
+
_txCache.delete(tx);
|
|
306
|
+
}
|
|
307
|
+
function serializeTransaction(tx) {
|
|
308
|
+
const cached = _txCache.get(tx);
|
|
309
|
+
if (cached)
|
|
310
|
+
return cached;
|
|
311
|
+
const bytes = concatBytes(writeUInt8(tx.version), writeUInt32BE(tx.chainId), serializeAuthorization(tx.auth), writeUInt8(tx.anchorMode), writeUInt8(tx.postConditionMode), serializePostConditions(tx.postConditions), serializePayload(tx.payload));
|
|
312
|
+
_txCache.set(tx, bytes);
|
|
313
|
+
return bytes;
|
|
314
|
+
}
|
|
315
|
+
function serializeTransactionHex(tx) {
|
|
316
|
+
return bytesToHex(serializeTransaction(tx));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// src/transactions/wire/deserialize.ts
|
|
320
|
+
function readSpendingCondition(r) {
|
|
321
|
+
const hashMode = r.readUInt8();
|
|
322
|
+
const signer = bytesToHex(r.readBytes(20));
|
|
323
|
+
const nonce = r.readBigUInt64BE();
|
|
324
|
+
const fee = r.readBigUInt64BE();
|
|
325
|
+
if (hashMode === AddressHashMode.P2PKH || hashMode === AddressHashMode.P2WPKH) {
|
|
326
|
+
const keyEncoding = r.readUInt8();
|
|
327
|
+
const signature = bytesToHex(r.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));
|
|
328
|
+
return {
|
|
329
|
+
hashMode,
|
|
330
|
+
signer,
|
|
331
|
+
nonce,
|
|
332
|
+
fee,
|
|
333
|
+
keyEncoding,
|
|
334
|
+
signature
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
const fieldCount = r.readUInt32BE();
|
|
338
|
+
const fields = [];
|
|
339
|
+
for (let i = 0;i < fieldCount; i++) {
|
|
340
|
+
const fieldType = r.readUInt8();
|
|
341
|
+
if (fieldType <= 1) {
|
|
342
|
+
const keyLen = fieldType === 0 ? 33 : 65;
|
|
343
|
+
fields.push({
|
|
344
|
+
type: "publicKey",
|
|
345
|
+
pubKeyEncoding: fieldType,
|
|
346
|
+
data: bytesToHex(r.readBytes(keyLen))
|
|
347
|
+
});
|
|
348
|
+
} else {
|
|
349
|
+
fields.push({
|
|
350
|
+
type: "signature",
|
|
351
|
+
pubKeyEncoding: fieldType === 2 ? 0 : 1,
|
|
352
|
+
data: bytesToHex(r.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES))
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const signaturesRequired = r.readUInt16BE();
|
|
357
|
+
return {
|
|
358
|
+
hashMode,
|
|
359
|
+
signer,
|
|
360
|
+
nonce,
|
|
361
|
+
fee,
|
|
362
|
+
fields,
|
|
363
|
+
signaturesRequired
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function readAuthorization(r) {
|
|
367
|
+
const authType = r.readUInt8();
|
|
368
|
+
const spendingCondition = readSpendingCondition(r);
|
|
369
|
+
if (authType === AuthType.Standard) {
|
|
370
|
+
return { authType: AuthType.Standard, spendingCondition };
|
|
371
|
+
}
|
|
372
|
+
const sponsorSpendingCondition = readSpendingCondition(r);
|
|
373
|
+
return {
|
|
374
|
+
authType: AuthType.Sponsored,
|
|
375
|
+
spendingCondition,
|
|
376
|
+
sponsorSpendingCondition
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function readAssetInfo(r) {
|
|
380
|
+
return {
|
|
381
|
+
address: readAddress(r),
|
|
382
|
+
contractName: readLPString(r),
|
|
383
|
+
assetName: readLPString(r)
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function readPostConditionPrincipal(r) {
|
|
387
|
+
const type = r.readUInt8();
|
|
388
|
+
switch (type) {
|
|
389
|
+
case PostConditionPrincipalId.Origin:
|
|
390
|
+
return { type: "origin" };
|
|
391
|
+
case PostConditionPrincipalId.Standard:
|
|
392
|
+
return { type: "standard", address: readAddress(r) };
|
|
393
|
+
case PostConditionPrincipalId.Contract:
|
|
394
|
+
return {
|
|
395
|
+
type: "contract",
|
|
396
|
+
address: readAddress(r),
|
|
397
|
+
contractName: readLPString(r)
|
|
398
|
+
};
|
|
399
|
+
default:
|
|
400
|
+
return { type: "origin" };
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function readPostCondition(r) {
|
|
404
|
+
const assetType = r.readUInt8();
|
|
405
|
+
const principal = readPostConditionPrincipal(r);
|
|
406
|
+
switch (assetType) {
|
|
407
|
+
case AssetType.STX:
|
|
408
|
+
return {
|
|
409
|
+
type: "stx",
|
|
410
|
+
principal,
|
|
411
|
+
conditionCode: r.readUInt8(),
|
|
412
|
+
amount: r.readBigUInt64BE()
|
|
413
|
+
};
|
|
414
|
+
case AssetType.Fungible:
|
|
415
|
+
return {
|
|
416
|
+
type: "ft",
|
|
417
|
+
principal,
|
|
418
|
+
asset: readAssetInfo(r),
|
|
419
|
+
conditionCode: r.readUInt8(),
|
|
420
|
+
amount: r.readBigUInt64BE()
|
|
421
|
+
};
|
|
422
|
+
case AssetType.NonFungible:
|
|
423
|
+
return {
|
|
424
|
+
type: "nft",
|
|
425
|
+
principal,
|
|
426
|
+
asset: readAssetInfo(r),
|
|
427
|
+
assetId: readCV(r),
|
|
428
|
+
conditionCode: r.readUInt8()
|
|
429
|
+
};
|
|
430
|
+
case AssetType.Staking:
|
|
431
|
+
return {
|
|
432
|
+
type: "staking",
|
|
433
|
+
principal,
|
|
434
|
+
conditionCode: r.readUInt8(),
|
|
435
|
+
amount: r.readBigUInt64BE()
|
|
436
|
+
};
|
|
437
|
+
case AssetType.Pox:
|
|
438
|
+
return {
|
|
439
|
+
type: "pox",
|
|
440
|
+
principal,
|
|
441
|
+
conditionCode: r.readUInt8()
|
|
442
|
+
};
|
|
443
|
+
default:
|
|
444
|
+
throw new Error(`Unknown post-condition asset type: 0x${assetType.toString(16).padStart(2, "0")}`);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function readPostConditions(r) {
|
|
448
|
+
const count = r.readUInt32BE();
|
|
449
|
+
const pcs = [];
|
|
450
|
+
for (let i = 0;i < count; i++) {
|
|
451
|
+
try {
|
|
452
|
+
pcs.push(readPostCondition(r));
|
|
453
|
+
} catch (e) {
|
|
454
|
+
if (e instanceof Error && e.message.startsWith("Unknown post-condition asset type:")) {
|
|
455
|
+
throw new Error(`${e.message} (post-condition ${i + 1}/${count})`);
|
|
456
|
+
}
|
|
457
|
+
throw e;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return pcs;
|
|
461
|
+
}
|
|
462
|
+
function readPayload(r) {
|
|
463
|
+
const payloadType = r.readUInt8();
|
|
464
|
+
switch (payloadType) {
|
|
465
|
+
case PayloadType.TokenTransfer: {
|
|
466
|
+
const recipient = readCV(r);
|
|
467
|
+
const amount = r.readBigUInt64BE();
|
|
468
|
+
const memoBytes = r.readBytes(MEMO_MAX_LENGTH_BYTES);
|
|
469
|
+
const memo = bytesToAscii(memoBytes).replace(/\0+$/, "");
|
|
470
|
+
return {
|
|
471
|
+
payloadType: PayloadType.TokenTransfer,
|
|
472
|
+
recipient,
|
|
473
|
+
amount,
|
|
474
|
+
memo
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
case PayloadType.ContractCall: {
|
|
478
|
+
const contractAddress = readAddress(r);
|
|
479
|
+
const contractName = readLPString(r);
|
|
480
|
+
const functionName = readLPString(r);
|
|
481
|
+
const numArgs = r.readUInt32BE();
|
|
482
|
+
const functionArgs = [];
|
|
483
|
+
for (let i = 0;i < numArgs; i++)
|
|
484
|
+
functionArgs.push(readCV(r));
|
|
485
|
+
return {
|
|
486
|
+
payloadType: PayloadType.ContractCall,
|
|
487
|
+
contractAddress,
|
|
488
|
+
contractName,
|
|
489
|
+
functionName,
|
|
490
|
+
functionArgs
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
case PayloadType.SmartContract: {
|
|
494
|
+
const contractName = readLPString(r);
|
|
495
|
+
const codeBody = readLPString(r, 4);
|
|
496
|
+
return { payloadType: PayloadType.SmartContract, contractName, codeBody };
|
|
497
|
+
}
|
|
498
|
+
case PayloadType.VersionedSmartContract: {
|
|
499
|
+
const clarityVersion = r.readUInt8();
|
|
500
|
+
const contractName = readLPString(r);
|
|
501
|
+
const codeBody = readLPString(r, 4);
|
|
502
|
+
return {
|
|
503
|
+
payloadType: PayloadType.VersionedSmartContract,
|
|
504
|
+
clarityVersion,
|
|
505
|
+
contractName,
|
|
506
|
+
codeBody
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
case PayloadType.Coinbase: {
|
|
510
|
+
const coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));
|
|
511
|
+
return { payloadType: PayloadType.Coinbase, coinbaseBuffer };
|
|
512
|
+
}
|
|
513
|
+
case PayloadType.CoinbaseToAltRecipient: {
|
|
514
|
+
const coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));
|
|
515
|
+
const recipient = readCV(r);
|
|
516
|
+
return {
|
|
517
|
+
payloadType: PayloadType.CoinbaseToAltRecipient,
|
|
518
|
+
coinbaseBuffer,
|
|
519
|
+
recipient
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
case PayloadType.PoisonMicroblock: {
|
|
523
|
+
const header1 = bytesToHex(r.readBytes(MICROBLOCK_HEADER_BYTES_LENGTH));
|
|
524
|
+
const header2 = bytesToHex(r.readBytes(MICROBLOCK_HEADER_BYTES_LENGTH));
|
|
525
|
+
return { payloadType: PayloadType.PoisonMicroblock, header1, header2 };
|
|
526
|
+
}
|
|
527
|
+
case PayloadType.TenureChange: {
|
|
528
|
+
const tenureConsensusHash = bytesToHex(r.readBytes(20));
|
|
529
|
+
const prevTenureConsensusHash = bytesToHex(r.readBytes(20));
|
|
530
|
+
const burnViewConsensusHash = bytesToHex(r.readBytes(20));
|
|
531
|
+
const previousTenureEnd = bytesToHex(r.readBytes(32));
|
|
532
|
+
const previousTenureBlocks = r.readUInt32BE();
|
|
533
|
+
const cause = r.readUInt8();
|
|
534
|
+
const pubkeyHash = bytesToHex(r.readBytes(20));
|
|
535
|
+
return {
|
|
536
|
+
payloadType: PayloadType.TenureChange,
|
|
537
|
+
tenureConsensusHash,
|
|
538
|
+
prevTenureConsensusHash,
|
|
539
|
+
burnViewConsensusHash,
|
|
540
|
+
previousTenureEnd,
|
|
541
|
+
previousTenureBlocks,
|
|
542
|
+
cause,
|
|
543
|
+
pubkeyHash
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
case PayloadType.NakamotoCoinbase: {
|
|
547
|
+
const coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));
|
|
548
|
+
const optionalCV = readCV(r);
|
|
549
|
+
const recipient = optionalCV.type === "none" ? null : optionalCV.type === "some" ? optionalCV.value : optionalCV;
|
|
550
|
+
const vrfProof = bytesToHex(r.readBytes(VRF_PROOF_BYTES_LENGTH));
|
|
551
|
+
return {
|
|
552
|
+
payloadType: PayloadType.NakamotoCoinbase,
|
|
553
|
+
coinbaseBuffer,
|
|
554
|
+
recipient,
|
|
555
|
+
vrfProof
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
default:
|
|
559
|
+
throw new Error(`Unknown payload type: ${payloadType}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function deserializePostConditionWire(input) {
|
|
563
|
+
const bytes = typeof input === "string" ? hexToBytes(without0x(input)) : input;
|
|
564
|
+
return readPostCondition(new BytesReader(bytes));
|
|
565
|
+
}
|
|
566
|
+
function deserializeTransaction(input, meta) {
|
|
567
|
+
const bytes = typeof input === "string" ? hexToBytes(without0x(input)) : input;
|
|
568
|
+
const r = new BytesReader(bytes);
|
|
569
|
+
const tx = {
|
|
570
|
+
version: r.readUInt8(),
|
|
571
|
+
chainId: r.readUInt32BE(),
|
|
572
|
+
auth: readAuthorization(r),
|
|
573
|
+
anchorMode: r.readUInt8(),
|
|
574
|
+
postConditionMode: r.readUInt8(),
|
|
575
|
+
postConditions: readPostConditions(r),
|
|
576
|
+
payload: readPayload(r)
|
|
577
|
+
};
|
|
578
|
+
if (meta?._multisig) {
|
|
579
|
+
tx._multisig = meta._multisig;
|
|
580
|
+
}
|
|
581
|
+
return tx;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// src/postconditions/convert.ts
|
|
585
|
+
var MAX_U64 = 18446744073709551615n;
|
|
586
|
+
function parsePostConditionAmount(amount) {
|
|
587
|
+
const value = intToBigInt(amount);
|
|
588
|
+
if (value < 0n || value > MAX_U64) {
|
|
589
|
+
throw new RangeError(`Post-condition amount must be between 0 and ${MAX_U64} (u64 max), received: ${value}`);
|
|
590
|
+
}
|
|
591
|
+
return value;
|
|
592
|
+
}
|
|
593
|
+
var FUNGIBLE_CODE_MAP = {
|
|
594
|
+
eq: FungibleConditionCode.Equal,
|
|
595
|
+
gt: FungibleConditionCode.Greater,
|
|
596
|
+
gte: FungibleConditionCode.GreaterEqual,
|
|
597
|
+
lt: FungibleConditionCode.Less,
|
|
598
|
+
lte: FungibleConditionCode.LessEqual
|
|
599
|
+
};
|
|
600
|
+
var FUNGIBLE_CODE_REVERSE = {
|
|
601
|
+
[FungibleConditionCode.Equal]: "eq",
|
|
602
|
+
[FungibleConditionCode.Greater]: "gt",
|
|
603
|
+
[FungibleConditionCode.GreaterEqual]: "gte",
|
|
604
|
+
[FungibleConditionCode.Less]: "lt",
|
|
605
|
+
[FungibleConditionCode.LessEqual]: "lte"
|
|
606
|
+
};
|
|
607
|
+
var NFT_CODE_MAP = {
|
|
608
|
+
sent: NonFungibleConditionCode.Sends,
|
|
609
|
+
"not-sent": NonFungibleConditionCode.DoesNotSend,
|
|
610
|
+
"maybe-sent": NonFungibleConditionCode.MaybeSent
|
|
611
|
+
};
|
|
612
|
+
var NFT_CODE_REVERSE = {
|
|
613
|
+
[NonFungibleConditionCode.Sends]: "sent",
|
|
614
|
+
[NonFungibleConditionCode.DoesNotSend]: "not-sent",
|
|
615
|
+
[NonFungibleConditionCode.MaybeSent]: "maybe-sent"
|
|
616
|
+
};
|
|
617
|
+
var POX_CODE_MAP = {
|
|
618
|
+
"will-not-perform": PoxConditionCode.WillNotPerform,
|
|
619
|
+
"may-perform": PoxConditionCode.MayPerform,
|
|
620
|
+
"will-perform": PoxConditionCode.WillPerform
|
|
621
|
+
};
|
|
622
|
+
var POX_CODE_REVERSE = {
|
|
623
|
+
[PoxConditionCode.WillNotPerform]: "will-not-perform",
|
|
624
|
+
[PoxConditionCode.MayPerform]: "may-perform",
|
|
625
|
+
[PoxConditionCode.WillPerform]: "will-perform"
|
|
626
|
+
};
|
|
627
|
+
function resolvePrincipal(address) {
|
|
628
|
+
if (address === "origin")
|
|
629
|
+
return { type: "origin" };
|
|
630
|
+
const [addr, name] = address.split(".");
|
|
631
|
+
if (name) {
|
|
632
|
+
return { type: "contract", address: addr, contractName: name };
|
|
633
|
+
}
|
|
634
|
+
return { type: "standard", address: addr };
|
|
635
|
+
}
|
|
636
|
+
function principalToString(principal) {
|
|
637
|
+
if (principal.type === "origin")
|
|
638
|
+
return "origin";
|
|
639
|
+
if (principal.type === "contract") {
|
|
640
|
+
return `${principal.address}.${principal.contractName}`;
|
|
641
|
+
}
|
|
642
|
+
return principal.address;
|
|
643
|
+
}
|
|
644
|
+
function assetToString(asset) {
|
|
645
|
+
return `${asset.address}.${asset.contractName}::${asset.assetName}`;
|
|
646
|
+
}
|
|
647
|
+
function parseAsset(asset) {
|
|
648
|
+
const [contractId, tokenName] = asset.split("::");
|
|
649
|
+
const [addr, name] = parseContractId(contractId);
|
|
650
|
+
return { address: addr, contractName: name, assetName: tokenName };
|
|
651
|
+
}
|
|
652
|
+
function convertPostCondition(pc) {
|
|
653
|
+
switch (pc.type) {
|
|
654
|
+
case "stx-postcondition":
|
|
655
|
+
return {
|
|
656
|
+
type: "stx",
|
|
657
|
+
principal: resolvePrincipal(pc.address),
|
|
658
|
+
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
659
|
+
amount: parsePostConditionAmount(pc.amount)
|
|
660
|
+
};
|
|
661
|
+
case "ft-postcondition":
|
|
662
|
+
return {
|
|
663
|
+
type: "ft",
|
|
664
|
+
principal: resolvePrincipal(pc.address),
|
|
665
|
+
asset: parseAsset(pc.asset),
|
|
666
|
+
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
667
|
+
amount: parsePostConditionAmount(pc.amount)
|
|
668
|
+
};
|
|
669
|
+
case "nft-postcondition":
|
|
670
|
+
return {
|
|
671
|
+
type: "nft",
|
|
672
|
+
principal: resolvePrincipal(pc.address),
|
|
673
|
+
asset: parseAsset(pc.asset),
|
|
674
|
+
conditionCode: NFT_CODE_MAP[pc.condition],
|
|
675
|
+
assetId: pc.assetId
|
|
676
|
+
};
|
|
677
|
+
case "staking-postcondition":
|
|
678
|
+
return {
|
|
679
|
+
type: "staking",
|
|
680
|
+
principal: resolvePrincipal(pc.address),
|
|
681
|
+
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
682
|
+
amount: parsePostConditionAmount(pc.amount)
|
|
683
|
+
};
|
|
684
|
+
case "pox-postcondition":
|
|
685
|
+
return {
|
|
686
|
+
type: "pox",
|
|
687
|
+
principal: resolvePrincipal(pc.address),
|
|
688
|
+
conditionCode: POX_CODE_MAP[pc.condition]
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
function wireToPostCondition(wire) {
|
|
693
|
+
switch (wire.type) {
|
|
694
|
+
case "stx":
|
|
695
|
+
return {
|
|
696
|
+
type: "stx-postcondition",
|
|
697
|
+
address: principalToString(wire.principal),
|
|
698
|
+
condition: fungibleName(wire.conditionCode),
|
|
699
|
+
amount: wire.amount.toString()
|
|
700
|
+
};
|
|
701
|
+
case "ft":
|
|
702
|
+
return {
|
|
703
|
+
type: "ft-postcondition",
|
|
704
|
+
address: principalToString(wire.principal),
|
|
705
|
+
condition: fungibleName(wire.conditionCode),
|
|
706
|
+
amount: wire.amount.toString(),
|
|
707
|
+
asset: assetToString(wire.asset)
|
|
708
|
+
};
|
|
709
|
+
case "nft":
|
|
710
|
+
return {
|
|
711
|
+
type: "nft-postcondition",
|
|
712
|
+
address: principalToString(wire.principal),
|
|
713
|
+
condition: nftName(wire.conditionCode),
|
|
714
|
+
asset: assetToString(wire.asset),
|
|
715
|
+
assetId: wire.assetId
|
|
716
|
+
};
|
|
717
|
+
case "staking":
|
|
718
|
+
return {
|
|
719
|
+
type: "staking-postcondition",
|
|
720
|
+
address: principalToString(wire.principal),
|
|
721
|
+
condition: fungibleName(wire.conditionCode),
|
|
722
|
+
amount: wire.amount.toString()
|
|
723
|
+
};
|
|
724
|
+
case "pox":
|
|
725
|
+
return {
|
|
726
|
+
type: "pox-postcondition",
|
|
727
|
+
address: principalToString(wire.principal),
|
|
728
|
+
condition: poxName(wire.conditionCode)
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
function fungibleName(code) {
|
|
733
|
+
const name = FUNGIBLE_CODE_REVERSE[code];
|
|
734
|
+
if (!name)
|
|
735
|
+
throw new Error(`Unknown fungible post-condition code: ${code}`);
|
|
736
|
+
return name;
|
|
737
|
+
}
|
|
738
|
+
function nftName(code) {
|
|
739
|
+
const name = NFT_CODE_REVERSE[code];
|
|
740
|
+
if (!name)
|
|
741
|
+
throw new Error(`Unknown nft post-condition code: ${code}`);
|
|
742
|
+
return name;
|
|
743
|
+
}
|
|
744
|
+
function poxName(code) {
|
|
745
|
+
const name = POX_CODE_REVERSE[code];
|
|
746
|
+
if (!name)
|
|
747
|
+
throw new Error(`Unknown pox post-condition code: ${code}`);
|
|
748
|
+
return name;
|
|
749
|
+
}
|
|
750
|
+
function fromHex(hex) {
|
|
751
|
+
return wireToPostCondition(deserializePostConditionWire(hex));
|
|
752
|
+
}
|
|
753
|
+
function postConditionToHex(pc) {
|
|
754
|
+
return bytesToHex(serializePostConditionWire(convertPostCondition(pc)));
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
export { AuthType, PayloadType, ClarityVersion, AnchorMode, PostConditionModeWire, AddressHashMode, PubKeyEncoding, FungibleConditionCode, NonFungibleConditionCode, PoxConditionCode, PostConditionPrincipalId, AssetType, AuthFieldType, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, COINBASE_BYTES_LENGTH, VRF_PROOF_BYTES_LENGTH, MICROBLOCK_HEADER_BYTES_LENGTH, TenureChangeCause, serializePostConditionWire, serializePayload, clearTxCache, serializeTransaction, serializeTransactionHex, deserializePostConditionWire, deserializeTransaction, parsePostConditionAmount, convertPostCondition, wireToPostCondition, fromHex, postConditionToHex };
|
|
758
|
+
|
|
759
|
+
//# debugId=0727B877F1BE3A9864756E2164756E21
|
|
760
|
+
//# sourceMappingURL=stacks-w23294am.js.map
|