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