@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
package/dist/src/pox5/index.cjs
CHANGED
|
@@ -11,9 +11,12 @@ __export(exports_pox5, {
|
|
|
11
11
|
pushCScriptNum: () => pushCScriptNum,
|
|
12
12
|
pox5ContractId: () => pox5ContractId,
|
|
13
13
|
pox5: () => pox5,
|
|
14
|
+
parsePox5Error: () => parsePox5Error,
|
|
14
15
|
isPox5Active: () => isPox5Active,
|
|
15
16
|
isInPreparePhase: () => isInPreparePhase,
|
|
17
|
+
getPoxInfo: () => getPoxInfo,
|
|
16
18
|
getPox5Activation: () => getPox5Activation,
|
|
19
|
+
describePox5Error: () => describePox5Error,
|
|
17
20
|
computeSignerGrantHash: () => computeSignerGrantHash,
|
|
18
21
|
burnHeightToRewardCycle: () => burnHeightToRewardCycle,
|
|
19
22
|
burnHeightToDistributionIndex: () => burnHeightToDistributionIndex,
|
|
@@ -26,8 +29,10 @@ __export(exports_pox5, {
|
|
|
26
29
|
bondPeriodToRewardCycle: () => bondPeriodToRewardCycle,
|
|
27
30
|
bondPeriodToBurnHeight: () => bondPeriodToBurnHeight,
|
|
28
31
|
assertPox5Active: () => assertPox5Active,
|
|
32
|
+
Pox5ErrorCode: () => Pox5ErrorCode,
|
|
29
33
|
POX5_SIGNER_DOMAIN: () => POX5_SIGNER_DOMAIN,
|
|
30
34
|
POX5_EVENT_TOPICS: () => POX5_EVENT_TOPICS,
|
|
35
|
+
POX5_ERROR_NAMES: () => POX5_ERROR_NAMES,
|
|
31
36
|
POX5_CONTRACT_NAME: () => POX5_CONTRACT_NAME,
|
|
32
37
|
POX5_CONTRACT_ID_MAINNET: () => POX5_CONTRACT_ID_MAINNET,
|
|
33
38
|
POX5_ACTIVATION_BURN_HEIGHT_MAINNET: () => POX5_ACTIVATION_BURN_HEIGHT_MAINNET,
|
|
@@ -76,6 +81,23 @@ var C_SCRIPT_NUM_MAX = 549755813888n;
|
|
|
76
81
|
var BITCOIN_LOCKTIME_THRESHOLD = 500000000n;
|
|
77
82
|
|
|
78
83
|
// src/pox5/activation.ts
|
|
84
|
+
async function getPoxInfo(client) {
|
|
85
|
+
const info = await client.request("/v2/pox", {
|
|
86
|
+
method: "GET"
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
contractId: info.contract_id,
|
|
90
|
+
currentBurnchainBlockHeight: info.current_burnchain_block_height,
|
|
91
|
+
firstBurnchainBlockHeight: info.first_burnchain_block_height,
|
|
92
|
+
sbtcContract: info.pox_5_sbtc_contract,
|
|
93
|
+
sbtcRegistryContract: info.pox_5_sbtc_registry_contract,
|
|
94
|
+
contractVersions: (info.contract_versions ?? []).map((v) => ({
|
|
95
|
+
contractId: v.contract_id,
|
|
96
|
+
activationBurnchainBlockHeight: v.activation_burnchain_block_height,
|
|
97
|
+
firstRewardCycleId: v.first_reward_cycle_id
|
|
98
|
+
}))
|
|
99
|
+
};
|
|
100
|
+
}
|
|
79
101
|
async function getPox5Activation(client) {
|
|
80
102
|
const info = await client.request("/v2/pox", {
|
|
81
103
|
method: "GET"
|
|
@@ -103,6 +125,169 @@ async function assertPox5Active(client) {
|
|
|
103
125
|
throw new Error("pox-5 is not active on this chain yet (Epoch 4.0 activates at Bitcoin block 960,230 on mainnet, ~2026-07-29). " + "Check getPox5Activation(client) for this network's activation height.");
|
|
104
126
|
}
|
|
105
127
|
}
|
|
128
|
+
// src/pox5/errors.ts
|
|
129
|
+
var Pox5ErrorCode = {
|
|
130
|
+
Unauthorized: 1,
|
|
131
|
+
CannotSetupBondTooSoon: 2,
|
|
132
|
+
CannotSetupBondTooLate: 3,
|
|
133
|
+
BondAlreadySetup: 4,
|
|
134
|
+
StakerAlreadyAdded: 5,
|
|
135
|
+
BondNotFound: 7,
|
|
136
|
+
InsufficientStx: 8,
|
|
137
|
+
AlreadyRegistered: 9,
|
|
138
|
+
TooMuchSats: 10,
|
|
139
|
+
NotAllowlisted: 11,
|
|
140
|
+
SignerKeyGrantUsed: 12,
|
|
141
|
+
InvalidSignatureRecover: 13,
|
|
142
|
+
InvalidSignaturePubkey: 14,
|
|
143
|
+
SignerKeyGrantNotFound: 17,
|
|
144
|
+
AlreadyStaked: 19,
|
|
145
|
+
InvalidNumCycles: 20,
|
|
146
|
+
SignerNotFound: 23,
|
|
147
|
+
InvalidStartBurnHeight: 24,
|
|
148
|
+
UnauthorizedSignerRegistration: 26,
|
|
149
|
+
NotStaking: 27,
|
|
150
|
+
UnstakeInPreparePhase: 28,
|
|
151
|
+
InvalidBondPeriodOrdering: 29,
|
|
152
|
+
DistributionAlreadyComputed: 30,
|
|
153
|
+
BondNotActive: 31,
|
|
154
|
+
NoClaimableRewards: 32,
|
|
155
|
+
ActiveBondNotIncluded: 33,
|
|
156
|
+
NotBondParticipant: 34,
|
|
157
|
+
CannotAnnounceL1EarlyUnlock: 35,
|
|
158
|
+
InvalidOldSignerManager: 36,
|
|
159
|
+
InvalidUnstakeSbtcAmount: 37,
|
|
160
|
+
CannotUnstakeSbtc: 38,
|
|
161
|
+
ReadTxOutOfBounds: 39,
|
|
162
|
+
InvalidBtcHeader: 40,
|
|
163
|
+
InvalidMerkleProof: 41,
|
|
164
|
+
InvalidLockupScript: 42,
|
|
165
|
+
BondAlreadyStarted: 43,
|
|
166
|
+
UpdateBondSameSigner: 44,
|
|
167
|
+
InvalidLockupAmount: 45,
|
|
168
|
+
DuplicateLockupOutpoint: 46,
|
|
169
|
+
StakeInPreparePhase: 47,
|
|
170
|
+
RolloverTooEarly: 48,
|
|
171
|
+
ReentrantCall: 49,
|
|
172
|
+
L1EarlyExitAlreadyAnnounced: 50,
|
|
173
|
+
InsufficientReserveBalance: 51,
|
|
174
|
+
InvalidUnlockHeight: 52,
|
|
175
|
+
RewardsPaused: 53
|
|
176
|
+
};
|
|
177
|
+
var POX5_ERROR_NAMES = {
|
|
178
|
+
[Pox5ErrorCode.Unauthorized]: "ERR_UNAUTHORIZED",
|
|
179
|
+
[Pox5ErrorCode.CannotSetupBondTooSoon]: "ERR_CANNOT_SETUP_BOND_TOO_SOON",
|
|
180
|
+
[Pox5ErrorCode.CannotSetupBondTooLate]: "ERR_CANNOT_SETUP_BOND_TOO_LATE",
|
|
181
|
+
[Pox5ErrorCode.BondAlreadySetup]: "ERR_BOND_ALREADY_SETUP",
|
|
182
|
+
[Pox5ErrorCode.StakerAlreadyAdded]: "ERR_STAKER_ALREADY_ADDED",
|
|
183
|
+
[Pox5ErrorCode.BondNotFound]: "ERR_BOND_NOT_FOUND",
|
|
184
|
+
[Pox5ErrorCode.InsufficientStx]: "ERR_INSUFFICIENT_STX",
|
|
185
|
+
[Pox5ErrorCode.AlreadyRegistered]: "ERR_ALREADY_REGISTERED",
|
|
186
|
+
[Pox5ErrorCode.TooMuchSats]: "ERR_TOO_MUCH_SATS",
|
|
187
|
+
[Pox5ErrorCode.NotAllowlisted]: "ERR_NOT_ALLOWLISTED",
|
|
188
|
+
[Pox5ErrorCode.SignerKeyGrantUsed]: "ERR_SIGNER_KEY_GRANT_USED",
|
|
189
|
+
[Pox5ErrorCode.InvalidSignatureRecover]: "ERR_INVALID_SIGNATURE_RECOVER",
|
|
190
|
+
[Pox5ErrorCode.InvalidSignaturePubkey]: "ERR_INVALID_SIGNATURE_PUBKEY",
|
|
191
|
+
[Pox5ErrorCode.SignerKeyGrantNotFound]: "ERR_SIGNER_KEY_GRANT_NOT_FOUND",
|
|
192
|
+
[Pox5ErrorCode.AlreadyStaked]: "ERR_ALREADY_STAKED",
|
|
193
|
+
[Pox5ErrorCode.InvalidNumCycles]: "ERR_INVALID_NUM_CYCLES",
|
|
194
|
+
[Pox5ErrorCode.SignerNotFound]: "ERR_SIGNER_NOT_FOUND",
|
|
195
|
+
[Pox5ErrorCode.InvalidStartBurnHeight]: "ERR_INVALID_START_BURN_HEIGHT",
|
|
196
|
+
[Pox5ErrorCode.UnauthorizedSignerRegistration]: "ERR_UNAUTHORIZED_SIGNER_REGISTRATION",
|
|
197
|
+
[Pox5ErrorCode.NotStaking]: "ERR_NOT_STAKING",
|
|
198
|
+
[Pox5ErrorCode.UnstakeInPreparePhase]: "ERR_UNSTAKE_IN_PREPARE_PHASE",
|
|
199
|
+
[Pox5ErrorCode.InvalidBondPeriodOrdering]: "ERR_INVALID_BOND_PERIOD_ORDERING",
|
|
200
|
+
[Pox5ErrorCode.DistributionAlreadyComputed]: "ERR_DISTRIBUTION_ALREADY_COMPUTED",
|
|
201
|
+
[Pox5ErrorCode.BondNotActive]: "ERR_BOND_NOT_ACTIVE",
|
|
202
|
+
[Pox5ErrorCode.NoClaimableRewards]: "ERR_NO_CLAIMABLE_REWARDS",
|
|
203
|
+
[Pox5ErrorCode.ActiveBondNotIncluded]: "ERR_ACTIVE_BOND_NOT_INCLUDED",
|
|
204
|
+
[Pox5ErrorCode.NotBondParticipant]: "ERR_NOT_BOND_PARTICIPANT",
|
|
205
|
+
[Pox5ErrorCode.CannotAnnounceL1EarlyUnlock]: "ERR_CANNOT_ANNOUNCE_L1_EARLY_UNLOCK",
|
|
206
|
+
[Pox5ErrorCode.InvalidOldSignerManager]: "ERR_INVALID_OLD_SIGNER_MANAGER",
|
|
207
|
+
[Pox5ErrorCode.InvalidUnstakeSbtcAmount]: "ERR_INVALID_UNSTAKE_SBTC_AMOUNT",
|
|
208
|
+
[Pox5ErrorCode.CannotUnstakeSbtc]: "ERR_CANNOT_UNSTAKE_SBTC",
|
|
209
|
+
[Pox5ErrorCode.ReadTxOutOfBounds]: "ERR_READ_TX_OUT_OF_BOUNDS",
|
|
210
|
+
[Pox5ErrorCode.InvalidBtcHeader]: "ERR_INVALID_BTC_HEADER",
|
|
211
|
+
[Pox5ErrorCode.InvalidMerkleProof]: "ERR_INVALID_MERKLE_PROOF",
|
|
212
|
+
[Pox5ErrorCode.InvalidLockupScript]: "ERR_INVALID_LOCKUP_SCRIPT",
|
|
213
|
+
[Pox5ErrorCode.BondAlreadyStarted]: "ERR_BOND_ALREADY_STARTED",
|
|
214
|
+
[Pox5ErrorCode.UpdateBondSameSigner]: "ERR_UPDATE_BOND_SAME_SIGNER",
|
|
215
|
+
[Pox5ErrorCode.InvalidLockupAmount]: "ERR_INVALID_LOCKUP_AMOUNT",
|
|
216
|
+
[Pox5ErrorCode.DuplicateLockupOutpoint]: "ERR_DUPLICATE_LOCKUP_OUTPOINT",
|
|
217
|
+
[Pox5ErrorCode.StakeInPreparePhase]: "ERR_STAKE_IN_PREPARE_PHASE",
|
|
218
|
+
[Pox5ErrorCode.RolloverTooEarly]: "ERR_ROLLOVER_TOO_EARLY",
|
|
219
|
+
[Pox5ErrorCode.ReentrantCall]: "ERR_REENTRANT_CALL",
|
|
220
|
+
[Pox5ErrorCode.L1EarlyExitAlreadyAnnounced]: "ERR_L1_EARLY_EXIT_ALREADY_ANNOUNCED",
|
|
221
|
+
[Pox5ErrorCode.InsufficientReserveBalance]: "ERR_INSUFFICIENT_RESERVE_BALANCE",
|
|
222
|
+
[Pox5ErrorCode.InvalidUnlockHeight]: "ERR_INVALID_UNLOCK_HEIGHT",
|
|
223
|
+
[Pox5ErrorCode.RewardsPaused]: "ERR_REWARDS_PAUSED"
|
|
224
|
+
};
|
|
225
|
+
var POX5_ERROR_DESCRIPTIONS = {
|
|
226
|
+
[Pox5ErrorCode.Unauthorized]: "Caller is not authorized.",
|
|
227
|
+
[Pox5ErrorCode.CannotSetupBondTooSoon]: "Bond setup window has not opened.",
|
|
228
|
+
[Pox5ErrorCode.CannotSetupBondTooLate]: "Bond setup window has closed.",
|
|
229
|
+
[Pox5ErrorCode.BondAlreadySetup]: "This bond period is already set up.",
|
|
230
|
+
[Pox5ErrorCode.StakerAlreadyAdded]: "Staker is already on this bond.",
|
|
231
|
+
[Pox5ErrorCode.BondNotFound]: "No bond at this index.",
|
|
232
|
+
[Pox5ErrorCode.InsufficientStx]: "Not enough STX for this operation.",
|
|
233
|
+
[Pox5ErrorCode.AlreadyRegistered]: "Staker already has an overlapping position.",
|
|
234
|
+
[Pox5ErrorCode.TooMuchSats]: "Sats amount exceeds the allowlist maximum.",
|
|
235
|
+
[Pox5ErrorCode.NotAllowlisted]: "Principal is not on the bond allowlist.",
|
|
236
|
+
[Pox5ErrorCode.SignerKeyGrantUsed]: "This signer-key grant was already consumed.",
|
|
237
|
+
[Pox5ErrorCode.InvalidSignatureRecover]: "Could not recover a public key from the signature.",
|
|
238
|
+
[Pox5ErrorCode.InvalidSignaturePubkey]: "Recovered public key does not match the signer key.",
|
|
239
|
+
[Pox5ErrorCode.SignerKeyGrantNotFound]: "No grant found for this signer key.",
|
|
240
|
+
[Pox5ErrorCode.AlreadyStaked]: "Principal already has an overlapping stake.",
|
|
241
|
+
[Pox5ErrorCode.InvalidNumCycles]: "Cycle count is outside the allowed range.",
|
|
242
|
+
[Pox5ErrorCode.SignerNotFound]: "No signer found for this principal.",
|
|
243
|
+
[Pox5ErrorCode.InvalidStartBurnHeight]: "Start burn height must fall in the current reward cycle.",
|
|
244
|
+
[Pox5ErrorCode.UnauthorizedSignerRegistration]: "Caller is not authorized to register this signer.",
|
|
245
|
+
[Pox5ErrorCode.NotStaking]: "Principal is not currently staking.",
|
|
246
|
+
[Pox5ErrorCode.UnstakeInPreparePhase]: "Unstaking is not allowed in the prepare phase.",
|
|
247
|
+
[Pox5ErrorCode.InvalidBondPeriodOrdering]: "Bond periods were supplied out of order.",
|
|
248
|
+
[Pox5ErrorCode.DistributionAlreadyComputed]: "Reward distribution already computed for this period.",
|
|
249
|
+
[Pox5ErrorCode.BondNotActive]: "Bond is not currently active.",
|
|
250
|
+
[Pox5ErrorCode.NoClaimableRewards]: "No claimable rewards for this caller.",
|
|
251
|
+
[Pox5ErrorCode.ActiveBondNotIncluded]: "The currently active bond was not included in the list.",
|
|
252
|
+
[Pox5ErrorCode.NotBondParticipant]: "Caller is not in a bond.",
|
|
253
|
+
[Pox5ErrorCode.CannotAnnounceL1EarlyUnlock]: "Early-exit announce is not valid for this membership.",
|
|
254
|
+
[Pox5ErrorCode.InvalidOldSignerManager]: "old-signer-manager does not match the staker's current signer.",
|
|
255
|
+
[Pox5ErrorCode.InvalidUnstakeSbtcAmount]: "sBTC unstake amount is invalid.",
|
|
256
|
+
[Pox5ErrorCode.CannotUnstakeSbtc]: "Bond participant did not stake sBTC.",
|
|
257
|
+
[Pox5ErrorCode.ReadTxOutOfBounds]: "Lockup proof buffer was truncated.",
|
|
258
|
+
[Pox5ErrorCode.InvalidBtcHeader]: "Bitcoin header in the lockup proof is invalid.",
|
|
259
|
+
[Pox5ErrorCode.InvalidMerkleProof]: "Merkle proof in the lockup proof is invalid.",
|
|
260
|
+
[Pox5ErrorCode.InvalidLockupScript]: "Lockup output script does not match.",
|
|
261
|
+
[Pox5ErrorCode.BondAlreadyStarted]: "Cannot register after the bond has started.",
|
|
262
|
+
[Pox5ErrorCode.UpdateBondSameSigner]: "update-bond-registration cannot keep the same signer.",
|
|
263
|
+
[Pox5ErrorCode.InvalidLockupAmount]: "Lockup output amount does not match sats.",
|
|
264
|
+
[Pox5ErrorCode.DuplicateLockupOutpoint]: "The same Bitcoin outpoint appeared twice in the lockup list.",
|
|
265
|
+
[Pox5ErrorCode.StakeInPreparePhase]: "Cannot modify next-cycle stake during the prepare phase.",
|
|
266
|
+
[Pox5ErrorCode.RolloverTooEarly]: "Bond rollover is too early.",
|
|
267
|
+
[Pox5ErrorCode.ReentrantCall]: "Reentrant call into pox-5 while a trait call is in flight.",
|
|
268
|
+
[Pox5ErrorCode.L1EarlyExitAlreadyAnnounced]: "L1 early exit already announced for this bond period.",
|
|
269
|
+
[Pox5ErrorCode.InsufficientReserveBalance]: "Reserve withdrawal exceeds the balance.",
|
|
270
|
+
[Pox5ErrorCode.InvalidUnlockHeight]: "Unlock height is below the bond minimum or at/above 500,000,000.",
|
|
271
|
+
[Pox5ErrorCode.RewardsPaused]: "Signer reward claims are paused."
|
|
272
|
+
};
|
|
273
|
+
function parsePox5Error(result) {
|
|
274
|
+
if (result == null)
|
|
275
|
+
return;
|
|
276
|
+
if (typeof result === "string") {
|
|
277
|
+
const match = result.trim().match(/^\(err u(\d+)\)$/);
|
|
278
|
+
return match ? Number(match[1]) : undefined;
|
|
279
|
+
}
|
|
280
|
+
if (result.type !== "err")
|
|
281
|
+
return;
|
|
282
|
+
return result.value.type === "uint" ? Number(result.value.value) : undefined;
|
|
283
|
+
}
|
|
284
|
+
function describePox5Error(code) {
|
|
285
|
+
const n = Number(code);
|
|
286
|
+
const name = POX5_ERROR_NAMES[n];
|
|
287
|
+
if (!name)
|
|
288
|
+
return;
|
|
289
|
+
return { code: n, name, description: POX5_ERROR_DESCRIPTIONS[n] };
|
|
290
|
+
}
|
|
106
291
|
// src/pox5/cycles.ts
|
|
107
292
|
function burnHeightToRewardCycle(burnHeight, params) {
|
|
108
293
|
if (burnHeight < params.firstBurnchainBlockHeight) {
|
|
@@ -218,20 +403,19 @@ function buildDefaultStakerUnlockBytes(publicKey) {
|
|
|
218
403
|
}
|
|
219
404
|
// src/pox5/grants.ts
|
|
220
405
|
var import_secp256k1 = require("@noble/curves/secp256k1.js");
|
|
221
|
-
var import_sha22 = require("@noble/hashes/sha2.js");
|
|
222
|
-
var SIP018_PREFIX = hexToBytes("534950303138");
|
|
223
406
|
function computeSignerGrantHash(opts) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
407
|
+
return structuredDataHash({
|
|
408
|
+
domain: Cl.tuple({
|
|
409
|
+
name: Cl.stringAscii(POX5_SIGNER_DOMAIN.name),
|
|
410
|
+
version: Cl.stringAscii(POX5_SIGNER_DOMAIN.version),
|
|
411
|
+
"chain-id": Cl.uint(opts.chainId)
|
|
412
|
+
}),
|
|
413
|
+
message: Cl.tuple({
|
|
414
|
+
topic: Cl.stringAscii("grant-authorization"),
|
|
415
|
+
"signer-manager": Cl.principal(opts.signerManager),
|
|
416
|
+
"auth-id": Cl.uint(opts.authId)
|
|
417
|
+
})
|
|
418
|
+
});
|
|
235
419
|
}
|
|
236
420
|
async function signSignerGrant(account, opts) {
|
|
237
421
|
const vrs = await account.sign(computeSignerGrantHash(opts));
|
|
@@ -838,9 +1022,23 @@ function toBytes2(input) {
|
|
|
838
1022
|
function optionalBytes(input) {
|
|
839
1023
|
return input === undefined ? null : toBytes2(input);
|
|
840
1024
|
}
|
|
1025
|
+
var MAX_LOCKUP_OUTPUTS = 10;
|
|
1026
|
+
var MAX_LEAF_HASHES = 14;
|
|
841
1027
|
function btcLockupArg(lockup) {
|
|
842
1028
|
if ("sbtcSats" in lockup)
|
|
843
1029
|
return { err: intToBigInt(lockup.sbtcSats) };
|
|
1030
|
+
if (lockup.l1Outputs.length === 0) {
|
|
1031
|
+
throw new Error("registerForBond: l1Outputs is empty — nothing would be locked");
|
|
1032
|
+
}
|
|
1033
|
+
if (lockup.l1Outputs.length > MAX_LOCKUP_OUTPUTS) {
|
|
1034
|
+
throw new Error(`registerForBond: ${lockup.l1Outputs.length} lockup outputs; pox-5 accepts at most ${MAX_LOCKUP_OUTPUTS}`);
|
|
1035
|
+
}
|
|
1036
|
+
for (let i = 0;i < lockup.l1Outputs.length; i++) {
|
|
1037
|
+
const n = lockup.l1Outputs[i]?.leafHashes.length ?? 0;
|
|
1038
|
+
if (n > MAX_LEAF_HASHES) {
|
|
1039
|
+
throw new Error(`registerForBond: output ${i} has ${n} merkle siblings; pox-5 accepts at most ${MAX_LEAF_HASHES}`);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
844
1042
|
return {
|
|
845
1043
|
ok: {
|
|
846
1044
|
outputs: lockup.l1Outputs.map((o) => ({
|
|
@@ -1077,6 +1275,7 @@ function pox5() {
|
|
|
1077
1275
|
pox5: {
|
|
1078
1276
|
isActive: () => isPox5Active(client),
|
|
1079
1277
|
getActivation: () => getPox5Activation(client),
|
|
1278
|
+
getPoxInfo: () => getPoxInfo(client),
|
|
1080
1279
|
contractId: () => pox5ContractId(client),
|
|
1081
1280
|
getStakerState: (staker) => getStakerState(client, staker),
|
|
1082
1281
|
getStakerInfo: (staker) => getStakerInfo(client, staker),
|
|
@@ -1108,5 +1307,5 @@ function pox5() {
|
|
|
1108
1307
|
});
|
|
1109
1308
|
}
|
|
1110
1309
|
|
|
1111
|
-
//# debugId=
|
|
1310
|
+
//# debugId=C8CF6DB65C5A821964756E2164756E21
|
|
1112
1311
|
//# sourceMappingURL=index.cjs.map
|