@secondlayer/stacks 2.16.0 → 2.17.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.
@@ -4,18 +4,18 @@ import {
4
4
  import {
5
5
  bech32
6
6
  } from "../../shared/stacks-5nmz5ad9.js";
7
+ import {
8
+ getContract
9
+ } from "../../shared/stacks-rb9shyk8.js";
7
10
  import {
8
11
  multicall
9
12
  } from "../../shared/stacks-f0hfqaj5.js";
10
- import {
11
- callContract
12
- } from "../../shared/stacks-58e4vbaw.js";
13
- import {
14
- readContract
15
- } from "../../shared/stacks-msmgyerb.js";
13
+ import"../../shared/stacks-bq0weg6n.js";
14
+ import"../../shared/stacks-msmgyerb.js";
16
15
  import"../../shared/stacks-mbnfwekf.js";
17
16
  import"../../shared/stacks-fh48neva.js";
18
17
  import"../../shared/stacks-709tra19.js";
18
+ import"../../shared/stacks-18jv9aen.js";
19
19
  import"../../shared/stacks-sd9sc71n.js";
20
20
  import {
21
21
  Cl,
@@ -25,7 +25,8 @@ import"../../shared/stacks-azp00pve.js";
25
25
  import {
26
26
  bytesToHex,
27
27
  concatBytes,
28
- hexToBytes
28
+ hexToBytes,
29
+ intToBigInt
29
30
  } from "../../shared/stacks-qs5fzts5.js";
30
31
  import"../../shared/stacks-cfazrteq.js";
31
32
 
@@ -219,6 +220,539 @@ function verifySignerGrant(opts) {
219
220
  return false;
220
221
  }
221
222
  }
223
+ // src/pox5/abi.ts
224
+ var optionalSignerCalldata = {
225
+ optional: { buff: { length: 500 } }
226
+ };
227
+ var earnedRewardsTuple = {
228
+ tuple: [
229
+ { name: "earned", type: "uint128" },
230
+ { name: "rewards-per-token", type: "uint128" }
231
+ ]
232
+ };
233
+ var l1LockupOutputTuple = {
234
+ tuple: [
235
+ { name: "amount", type: "uint128" },
236
+ { name: "header", type: { buff: { length: 80 } } },
237
+ { name: "height", type: "uint128" },
238
+ {
239
+ name: "leaf-hashes",
240
+ type: { list: { type: { buff: { length: 32 } }, length: 14 } }
241
+ },
242
+ { name: "output-index", type: "uint128" },
243
+ { name: "tx", type: { buff: { length: 1e5 } } },
244
+ { name: "tx-count", type: "uint128" },
245
+ { name: "tx-index", type: "uint128" },
246
+ { name: "unlock-burn-height", type: "uint128" }
247
+ ]
248
+ };
249
+ var POX5_ABI = {
250
+ functions: [
251
+ {
252
+ name: "current-pox-reward-cycle",
253
+ access: "read-only",
254
+ args: [],
255
+ outputs: "uint128"
256
+ },
257
+ {
258
+ name: "get-bond-allowance",
259
+ access: "read-only",
260
+ args: [
261
+ { name: "bond-index", type: "uint128" },
262
+ { name: "staker", type: "principal" }
263
+ ],
264
+ outputs: { optional: "uint128" }
265
+ },
266
+ {
267
+ name: "get-bond-l1-unlock-height",
268
+ access: "read-only",
269
+ args: [{ name: "bond-index", type: "uint128" }],
270
+ outputs: "uint128"
271
+ },
272
+ {
273
+ name: "get-bond-membership",
274
+ access: "read-only",
275
+ args: [{ name: "staker", type: "principal" }],
276
+ outputs: {
277
+ optional: {
278
+ tuple: [
279
+ { name: "amount-sats", type: "uint128" },
280
+ { name: "amount-ustx", type: "uint128" },
281
+ { name: "bond-index", type: "uint128" },
282
+ { name: "is-l1-lock", type: "bool" },
283
+ { name: "signer", type: "principal" }
284
+ ]
285
+ }
286
+ }
287
+ },
288
+ {
289
+ name: "get-first-pox-5-reward-cycle",
290
+ access: "read-only",
291
+ args: [],
292
+ outputs: "uint128"
293
+ },
294
+ {
295
+ name: "get-protocol-bond",
296
+ access: "read-only",
297
+ args: [{ name: "bond-index", type: "uint128" }],
298
+ outputs: {
299
+ optional: {
300
+ tuple: [
301
+ { name: "early-unlock-bytes", type: { buff: { length: 683 } } },
302
+ { name: "min-ustx-ratio", type: "uint128" },
303
+ { name: "stx-value-ratio", type: "uint128" },
304
+ { name: "target-rate", type: "uint128" }
305
+ ]
306
+ }
307
+ }
308
+ },
309
+ {
310
+ name: "get-signer-info",
311
+ access: "read-only",
312
+ args: [{ name: "signer", type: "principal" }],
313
+ outputs: { optional: { buff: { length: 33 } } }
314
+ },
315
+ {
316
+ name: "get-staker-custodied-sbtc",
317
+ access: "read-only",
318
+ args: [{ name: "staker", type: "principal" }],
319
+ outputs: "uint128"
320
+ },
321
+ {
322
+ name: "get-staker-info",
323
+ access: "read-only",
324
+ args: [{ name: "staker", type: "principal" }],
325
+ outputs: {
326
+ optional: {
327
+ tuple: [
328
+ { name: "amount-ustx", type: "uint128" },
329
+ { name: "first-reward-cycle", type: "uint128" },
330
+ { name: "num-cycles", type: "uint128" },
331
+ { name: "signer", type: "principal" }
332
+ ]
333
+ }
334
+ }
335
+ },
336
+ {
337
+ name: "get-total-sbtc-staked-for-bond",
338
+ access: "read-only",
339
+ args: [{ name: "bond-index", type: "uint128" }],
340
+ outputs: "uint128"
341
+ },
342
+ {
343
+ name: "has-announced-l1-early-exit",
344
+ access: "read-only",
345
+ args: [
346
+ { name: "bond-index", type: "uint128" },
347
+ { name: "staker", type: "principal" }
348
+ ],
349
+ outputs: "bool"
350
+ },
351
+ {
352
+ name: "verify-signer-key-grant",
353
+ access: "read-only",
354
+ args: [
355
+ { name: "signer-manager", type: "principal" },
356
+ { name: "signer-key", type: { buff: { length: 33 } } }
357
+ ],
358
+ outputs: { response: { ok: "bool", error: "uint128" } }
359
+ },
360
+ {
361
+ name: "announce-l1-early-exit",
362
+ access: "public",
363
+ args: [
364
+ { name: "staker", type: "principal" },
365
+ { name: "old-signer-manager", type: "trait_reference" }
366
+ ],
367
+ outputs: {
368
+ response: {
369
+ ok: {
370
+ tuple: [
371
+ { name: "amount-sats-released", type: "uint128" },
372
+ { name: "bond-index", type: "uint128" },
373
+ { name: "signer", type: "principal" },
374
+ { name: "staker", type: "principal" }
375
+ ]
376
+ },
377
+ error: "uint128"
378
+ }
379
+ }
380
+ },
381
+ {
382
+ name: "calculate-rewards",
383
+ access: "public",
384
+ args: [
385
+ {
386
+ name: "bond-periods",
387
+ type: { list: { type: "uint128", length: 6 } }
388
+ }
389
+ ],
390
+ outputs: {
391
+ response: {
392
+ ok: {
393
+ tuple: [
394
+ { name: "accrued-rewards-per-ustx", type: "uint128" },
395
+ {
396
+ name: "bond-periods",
397
+ type: { list: { type: "uint128", length: 6 } }
398
+ },
399
+ { name: "calculation-height", type: "uint128" },
400
+ { name: "cumulative-rewards-per-ustx", type: "uint128" },
401
+ { name: "cycle-staked-ustx", type: "uint128" },
402
+ { name: "gross-accrued-rewards", type: "uint128" },
403
+ { name: "reserve-balance", type: "uint128" },
404
+ { name: "reserve-deposit", type: "uint128" },
405
+ { name: "stx-cycle", type: "uint128" },
406
+ { name: "total-bond-rewards", type: "uint128" },
407
+ { name: "total-stx-staker-rewards", type: "uint128" }
408
+ ]
409
+ },
410
+ error: "uint128"
411
+ }
412
+ }
413
+ },
414
+ {
415
+ name: "claim-rewards",
416
+ access: "public",
417
+ args: [
418
+ {
419
+ name: "bond-periods",
420
+ type: { list: { type: "uint128", length: 6 } }
421
+ },
422
+ { name: "reward-cycle", type: "uint128" }
423
+ ],
424
+ outputs: {
425
+ response: {
426
+ ok: {
427
+ tuple: [
428
+ {
429
+ name: "bond-rewards",
430
+ type: {
431
+ list: {
432
+ type: {
433
+ tuple: [
434
+ { name: "bond-index", type: "uint128" },
435
+ { name: "earned", type: "uint128" },
436
+ { name: "rewards-per-token", type: "uint128" }
437
+ ]
438
+ },
439
+ length: 6
440
+ }
441
+ }
442
+ },
443
+ { name: "bond-totals", type: "uint128" },
444
+ { name: "stx-rewards", type: earnedRewardsTuple },
445
+ { name: "total-rewards", type: "uint128" }
446
+ ]
447
+ },
448
+ error: "uint128"
449
+ }
450
+ }
451
+ },
452
+ {
453
+ name: "claim-staker-rewards-for-signer",
454
+ access: "public",
455
+ args: [
456
+ { name: "staker", type: "principal" },
457
+ { name: "reward-cycle", type: "uint128" },
458
+ { name: "bond-index", type: { optional: "uint128" } }
459
+ ],
460
+ outputs: {
461
+ response: { ok: earnedRewardsTuple, error: "uint128" }
462
+ }
463
+ },
464
+ {
465
+ name: "grant-signer-key",
466
+ access: "public",
467
+ args: [
468
+ { name: "signer-key", type: { buff: { length: 33 } } },
469
+ { name: "signer-manager", type: "principal" },
470
+ { name: "auth-id", type: "uint128" },
471
+ { name: "signer-sig", type: { buff: { length: 65 } } }
472
+ ],
473
+ outputs: {
474
+ response: {
475
+ ok: {
476
+ tuple: [
477
+ { name: "auth-id", type: "uint128" },
478
+ { name: "signer-key", type: { buff: { length: 33 } } },
479
+ { name: "signer-manager", type: "principal" }
480
+ ]
481
+ },
482
+ error: "uint128"
483
+ }
484
+ }
485
+ },
486
+ {
487
+ name: "register-for-bond",
488
+ access: "public",
489
+ args: [
490
+ { name: "bond-index", type: "uint128" },
491
+ { name: "signer-manager", type: "trait_reference" },
492
+ { name: "amount-ustx", type: "uint128" },
493
+ {
494
+ name: "btc-lockup",
495
+ type: {
496
+ response: {
497
+ ok: {
498
+ tuple: [
499
+ {
500
+ name: "outputs",
501
+ type: { list: { type: l1LockupOutputTuple, length: 10 } }
502
+ },
503
+ {
504
+ name: "staker-unlock-bytes",
505
+ type: { buff: { length: 683 } }
506
+ }
507
+ ]
508
+ },
509
+ error: "uint128"
510
+ }
511
+ }
512
+ },
513
+ { name: "signer-calldata", type: optionalSignerCalldata }
514
+ ],
515
+ outputs: {
516
+ response: {
517
+ ok: {
518
+ tuple: [
519
+ { name: "amount-ustx", type: "uint128" },
520
+ { name: "bond-index", type: "uint128" },
521
+ {
522
+ name: "btc-lockup",
523
+ type: {
524
+ tuple: [
525
+ {
526
+ name: "txs",
527
+ type: {
528
+ optional: {
529
+ list: {
530
+ type: {
531
+ tuple: [
532
+ { name: "output-index", type: "uint128" },
533
+ {
534
+ name: "txid",
535
+ type: { buff: { length: 32 } }
536
+ }
537
+ ]
538
+ },
539
+ length: 10
540
+ }
541
+ }
542
+ }
543
+ },
544
+ {
545
+ name: "type",
546
+ type: { "string-ascii": { length: 2 } }
547
+ }
548
+ ]
549
+ }
550
+ },
551
+ { name: "first-reward-cycle", type: "uint128" },
552
+ { name: "is-l1-lock", type: "bool" },
553
+ { name: "sats-total", type: "uint128" },
554
+ { name: "signer", type: "principal" },
555
+ { name: "staker", type: "principal" },
556
+ { name: "unlock-burn-height", type: "uint128" },
557
+ { name: "unlock-cycle", type: "uint128" }
558
+ ]
559
+ },
560
+ error: "uint128"
561
+ }
562
+ }
563
+ },
564
+ {
565
+ name: "revoke-signer-grant",
566
+ access: "public",
567
+ args: [
568
+ { name: "signer-manager", type: "principal" },
569
+ { name: "signer-key", type: { buff: { length: 33 } } }
570
+ ],
571
+ outputs: {
572
+ response: {
573
+ ok: {
574
+ tuple: [
575
+ { name: "existed", type: "bool" },
576
+ { name: "signer-key", type: { buff: { length: 33 } } },
577
+ { name: "signer-manager", type: "principal" }
578
+ ]
579
+ },
580
+ error: "uint128"
581
+ }
582
+ }
583
+ },
584
+ {
585
+ name: "setup-bond",
586
+ access: "public",
587
+ args: [
588
+ { name: "bond-index", type: "uint128" },
589
+ { name: "target-rate", type: "uint128" },
590
+ { name: "stx-value-ratio", type: "uint128" },
591
+ { name: "min-ustx-ratio", type: "uint128" },
592
+ { name: "early-unlock-bytes", type: { buff: { length: 683 } } },
593
+ {
594
+ name: "allowlist",
595
+ type: {
596
+ list: {
597
+ type: {
598
+ tuple: [
599
+ { name: "max-sats", type: "uint128" },
600
+ { name: "staker", type: "principal" }
601
+ ]
602
+ },
603
+ length: 1000
604
+ }
605
+ }
606
+ }
607
+ ],
608
+ outputs: {
609
+ response: {
610
+ ok: {
611
+ tuple: [
612
+ { name: "bond-index", type: "uint128" },
613
+ {
614
+ name: "early-unlock-bytes",
615
+ type: { buff: { length: 683 } }
616
+ },
617
+ { name: "max-allocation-sats", type: "uint128" },
618
+ { name: "min-ustx-ratio", type: "uint128" },
619
+ { name: "stx-value-ratio", type: "uint128" },
620
+ { name: "target-rate", type: "uint128" }
621
+ ]
622
+ },
623
+ error: "uint128"
624
+ }
625
+ }
626
+ },
627
+ {
628
+ name: "stake",
629
+ access: "public",
630
+ args: [
631
+ { name: "signer-manager", type: "trait_reference" },
632
+ { name: "amount-ustx", type: "uint128" },
633
+ { name: "num-cycles", type: "uint128" },
634
+ { name: "start-burn-ht", type: "uint128" },
635
+ { name: "signer-calldata", type: optionalSignerCalldata }
636
+ ],
637
+ outputs: {
638
+ response: {
639
+ ok: {
640
+ tuple: [
641
+ { name: "amount-ustx", type: "uint128" },
642
+ { name: "first-reward-cycle", type: "uint128" },
643
+ { name: "num-cycles", type: "uint128" },
644
+ { name: "signer", type: "principal" },
645
+ { name: "staker", type: "principal" },
646
+ { name: "unlock-burn-height", type: "uint128" },
647
+ { name: "unlock-cycle", type: "uint128" }
648
+ ]
649
+ },
650
+ error: "uint128"
651
+ }
652
+ }
653
+ },
654
+ {
655
+ name: "stake-update",
656
+ access: "public",
657
+ args: [
658
+ { name: "signer-manager", type: "trait_reference" },
659
+ { name: "old-signer-manager", type: "trait_reference" },
660
+ { name: "cycles-to-extend", type: "uint128" },
661
+ { name: "amount-increase", type: "uint128" },
662
+ { name: "signer-calldata", type: optionalSignerCalldata }
663
+ ],
664
+ outputs: {
665
+ response: {
666
+ ok: {
667
+ tuple: [
668
+ { name: "amount-increase", type: "uint128" },
669
+ { name: "amount-ustx", type: "uint128" },
670
+ { name: "cycles-to-extend", type: "uint128" },
671
+ { name: "num-cycles", type: "uint128" },
672
+ { name: "old-signer", type: "principal" },
673
+ { name: "prev-unlock-height", type: "uint128" },
674
+ { name: "signer", type: "principal" },
675
+ { name: "staker", type: "principal" },
676
+ { name: "unlock-burn-height", type: "uint128" },
677
+ { name: "unlock-cycle", type: "uint128" }
678
+ ]
679
+ },
680
+ error: "uint128"
681
+ }
682
+ }
683
+ },
684
+ {
685
+ name: "unstake",
686
+ access: "public",
687
+ args: [{ name: "old-signer-manager", type: "trait_reference" }],
688
+ outputs: {
689
+ response: {
690
+ ok: {
691
+ tuple: [
692
+ { name: "amount-ustx", type: "uint128" },
693
+ { name: "first-reward-cycle", type: "uint128" },
694
+ { name: "signer", type: "principal" },
695
+ { name: "staker", type: "principal" },
696
+ { name: "unlock-burn-height", type: "uint128" },
697
+ { name: "unlock-cycle", type: "uint128" }
698
+ ]
699
+ },
700
+ error: "uint128"
701
+ }
702
+ }
703
+ },
704
+ {
705
+ name: "unstake-sbtc",
706
+ access: "public",
707
+ args: [
708
+ { name: "signer-manager", type: "trait_reference" },
709
+ { name: "amount-to-withdrawal-sats", type: "uint128" }
710
+ ],
711
+ outputs: {
712
+ response: {
713
+ ok: {
714
+ tuple: [
715
+ { name: "amount-withdrawn-sats", type: "uint128" },
716
+ { name: "bond-index", type: "uint128" },
717
+ { name: "new-amount-sats", type: "uint128" },
718
+ { name: "signer", type: "principal" },
719
+ { name: "staker", type: "principal" }
720
+ ]
721
+ },
722
+ error: "uint128"
723
+ }
724
+ }
725
+ },
726
+ {
727
+ name: "update-bond-registration",
728
+ access: "public",
729
+ args: [
730
+ { name: "signer-manager", type: "trait_reference" },
731
+ { name: "old-signer-manager", type: "trait_reference" },
732
+ { name: "signer-calldata", type: optionalSignerCalldata }
733
+ ],
734
+ outputs: {
735
+ response: {
736
+ ok: {
737
+ tuple: [
738
+ { name: "amount-sats", type: "uint128" },
739
+ { name: "amount-ustx", type: "uint128" },
740
+ { name: "bond-index", type: "uint128" },
741
+ { name: "first-reward-cycle", type: "uint128" },
742
+ { name: "is-l1-lock", type: "bool" },
743
+ { name: "num-cycles", type: "uint128" },
744
+ { name: "old-signer", type: "principal" },
745
+ { name: "signer", type: "principal" },
746
+ { name: "staker", type: "principal" }
747
+ ]
748
+ },
749
+ error: "uint128"
750
+ }
751
+ }
752
+ }
753
+ ]
754
+ };
755
+
222
756
  // src/pox5/actions.ts
223
757
  function pox5ContractId(client) {
224
758
  const boot = client.chain?.bootAddress;
@@ -226,45 +760,35 @@ function pox5ContractId(client) {
226
760
  throw new Error("Client must have a chain with a bootAddress");
227
761
  return `${boot}.${POX5_CONTRACT_NAME}`;
228
762
  }
229
- function call(client, functionName, functionArgs, options = {}) {
230
- return callContract(client, {
231
- contract: pox5ContractId(client),
232
- functionName,
233
- functionArgs,
234
- ...options
235
- });
236
- }
237
- function read(client, functionName, functionArgs = []) {
763
+ function getPox5Contract(client) {
238
764
  const [address, name] = pox5ContractId(client).split(".");
239
- return readContract(client, {
240
- contract: `${address}.${name}`,
241
- functionName,
242
- args: functionArgs
243
- });
765
+ return getContract({ client, address, name, abi: POX5_ABI });
244
766
  }
245
- function bufferCV(input) {
246
- return typeof input === "string" ? Cl.bufferFromHex(input) : Cl.buffer(input);
767
+ function toBytes2(input) {
768
+ return typeof input === "string" ? hexToBytes(input) : input;
247
769
  }
248
- function btcLockupCV(lockup) {
249
- if ("sbtcSats" in lockup)
250
- return Cl.error(Cl.uint(lockup.sbtcSats));
251
- return Cl.ok(Cl.tuple({
252
- outputs: Cl.list(lockup.l1Outputs.map((o) => Cl.tuple({
253
- height: Cl.uint(o.height),
254
- tx: bufferCV(o.tx),
255
- "output-index": Cl.uint(o.outputIndex),
256
- header: bufferCV(o.header),
257
- "leaf-hashes": Cl.list(o.leafHashes.map(bufferCV)),
258
- "tx-count": Cl.uint(o.txCount),
259
- "tx-index": Cl.uint(o.txIndex),
260
- amount: Cl.uint(o.amount),
261
- "unlock-burn-height": Cl.uint(o.unlockBurnHeight)
262
- }))),
263
- "staker-unlock-bytes": bufferCV(lockup.stakerUnlockBytes)
264
- }));
770
+ function optionalBytes(input) {
771
+ return input === undefined ? null : toBytes2(input);
265
772
  }
266
- function optionalBuffer(input) {
267
- return input === undefined ? Cl.none() : Cl.some(bufferCV(input));
773
+ function btcLockupArg(lockup) {
774
+ if ("sbtcSats" in lockup)
775
+ return { err: intToBigInt(lockup.sbtcSats) };
776
+ return {
777
+ ok: {
778
+ outputs: lockup.l1Outputs.map((o) => ({
779
+ height: intToBigInt(o.height),
780
+ tx: toBytes2(o.tx),
781
+ outputIndex: intToBigInt(o.outputIndex),
782
+ header: toBytes2(o.header),
783
+ leafHashes: o.leafHashes.map(toBytes2),
784
+ txCount: intToBigInt(o.txCount),
785
+ txIndex: intToBigInt(o.txIndex),
786
+ amount: intToBigInt(o.amount),
787
+ unlockBurnHeight: intToBigInt(o.unlockBurnHeight)
788
+ })),
789
+ stakerUnlockBytes: toBytes2(lockup.stakerUnlockBytes)
790
+ }
791
+ };
268
792
  }
269
793
  function setupBond(client, params) {
270
794
  const {
@@ -276,17 +800,17 @@ function setupBond(client, params) {
276
800
  allowlist,
277
801
  ...tx
278
802
  } = params;
279
- return call(client, "setup-bond", [
280
- Cl.uint(bondIndex),
281
- Cl.uint(targetRate),
282
- Cl.uint(stxValueRatio),
283
- Cl.uint(minUstxRatio),
284
- bufferCV(earlyUnlockBytes),
285
- Cl.list(allowlist.map((a) => Cl.tuple({
286
- staker: Cl.principal(a.staker),
287
- "max-sats": Cl.uint(a.maxSats)
288
- })))
289
- ], tx);
803
+ return getPox5Contract(client).call.setupBond({
804
+ bondIndex: intToBigInt(bondIndex),
805
+ targetRate: intToBigInt(targetRate),
806
+ stxValueRatio: intToBigInt(stxValueRatio),
807
+ minUstxRatio: intToBigInt(minUstxRatio),
808
+ earlyUnlockBytes: toBytes2(earlyUnlockBytes),
809
+ allowlist: allowlist.map((a) => ({
810
+ staker: a.staker,
811
+ maxSats: intToBigInt(a.maxSats)
812
+ }))
813
+ }, tx);
290
814
  }
291
815
  function registerForBond(client, params) {
292
816
  const {
@@ -297,21 +821,21 @@ function registerForBond(client, params) {
297
821
  signerCalldata,
298
822
  ...tx
299
823
  } = params;
300
- return call(client, "register-for-bond", [
301
- Cl.uint(bondIndex),
302
- Cl.principal(signerManager),
303
- Cl.uint(amountUstx),
304
- btcLockupCV(btcLockup),
305
- optionalBuffer(signerCalldata)
306
- ], tx);
824
+ return getPox5Contract(client).call.registerForBond({
825
+ bondIndex: intToBigInt(bondIndex),
826
+ signerManager,
827
+ amountUstx: intToBigInt(amountUstx),
828
+ btcLockup: btcLockupArg(btcLockup),
829
+ signerCalldata: optionalBytes(signerCalldata)
830
+ }, tx);
307
831
  }
308
832
  function updateBondRegistration(client, params) {
309
833
  const { signerManager, oldSignerManager, signerCalldata, ...tx } = params;
310
- return call(client, "update-bond-registration", [
311
- Cl.principal(signerManager),
312
- Cl.principal(oldSignerManager),
313
- optionalBuffer(signerCalldata)
314
- ], tx);
834
+ return getPox5Contract(client).call.updateBondRegistration({
835
+ signerManager,
836
+ oldSignerManager,
837
+ signerCalldata: optionalBytes(signerCalldata)
838
+ }, tx);
315
839
  }
316
840
  function stake(client, params) {
317
841
  const {
@@ -322,13 +846,13 @@ function stake(client, params) {
322
846
  signerCalldata,
323
847
  ...tx
324
848
  } = params;
325
- return call(client, "stake", [
326
- Cl.principal(signerManager),
327
- Cl.uint(amountUstx),
328
- Cl.uint(numCycles),
329
- Cl.uint(startBurnHeight),
330
- optionalBuffer(signerCalldata)
331
- ], tx);
849
+ return getPox5Contract(client).call.stake({
850
+ signerManager,
851
+ amountUstx: intToBigInt(amountUstx),
852
+ numCycles: intToBigInt(numCycles),
853
+ startBurnHt: intToBigInt(startBurnHeight),
854
+ signerCalldata: optionalBytes(signerCalldata)
855
+ }, tx);
332
856
  }
333
857
  function stakeUpdate(client, params) {
334
858
  const {
@@ -339,99 +863,114 @@ function stakeUpdate(client, params) {
339
863
  signerCalldata,
340
864
  ...tx
341
865
  } = params;
342
- return call(client, "stake-update", [
343
- Cl.principal(signerManager),
344
- Cl.principal(oldSignerManager),
345
- Cl.uint(cyclesToExtend),
346
- Cl.uint(amountIncrease),
347
- optionalBuffer(signerCalldata)
348
- ], tx);
866
+ return getPox5Contract(client).call.stakeUpdate({
867
+ signerManager,
868
+ oldSignerManager,
869
+ cyclesToExtend: intToBigInt(cyclesToExtend),
870
+ amountIncrease: intToBigInt(amountIncrease),
871
+ signerCalldata: optionalBytes(signerCalldata)
872
+ }, tx);
349
873
  }
350
874
  function unstake(client, params) {
351
875
  const { oldSignerManager, ...tx } = params;
352
- return call(client, "unstake", [Cl.principal(oldSignerManager)], tx);
876
+ return getPox5Contract(client).call.unstake({ oldSignerManager }, tx);
353
877
  }
354
878
  function unstakeSbtc(client, params) {
355
879
  const { signerManager, amountSats, ...tx } = params;
356
- return call(client, "unstake-sbtc", [Cl.principal(signerManager), Cl.uint(amountSats)], tx);
880
+ return getPox5Contract(client).call.unstakeSbtc({ signerManager, amountToWithdrawalSats: intToBigInt(amountSats) }, tx);
357
881
  }
358
882
  function announceL1EarlyExit(client, params) {
359
883
  const { staker, oldSignerManager, ...tx } = params;
360
- return call(client, "announce-l1-early-exit", [Cl.principal(staker), Cl.principal(oldSignerManager)], tx);
884
+ return getPox5Contract(client).call.announceL1EarlyExit({ staker, oldSignerManager }, tx);
361
885
  }
362
886
  function calculateRewards(client, params) {
363
887
  const { bondPeriods, ...tx } = params;
364
- return call(client, "calculate-rewards", [Cl.list(bondPeriods.map((p) => Cl.uint(p)))], tx);
888
+ return getPox5Contract(client).call.calculateRewards({ bondPeriods: bondPeriods.map(intToBigInt) }, tx);
365
889
  }
366
890
  function claimRewards(client, params) {
367
891
  const { bondPeriods, rewardCycle, ...tx } = params;
368
- return call(client, "claim-rewards", [Cl.list(bondPeriods.map((p) => Cl.uint(p))), Cl.uint(rewardCycle)], tx);
892
+ return getPox5Contract(client).call.claimRewards({
893
+ bondPeriods: bondPeriods.map(intToBigInt),
894
+ rewardCycle: intToBigInt(rewardCycle)
895
+ }, tx);
369
896
  }
370
897
  function claimStakerRewardsForSigner(client, params) {
371
898
  const { staker, rewardCycle, bondIndex, ...tx } = params;
372
- return call(client, "claim-staker-rewards-for-signer", [
373
- Cl.principal(staker),
374
- Cl.uint(rewardCycle),
375
- bondIndex === undefined ? Cl.none() : Cl.some(Cl.uint(bondIndex))
376
- ], tx);
899
+ return getPox5Contract(client).call.claimStakerRewardsForSigner({
900
+ staker,
901
+ rewardCycle: intToBigInt(rewardCycle),
902
+ bondIndex: bondIndex === undefined ? null : intToBigInt(bondIndex)
903
+ }, tx);
377
904
  }
378
905
  function grantSignerKey(client, params) {
379
906
  const { signerKey, signerManager, authId, signerSig, ...tx } = params;
380
- return call(client, "grant-signer-key", [
381
- bufferCV(signerKey),
382
- Cl.principal(signerManager),
383
- Cl.uint(authId),
384
- bufferCV(signerSig)
385
- ], tx);
907
+ return getPox5Contract(client).call.grantSignerKey({
908
+ signerKey: toBytes2(signerKey),
909
+ signerManager,
910
+ authId: intToBigInt(authId),
911
+ signerSig: toBytes2(signerSig)
912
+ }, tx);
386
913
  }
387
914
  function revokeSignerGrant(client, params) {
388
915
  const { signerManager, signerKey, ...tx } = params;
389
- return call(client, "revoke-signer-grant", [Cl.principal(signerManager), bufferCV(signerKey)], tx);
916
+ return getPox5Contract(client).call.revokeSignerGrant({ signerManager, signerKey: toBytes2(signerKey) }, tx);
390
917
  }
391
- function getStakerInfo(client, staker) {
392
- return read(client, "get-staker-info", [Cl.principal(staker)]);
918
+ async function getStakerInfo(client, staker) {
919
+ return await getPox5Contract(client).read.getStakerInfo({
920
+ staker
921
+ });
393
922
  }
394
- function getBondMembership(client, staker) {
395
- return read(client, "get-bond-membership", [Cl.principal(staker)]);
923
+ async function getBondMembership(client, staker) {
924
+ return await getPox5Contract(client).read.getBondMembership({
925
+ staker
926
+ });
396
927
  }
397
- function getProtocolBond(client, bondIndex) {
398
- return read(client, "get-protocol-bond", [Cl.uint(bondIndex)]);
928
+ async function getProtocolBond(client, bondIndex) {
929
+ return await getPox5Contract(client).read.getProtocolBond({
930
+ bondIndex: intToBigInt(bondIndex)
931
+ });
399
932
  }
400
- function getBondAllowance(client, bondIndex, staker) {
401
- return read(client, "get-bond-allowance", [
402
- Cl.uint(bondIndex),
403
- Cl.principal(staker)
404
- ]);
933
+ async function getBondAllowance(client, bondIndex, staker) {
934
+ return await getPox5Contract(client).read.getBondAllowance({
935
+ bondIndex: intToBigInt(bondIndex),
936
+ staker
937
+ });
405
938
  }
406
939
  function getTotalSbtcStakedForBond(client, bondIndex) {
407
- return read(client, "get-total-sbtc-staked-for-bond", [Cl.uint(bondIndex)]);
940
+ return getPox5Contract(client).read.getTotalSbtcStakedForBond({
941
+ bondIndex: intToBigInt(bondIndex)
942
+ });
408
943
  }
409
944
  function getStakerCustodiedSbtc(client, staker) {
410
- return read(client, "get-staker-custodied-sbtc", [Cl.principal(staker)]);
945
+ return getPox5Contract(client).read.getStakerCustodiedSbtc({ staker });
411
946
  }
412
947
  function hasAnnouncedL1EarlyExit(client, bondIndex, staker) {
413
- return read(client, "has-announced-l1-early-exit", [
414
- Cl.uint(bondIndex),
415
- Cl.principal(staker)
416
- ]);
948
+ return getPox5Contract(client).read.hasAnnouncedL1EarlyExit({
949
+ bondIndex: intToBigInt(bondIndex),
950
+ staker
951
+ });
417
952
  }
418
953
  function getBondL1UnlockHeight(client, bondIndex) {
419
- return read(client, "get-bond-l1-unlock-height", [Cl.uint(bondIndex)]);
954
+ return getPox5Contract(client).read.getBondL1UnlockHeight({
955
+ bondIndex: intToBigInt(bondIndex)
956
+ });
420
957
  }
421
- function getSignerInfo(client, signer) {
422
- return read(client, "get-signer-info", [Cl.principal(signer)]);
958
+ async function getSignerInfo(client, signer) {
959
+ return await getPox5Contract(client).read.getSignerInfo({
960
+ signer
961
+ });
423
962
  }
424
963
  function verifySignerKeyGrantOnChain(client, signerManager, signerKey) {
425
- return read(client, "verify-signer-key-grant", [
426
- Cl.principal(signerManager),
427
- bufferCV(signerKey)
428
- ]);
964
+ return getPox5Contract(client).read.verifySignerKeyGrant({
965
+ signerManager,
966
+ signerKey: toBytes2(signerKey)
967
+ });
429
968
  }
430
969
  function getCurrentRewardCycle(client) {
431
- return read(client, "current-pox-reward-cycle");
970
+ return getPox5Contract(client).read.currentPoxRewardCycle({});
432
971
  }
433
972
  function getFirstPox5RewardCycle(client) {
434
- return read(client, "get-first-pox-5-reward-cycle");
973
+ return getPox5Contract(client).read.getFirstPox5RewardCycle({});
435
974
  }
436
975
  // src/pox5/extension.ts
437
976
  async function getStakerState(client, staker) {
@@ -536,5 +1075,5 @@ export {
536
1075
  BITCOIN_LOCKTIME_THRESHOLD
537
1076
  };
538
1077
 
539
- //# debugId=922D98973998F42C64756E2164756E21
1078
+ //# debugId=3C4269CF940090F064756E2164756E21
540
1079
  //# sourceMappingURL=index.js.map