genlayer-js 0.18.6 → 0.18.7
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/CHANGELOG.md +7 -0
- package/dist/chains/index.cjs +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/{chunk-QAAO2WJL.cjs → chunk-I23SLL2A.cjs} +52 -13
- package/dist/{chunk-KVHGQTAI.js → chunk-RW6PLN5W.js} +52 -13
- package/dist/{index-BBh1NZjP.d.ts → index-9QkkDjYm.d.ts} +166 -12
- package/dist/{index-3leEwFoq.d.cts → index-DM646L5c.d.cts} +166 -12
- package/dist/index.cjs +67 -33
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/abi/staking.ts +53 -13
- package/src/staking/actions.ts +46 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## 0.18.7 (2025-12-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Decodes contract error messages ([#127](https://github.com/genlayerlabs/genlayer-js/issues/127)) ([0a82545](https://github.com/genlayerlabs/genlayer-js/commit/0a82545e994144229950ad2d156c20233102a8c4))
|
|
9
|
+
|
|
3
10
|
## 0.18.6 (2025-12-04)
|
|
4
11
|
|
|
5
12
|
|
package/dist/chains/index.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkI23SLL2Acjs = require('../chunk-I23SLL2A.cjs');
|
|
6
6
|
require('../chunk-75ZPJI57.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.localnet =
|
|
11
|
+
exports.localnet = _chunkI23SLL2Acjs.localnet; exports.studionet = _chunkI23SLL2Acjs.studionet; exports.testnetAsimov = _chunkI23SLL2Acjs.testnetAsimov;
|
package/dist/chains/index.js
CHANGED
|
@@ -8042,6 +8042,13 @@ var studionet = _viem.defineChain.call(void 0, {
|
|
|
8042
8042
|
|
|
8043
8043
|
// src/abi/staking.ts
|
|
8044
8044
|
var VALIDATOR_WALLET_ABI = [
|
|
8045
|
+
// Custom errors
|
|
8046
|
+
{ name: "NotOperator", type: "error", inputs: [] },
|
|
8047
|
+
{ name: "InvalidAddress", type: "error", inputs: [] },
|
|
8048
|
+
{ name: "TransferFailed", type: "error", inputs: [] },
|
|
8049
|
+
{ name: "OperatorTransferNotReady", type: "error", inputs: [] },
|
|
8050
|
+
{ name: "NoPendingOperator", type: "error", inputs: [] },
|
|
8051
|
+
// Functions
|
|
8045
8052
|
{
|
|
8046
8053
|
name: "operator",
|
|
8047
8054
|
type: "function",
|
|
@@ -8105,19 +8112,51 @@ var VALIDATOR_WALLET_ABI = [
|
|
|
8105
8112
|
}
|
|
8106
8113
|
];
|
|
8107
8114
|
var STAKING_ABI = [
|
|
8108
|
-
// Custom errors
|
|
8109
|
-
{ name: "
|
|
8110
|
-
{ name: "
|
|
8111
|
-
{ name: "
|
|
8112
|
-
{ name: "
|
|
8113
|
-
{ name: "
|
|
8114
|
-
{ name: "
|
|
8115
|
-
{ name: "
|
|
8116
|
-
{ name: "
|
|
8117
|
-
{ name: "
|
|
8118
|
-
{ name: "
|
|
8119
|
-
{ name: "
|
|
8120
|
-
{ name: "
|
|
8115
|
+
// Custom errors from IGenLayerStaking
|
|
8116
|
+
{ name: "OnlyGEN", type: "error", inputs: [] },
|
|
8117
|
+
{ name: "OnlyTribunal", type: "error", inputs: [] },
|
|
8118
|
+
{ name: "OnlyIdleness", type: "error", inputs: [] },
|
|
8119
|
+
{ name: "OnlyTransactions", type: "error", inputs: [] },
|
|
8120
|
+
{ name: "OnlyIdlenessOrTribunal", type: "error", inputs: [] },
|
|
8121
|
+
{ name: "OnlyTransactionsOrTribunal", type: "error", inputs: [] },
|
|
8122
|
+
{ name: "InvalidAtEpoch", type: "error", inputs: [] },
|
|
8123
|
+
{ name: "MaxValidatorsCannotBeZero", type: "error", inputs: [] },
|
|
8124
|
+
{ name: "ValidatorExitExceedsShares", type: "error", inputs: [] },
|
|
8125
|
+
{ name: "DelegatorExitExceedsShares", type: "error", inputs: [] },
|
|
8126
|
+
{ name: "DelegatorMayNotJoinWithZeroValue", type: "error", inputs: [] },
|
|
8127
|
+
{ name: "DelegatorMayNotJoinTwoValidatorsSimultaneously", type: "error", inputs: [] },
|
|
8128
|
+
{ name: "DelegatorBelowMinimumStake", type: "error", inputs: [] },
|
|
8129
|
+
{ name: "DelegatorExitWouldBeBelowMinimum", type: "error", inputs: [] },
|
|
8130
|
+
{ name: "ValidatorNotActive", type: "error", inputs: [] },
|
|
8131
|
+
{ name: "ValidatorMayNotBeDelegator", type: "error", inputs: [] },
|
|
8132
|
+
{ name: "ValidatorMustNotBeDelegator", type: "error", inputs: [] },
|
|
8133
|
+
{ name: "ValidatorMayNotJoinWithZeroValue", type: "error", inputs: [] },
|
|
8134
|
+
{ name: "ValidatorMayNotDepositZeroValue", type: "error", inputs: [] },
|
|
8135
|
+
{ name: "ValidatorWithdrawalExceedsStake", type: "error", inputs: [] },
|
|
8136
|
+
{ name: "ValidatorAlreadyJoined", type: "error", inputs: [] },
|
|
8137
|
+
{ name: "ValidatorNotJoined", type: "error", inputs: [] },
|
|
8138
|
+
{ name: "ValidatorBelowMinimumStake", type: "error", inputs: [] },
|
|
8139
|
+
{ name: "OperatorAlreadyAssigned", type: "error", inputs: [] },
|
|
8140
|
+
{ name: "InvalidOperatorAddress", type: "error", inputs: [] },
|
|
8141
|
+
{ name: "MaxNumberOfValidatorsReached", type: "error", inputs: [] },
|
|
8142
|
+
{ name: "ValidatorsConsumed", type: "error", inputs: [] },
|
|
8143
|
+
{ name: "ValidatorsUnavailable", type: "error", inputs: [] },
|
|
8144
|
+
{ name: "EpochNotFinished", type: "error", inputs: [] },
|
|
8145
|
+
{ name: "EpochNotFinalized", type: "error", inputs: [] },
|
|
8146
|
+
{ name: "InflationInvalidAmount", type: "error", inputs: [] },
|
|
8147
|
+
{ name: "InflationAlreadyReceived", type: "error", inputs: [] },
|
|
8148
|
+
{ name: "InflationAlreadyInitialized", type: "error", inputs: [] },
|
|
8149
|
+
{ name: "EpochAlreadyFinalized", type: "error", inputs: [] },
|
|
8150
|
+
{ name: "PendingTribunals", type: "error", inputs: [{ name: "epoch", type: "uint256" }] },
|
|
8151
|
+
{ name: "FailedTransfer", type: "error", inputs: [{ name: "validator", type: "address" }] },
|
|
8152
|
+
{ name: "NFTMinterCallFailed", type: "error", inputs: [] },
|
|
8153
|
+
{ name: "DeepthoughtCallFailed", type: "error", inputs: [] },
|
|
8154
|
+
{ name: "NFTMinterNotConfigured", type: "error", inputs: [] },
|
|
8155
|
+
{ name: "NumberOfValidatorsExceedsAvailable", type: "error", inputs: [] },
|
|
8156
|
+
{ name: "EpochAdvanceNotReady", type: "error", inputs: [] },
|
|
8157
|
+
{ name: "PreviousEpochNotFinalizable", type: "error", inputs: [] },
|
|
8158
|
+
{ name: "NoBurning", type: "error", inputs: [] },
|
|
8159
|
+
{ name: "ReductionFactorCannotBeZero", type: "error", inputs: [] },
|
|
8121
8160
|
// Validator functions
|
|
8122
8161
|
{
|
|
8123
8162
|
name: "validatorJoin",
|
|
@@ -8042,6 +8042,13 @@ import { defineChain as defineChain3 } from "viem";
|
|
|
8042
8042
|
|
|
8043
8043
|
// src/abi/staking.ts
|
|
8044
8044
|
var VALIDATOR_WALLET_ABI = [
|
|
8045
|
+
// Custom errors
|
|
8046
|
+
{ name: "NotOperator", type: "error", inputs: [] },
|
|
8047
|
+
{ name: "InvalidAddress", type: "error", inputs: [] },
|
|
8048
|
+
{ name: "TransferFailed", type: "error", inputs: [] },
|
|
8049
|
+
{ name: "OperatorTransferNotReady", type: "error", inputs: [] },
|
|
8050
|
+
{ name: "NoPendingOperator", type: "error", inputs: [] },
|
|
8051
|
+
// Functions
|
|
8045
8052
|
{
|
|
8046
8053
|
name: "operator",
|
|
8047
8054
|
type: "function",
|
|
@@ -8105,19 +8112,51 @@ var VALIDATOR_WALLET_ABI = [
|
|
|
8105
8112
|
}
|
|
8106
8113
|
];
|
|
8107
8114
|
var STAKING_ABI = [
|
|
8108
|
-
// Custom errors
|
|
8109
|
-
{ name: "
|
|
8110
|
-
{ name: "
|
|
8111
|
-
{ name: "
|
|
8112
|
-
{ name: "
|
|
8113
|
-
{ name: "
|
|
8114
|
-
{ name: "
|
|
8115
|
-
{ name: "
|
|
8116
|
-
{ name: "
|
|
8117
|
-
{ name: "
|
|
8118
|
-
{ name: "
|
|
8119
|
-
{ name: "
|
|
8120
|
-
{ name: "
|
|
8115
|
+
// Custom errors from IGenLayerStaking
|
|
8116
|
+
{ name: "OnlyGEN", type: "error", inputs: [] },
|
|
8117
|
+
{ name: "OnlyTribunal", type: "error", inputs: [] },
|
|
8118
|
+
{ name: "OnlyIdleness", type: "error", inputs: [] },
|
|
8119
|
+
{ name: "OnlyTransactions", type: "error", inputs: [] },
|
|
8120
|
+
{ name: "OnlyIdlenessOrTribunal", type: "error", inputs: [] },
|
|
8121
|
+
{ name: "OnlyTransactionsOrTribunal", type: "error", inputs: [] },
|
|
8122
|
+
{ name: "InvalidAtEpoch", type: "error", inputs: [] },
|
|
8123
|
+
{ name: "MaxValidatorsCannotBeZero", type: "error", inputs: [] },
|
|
8124
|
+
{ name: "ValidatorExitExceedsShares", type: "error", inputs: [] },
|
|
8125
|
+
{ name: "DelegatorExitExceedsShares", type: "error", inputs: [] },
|
|
8126
|
+
{ name: "DelegatorMayNotJoinWithZeroValue", type: "error", inputs: [] },
|
|
8127
|
+
{ name: "DelegatorMayNotJoinTwoValidatorsSimultaneously", type: "error", inputs: [] },
|
|
8128
|
+
{ name: "DelegatorBelowMinimumStake", type: "error", inputs: [] },
|
|
8129
|
+
{ name: "DelegatorExitWouldBeBelowMinimum", type: "error", inputs: [] },
|
|
8130
|
+
{ name: "ValidatorNotActive", type: "error", inputs: [] },
|
|
8131
|
+
{ name: "ValidatorMayNotBeDelegator", type: "error", inputs: [] },
|
|
8132
|
+
{ name: "ValidatorMustNotBeDelegator", type: "error", inputs: [] },
|
|
8133
|
+
{ name: "ValidatorMayNotJoinWithZeroValue", type: "error", inputs: [] },
|
|
8134
|
+
{ name: "ValidatorMayNotDepositZeroValue", type: "error", inputs: [] },
|
|
8135
|
+
{ name: "ValidatorWithdrawalExceedsStake", type: "error", inputs: [] },
|
|
8136
|
+
{ name: "ValidatorAlreadyJoined", type: "error", inputs: [] },
|
|
8137
|
+
{ name: "ValidatorNotJoined", type: "error", inputs: [] },
|
|
8138
|
+
{ name: "ValidatorBelowMinimumStake", type: "error", inputs: [] },
|
|
8139
|
+
{ name: "OperatorAlreadyAssigned", type: "error", inputs: [] },
|
|
8140
|
+
{ name: "InvalidOperatorAddress", type: "error", inputs: [] },
|
|
8141
|
+
{ name: "MaxNumberOfValidatorsReached", type: "error", inputs: [] },
|
|
8142
|
+
{ name: "ValidatorsConsumed", type: "error", inputs: [] },
|
|
8143
|
+
{ name: "ValidatorsUnavailable", type: "error", inputs: [] },
|
|
8144
|
+
{ name: "EpochNotFinished", type: "error", inputs: [] },
|
|
8145
|
+
{ name: "EpochNotFinalized", type: "error", inputs: [] },
|
|
8146
|
+
{ name: "InflationInvalidAmount", type: "error", inputs: [] },
|
|
8147
|
+
{ name: "InflationAlreadyReceived", type: "error", inputs: [] },
|
|
8148
|
+
{ name: "InflationAlreadyInitialized", type: "error", inputs: [] },
|
|
8149
|
+
{ name: "EpochAlreadyFinalized", type: "error", inputs: [] },
|
|
8150
|
+
{ name: "PendingTribunals", type: "error", inputs: [{ name: "epoch", type: "uint256" }] },
|
|
8151
|
+
{ name: "FailedTransfer", type: "error", inputs: [{ name: "validator", type: "address" }] },
|
|
8152
|
+
{ name: "NFTMinterCallFailed", type: "error", inputs: [] },
|
|
8153
|
+
{ name: "DeepthoughtCallFailed", type: "error", inputs: [] },
|
|
8154
|
+
{ name: "NFTMinterNotConfigured", type: "error", inputs: [] },
|
|
8155
|
+
{ name: "NumberOfValidatorsExceedsAvailable", type: "error", inputs: [] },
|
|
8156
|
+
{ name: "EpochAdvanceNotReady", type: "error", inputs: [] },
|
|
8157
|
+
{ name: "PreviousEpochNotFinalizable", type: "error", inputs: [] },
|
|
8158
|
+
{ name: "NoBurning", type: "error", inputs: [] },
|
|
8159
|
+
{ name: "ReductionFactorCannotBeZero", type: "error", inputs: [] },
|
|
8121
8160
|
// Validator functions
|
|
8122
8161
|
{
|
|
8123
8162
|
name: "validatorJoin",
|
|
@@ -289,6 +289,26 @@ type MetaMaskClientResult = {
|
|
|
289
289
|
};
|
|
290
290
|
|
|
291
291
|
declare const VALIDATOR_WALLET_ABI: readonly [{
|
|
292
|
+
readonly name: "NotOperator";
|
|
293
|
+
readonly type: "error";
|
|
294
|
+
readonly inputs: readonly [];
|
|
295
|
+
}, {
|
|
296
|
+
readonly name: "InvalidAddress";
|
|
297
|
+
readonly type: "error";
|
|
298
|
+
readonly inputs: readonly [];
|
|
299
|
+
}, {
|
|
300
|
+
readonly name: "TransferFailed";
|
|
301
|
+
readonly type: "error";
|
|
302
|
+
readonly inputs: readonly [];
|
|
303
|
+
}, {
|
|
304
|
+
readonly name: "OperatorTransferNotReady";
|
|
305
|
+
readonly type: "error";
|
|
306
|
+
readonly inputs: readonly [];
|
|
307
|
+
}, {
|
|
308
|
+
readonly name: "NoPendingOperator";
|
|
309
|
+
readonly type: "error";
|
|
310
|
+
readonly inputs: readonly [];
|
|
311
|
+
}, {
|
|
292
312
|
readonly name: "operator";
|
|
293
313
|
readonly type: "function";
|
|
294
314
|
readonly stateMutability: "view";
|
|
@@ -387,51 +407,185 @@ declare const VALIDATOR_WALLET_ABI: readonly [{
|
|
|
387
407
|
readonly outputs: readonly [];
|
|
388
408
|
}];
|
|
389
409
|
declare const STAKING_ABI: readonly [{
|
|
390
|
-
readonly name: "
|
|
410
|
+
readonly name: "OnlyGEN";
|
|
391
411
|
readonly type: "error";
|
|
392
412
|
readonly inputs: readonly [];
|
|
393
413
|
}, {
|
|
394
|
-
readonly name: "
|
|
414
|
+
readonly name: "OnlyTribunal";
|
|
395
415
|
readonly type: "error";
|
|
396
416
|
readonly inputs: readonly [];
|
|
397
417
|
}, {
|
|
398
|
-
readonly name: "
|
|
418
|
+
readonly name: "OnlyIdleness";
|
|
399
419
|
readonly type: "error";
|
|
400
420
|
readonly inputs: readonly [];
|
|
401
421
|
}, {
|
|
402
|
-
readonly name: "
|
|
422
|
+
readonly name: "OnlyTransactions";
|
|
403
423
|
readonly type: "error";
|
|
404
424
|
readonly inputs: readonly [];
|
|
405
425
|
}, {
|
|
406
|
-
readonly name: "
|
|
426
|
+
readonly name: "OnlyIdlenessOrTribunal";
|
|
427
|
+
readonly type: "error";
|
|
428
|
+
readonly inputs: readonly [];
|
|
429
|
+
}, {
|
|
430
|
+
readonly name: "OnlyTransactionsOrTribunal";
|
|
431
|
+
readonly type: "error";
|
|
432
|
+
readonly inputs: readonly [];
|
|
433
|
+
}, {
|
|
434
|
+
readonly name: "InvalidAtEpoch";
|
|
435
|
+
readonly type: "error";
|
|
436
|
+
readonly inputs: readonly [];
|
|
437
|
+
}, {
|
|
438
|
+
readonly name: "MaxValidatorsCannotBeZero";
|
|
439
|
+
readonly type: "error";
|
|
440
|
+
readonly inputs: readonly [];
|
|
441
|
+
}, {
|
|
442
|
+
readonly name: "ValidatorExitExceedsShares";
|
|
443
|
+
readonly type: "error";
|
|
444
|
+
readonly inputs: readonly [];
|
|
445
|
+
}, {
|
|
446
|
+
readonly name: "DelegatorExitExceedsShares";
|
|
447
|
+
readonly type: "error";
|
|
448
|
+
readonly inputs: readonly [];
|
|
449
|
+
}, {
|
|
450
|
+
readonly name: "DelegatorMayNotJoinWithZeroValue";
|
|
451
|
+
readonly type: "error";
|
|
452
|
+
readonly inputs: readonly [];
|
|
453
|
+
}, {
|
|
454
|
+
readonly name: "DelegatorMayNotJoinTwoValidatorsSimultaneously";
|
|
455
|
+
readonly type: "error";
|
|
456
|
+
readonly inputs: readonly [];
|
|
457
|
+
}, {
|
|
458
|
+
readonly name: "DelegatorBelowMinimumStake";
|
|
459
|
+
readonly type: "error";
|
|
460
|
+
readonly inputs: readonly [];
|
|
461
|
+
}, {
|
|
462
|
+
readonly name: "DelegatorExitWouldBeBelowMinimum";
|
|
463
|
+
readonly type: "error";
|
|
464
|
+
readonly inputs: readonly [];
|
|
465
|
+
}, {
|
|
466
|
+
readonly name: "ValidatorNotActive";
|
|
467
|
+
readonly type: "error";
|
|
468
|
+
readonly inputs: readonly [];
|
|
469
|
+
}, {
|
|
470
|
+
readonly name: "ValidatorMayNotBeDelegator";
|
|
471
|
+
readonly type: "error";
|
|
472
|
+
readonly inputs: readonly [];
|
|
473
|
+
}, {
|
|
474
|
+
readonly name: "ValidatorMustNotBeDelegator";
|
|
475
|
+
readonly type: "error";
|
|
476
|
+
readonly inputs: readonly [];
|
|
477
|
+
}, {
|
|
478
|
+
readonly name: "ValidatorMayNotJoinWithZeroValue";
|
|
479
|
+
readonly type: "error";
|
|
480
|
+
readonly inputs: readonly [];
|
|
481
|
+
}, {
|
|
482
|
+
readonly name: "ValidatorMayNotDepositZeroValue";
|
|
483
|
+
readonly type: "error";
|
|
484
|
+
readonly inputs: readonly [];
|
|
485
|
+
}, {
|
|
486
|
+
readonly name: "ValidatorWithdrawalExceedsStake";
|
|
487
|
+
readonly type: "error";
|
|
488
|
+
readonly inputs: readonly [];
|
|
489
|
+
}, {
|
|
490
|
+
readonly name: "ValidatorAlreadyJoined";
|
|
491
|
+
readonly type: "error";
|
|
492
|
+
readonly inputs: readonly [];
|
|
493
|
+
}, {
|
|
494
|
+
readonly name: "ValidatorNotJoined";
|
|
495
|
+
readonly type: "error";
|
|
496
|
+
readonly inputs: readonly [];
|
|
497
|
+
}, {
|
|
498
|
+
readonly name: "ValidatorBelowMinimumStake";
|
|
499
|
+
readonly type: "error";
|
|
500
|
+
readonly inputs: readonly [];
|
|
501
|
+
}, {
|
|
502
|
+
readonly name: "OperatorAlreadyAssigned";
|
|
503
|
+
readonly type: "error";
|
|
504
|
+
readonly inputs: readonly [];
|
|
505
|
+
}, {
|
|
506
|
+
readonly name: "InvalidOperatorAddress";
|
|
507
|
+
readonly type: "error";
|
|
508
|
+
readonly inputs: readonly [];
|
|
509
|
+
}, {
|
|
510
|
+
readonly name: "MaxNumberOfValidatorsReached";
|
|
511
|
+
readonly type: "error";
|
|
512
|
+
readonly inputs: readonly [];
|
|
513
|
+
}, {
|
|
514
|
+
readonly name: "ValidatorsConsumed";
|
|
515
|
+
readonly type: "error";
|
|
516
|
+
readonly inputs: readonly [];
|
|
517
|
+
}, {
|
|
518
|
+
readonly name: "ValidatorsUnavailable";
|
|
519
|
+
readonly type: "error";
|
|
520
|
+
readonly inputs: readonly [];
|
|
521
|
+
}, {
|
|
522
|
+
readonly name: "EpochNotFinished";
|
|
523
|
+
readonly type: "error";
|
|
524
|
+
readonly inputs: readonly [];
|
|
525
|
+
}, {
|
|
526
|
+
readonly name: "EpochNotFinalized";
|
|
527
|
+
readonly type: "error";
|
|
528
|
+
readonly inputs: readonly [];
|
|
529
|
+
}, {
|
|
530
|
+
readonly name: "InflationInvalidAmount";
|
|
531
|
+
readonly type: "error";
|
|
532
|
+
readonly inputs: readonly [];
|
|
533
|
+
}, {
|
|
534
|
+
readonly name: "InflationAlreadyReceived";
|
|
535
|
+
readonly type: "error";
|
|
536
|
+
readonly inputs: readonly [];
|
|
537
|
+
}, {
|
|
538
|
+
readonly name: "InflationAlreadyInitialized";
|
|
539
|
+
readonly type: "error";
|
|
540
|
+
readonly inputs: readonly [];
|
|
541
|
+
}, {
|
|
542
|
+
readonly name: "EpochAlreadyFinalized";
|
|
543
|
+
readonly type: "error";
|
|
544
|
+
readonly inputs: readonly [];
|
|
545
|
+
}, {
|
|
546
|
+
readonly name: "PendingTribunals";
|
|
547
|
+
readonly type: "error";
|
|
548
|
+
readonly inputs: readonly [{
|
|
549
|
+
readonly name: "epoch";
|
|
550
|
+
readonly type: "uint256";
|
|
551
|
+
}];
|
|
552
|
+
}, {
|
|
553
|
+
readonly name: "FailedTransfer";
|
|
554
|
+
readonly type: "error";
|
|
555
|
+
readonly inputs: readonly [{
|
|
556
|
+
readonly name: "validator";
|
|
557
|
+
readonly type: "address";
|
|
558
|
+
}];
|
|
559
|
+
}, {
|
|
560
|
+
readonly name: "NFTMinterCallFailed";
|
|
407
561
|
readonly type: "error";
|
|
408
562
|
readonly inputs: readonly [];
|
|
409
563
|
}, {
|
|
410
|
-
readonly name: "
|
|
564
|
+
readonly name: "DeepthoughtCallFailed";
|
|
411
565
|
readonly type: "error";
|
|
412
566
|
readonly inputs: readonly [];
|
|
413
567
|
}, {
|
|
414
|
-
readonly name: "
|
|
568
|
+
readonly name: "NFTMinterNotConfigured";
|
|
415
569
|
readonly type: "error";
|
|
416
570
|
readonly inputs: readonly [];
|
|
417
571
|
}, {
|
|
418
|
-
readonly name: "
|
|
572
|
+
readonly name: "NumberOfValidatorsExceedsAvailable";
|
|
419
573
|
readonly type: "error";
|
|
420
574
|
readonly inputs: readonly [];
|
|
421
575
|
}, {
|
|
422
|
-
readonly name: "
|
|
576
|
+
readonly name: "EpochAdvanceNotReady";
|
|
423
577
|
readonly type: "error";
|
|
424
578
|
readonly inputs: readonly [];
|
|
425
579
|
}, {
|
|
426
|
-
readonly name: "
|
|
580
|
+
readonly name: "PreviousEpochNotFinalizable";
|
|
427
581
|
readonly type: "error";
|
|
428
582
|
readonly inputs: readonly [];
|
|
429
583
|
}, {
|
|
430
|
-
readonly name: "
|
|
584
|
+
readonly name: "NoBurning";
|
|
431
585
|
readonly type: "error";
|
|
432
586
|
readonly inputs: readonly [];
|
|
433
587
|
}, {
|
|
434
|
-
readonly name: "
|
|
588
|
+
readonly name: "ReductionFactorCannotBeZero";
|
|
435
589
|
readonly type: "error";
|
|
436
590
|
readonly inputs: readonly [];
|
|
437
591
|
}, {
|
|
@@ -289,6 +289,26 @@ type MetaMaskClientResult = {
|
|
|
289
289
|
};
|
|
290
290
|
|
|
291
291
|
declare const VALIDATOR_WALLET_ABI: readonly [{
|
|
292
|
+
readonly name: "NotOperator";
|
|
293
|
+
readonly type: "error";
|
|
294
|
+
readonly inputs: readonly [];
|
|
295
|
+
}, {
|
|
296
|
+
readonly name: "InvalidAddress";
|
|
297
|
+
readonly type: "error";
|
|
298
|
+
readonly inputs: readonly [];
|
|
299
|
+
}, {
|
|
300
|
+
readonly name: "TransferFailed";
|
|
301
|
+
readonly type: "error";
|
|
302
|
+
readonly inputs: readonly [];
|
|
303
|
+
}, {
|
|
304
|
+
readonly name: "OperatorTransferNotReady";
|
|
305
|
+
readonly type: "error";
|
|
306
|
+
readonly inputs: readonly [];
|
|
307
|
+
}, {
|
|
308
|
+
readonly name: "NoPendingOperator";
|
|
309
|
+
readonly type: "error";
|
|
310
|
+
readonly inputs: readonly [];
|
|
311
|
+
}, {
|
|
292
312
|
readonly name: "operator";
|
|
293
313
|
readonly type: "function";
|
|
294
314
|
readonly stateMutability: "view";
|
|
@@ -387,51 +407,185 @@ declare const VALIDATOR_WALLET_ABI: readonly [{
|
|
|
387
407
|
readonly outputs: readonly [];
|
|
388
408
|
}];
|
|
389
409
|
declare const STAKING_ABI: readonly [{
|
|
390
|
-
readonly name: "
|
|
410
|
+
readonly name: "OnlyGEN";
|
|
391
411
|
readonly type: "error";
|
|
392
412
|
readonly inputs: readonly [];
|
|
393
413
|
}, {
|
|
394
|
-
readonly name: "
|
|
414
|
+
readonly name: "OnlyTribunal";
|
|
395
415
|
readonly type: "error";
|
|
396
416
|
readonly inputs: readonly [];
|
|
397
417
|
}, {
|
|
398
|
-
readonly name: "
|
|
418
|
+
readonly name: "OnlyIdleness";
|
|
399
419
|
readonly type: "error";
|
|
400
420
|
readonly inputs: readonly [];
|
|
401
421
|
}, {
|
|
402
|
-
readonly name: "
|
|
422
|
+
readonly name: "OnlyTransactions";
|
|
403
423
|
readonly type: "error";
|
|
404
424
|
readonly inputs: readonly [];
|
|
405
425
|
}, {
|
|
406
|
-
readonly name: "
|
|
426
|
+
readonly name: "OnlyIdlenessOrTribunal";
|
|
427
|
+
readonly type: "error";
|
|
428
|
+
readonly inputs: readonly [];
|
|
429
|
+
}, {
|
|
430
|
+
readonly name: "OnlyTransactionsOrTribunal";
|
|
431
|
+
readonly type: "error";
|
|
432
|
+
readonly inputs: readonly [];
|
|
433
|
+
}, {
|
|
434
|
+
readonly name: "InvalidAtEpoch";
|
|
435
|
+
readonly type: "error";
|
|
436
|
+
readonly inputs: readonly [];
|
|
437
|
+
}, {
|
|
438
|
+
readonly name: "MaxValidatorsCannotBeZero";
|
|
439
|
+
readonly type: "error";
|
|
440
|
+
readonly inputs: readonly [];
|
|
441
|
+
}, {
|
|
442
|
+
readonly name: "ValidatorExitExceedsShares";
|
|
443
|
+
readonly type: "error";
|
|
444
|
+
readonly inputs: readonly [];
|
|
445
|
+
}, {
|
|
446
|
+
readonly name: "DelegatorExitExceedsShares";
|
|
447
|
+
readonly type: "error";
|
|
448
|
+
readonly inputs: readonly [];
|
|
449
|
+
}, {
|
|
450
|
+
readonly name: "DelegatorMayNotJoinWithZeroValue";
|
|
451
|
+
readonly type: "error";
|
|
452
|
+
readonly inputs: readonly [];
|
|
453
|
+
}, {
|
|
454
|
+
readonly name: "DelegatorMayNotJoinTwoValidatorsSimultaneously";
|
|
455
|
+
readonly type: "error";
|
|
456
|
+
readonly inputs: readonly [];
|
|
457
|
+
}, {
|
|
458
|
+
readonly name: "DelegatorBelowMinimumStake";
|
|
459
|
+
readonly type: "error";
|
|
460
|
+
readonly inputs: readonly [];
|
|
461
|
+
}, {
|
|
462
|
+
readonly name: "DelegatorExitWouldBeBelowMinimum";
|
|
463
|
+
readonly type: "error";
|
|
464
|
+
readonly inputs: readonly [];
|
|
465
|
+
}, {
|
|
466
|
+
readonly name: "ValidatorNotActive";
|
|
467
|
+
readonly type: "error";
|
|
468
|
+
readonly inputs: readonly [];
|
|
469
|
+
}, {
|
|
470
|
+
readonly name: "ValidatorMayNotBeDelegator";
|
|
471
|
+
readonly type: "error";
|
|
472
|
+
readonly inputs: readonly [];
|
|
473
|
+
}, {
|
|
474
|
+
readonly name: "ValidatorMustNotBeDelegator";
|
|
475
|
+
readonly type: "error";
|
|
476
|
+
readonly inputs: readonly [];
|
|
477
|
+
}, {
|
|
478
|
+
readonly name: "ValidatorMayNotJoinWithZeroValue";
|
|
479
|
+
readonly type: "error";
|
|
480
|
+
readonly inputs: readonly [];
|
|
481
|
+
}, {
|
|
482
|
+
readonly name: "ValidatorMayNotDepositZeroValue";
|
|
483
|
+
readonly type: "error";
|
|
484
|
+
readonly inputs: readonly [];
|
|
485
|
+
}, {
|
|
486
|
+
readonly name: "ValidatorWithdrawalExceedsStake";
|
|
487
|
+
readonly type: "error";
|
|
488
|
+
readonly inputs: readonly [];
|
|
489
|
+
}, {
|
|
490
|
+
readonly name: "ValidatorAlreadyJoined";
|
|
491
|
+
readonly type: "error";
|
|
492
|
+
readonly inputs: readonly [];
|
|
493
|
+
}, {
|
|
494
|
+
readonly name: "ValidatorNotJoined";
|
|
495
|
+
readonly type: "error";
|
|
496
|
+
readonly inputs: readonly [];
|
|
497
|
+
}, {
|
|
498
|
+
readonly name: "ValidatorBelowMinimumStake";
|
|
499
|
+
readonly type: "error";
|
|
500
|
+
readonly inputs: readonly [];
|
|
501
|
+
}, {
|
|
502
|
+
readonly name: "OperatorAlreadyAssigned";
|
|
503
|
+
readonly type: "error";
|
|
504
|
+
readonly inputs: readonly [];
|
|
505
|
+
}, {
|
|
506
|
+
readonly name: "InvalidOperatorAddress";
|
|
507
|
+
readonly type: "error";
|
|
508
|
+
readonly inputs: readonly [];
|
|
509
|
+
}, {
|
|
510
|
+
readonly name: "MaxNumberOfValidatorsReached";
|
|
511
|
+
readonly type: "error";
|
|
512
|
+
readonly inputs: readonly [];
|
|
513
|
+
}, {
|
|
514
|
+
readonly name: "ValidatorsConsumed";
|
|
515
|
+
readonly type: "error";
|
|
516
|
+
readonly inputs: readonly [];
|
|
517
|
+
}, {
|
|
518
|
+
readonly name: "ValidatorsUnavailable";
|
|
519
|
+
readonly type: "error";
|
|
520
|
+
readonly inputs: readonly [];
|
|
521
|
+
}, {
|
|
522
|
+
readonly name: "EpochNotFinished";
|
|
523
|
+
readonly type: "error";
|
|
524
|
+
readonly inputs: readonly [];
|
|
525
|
+
}, {
|
|
526
|
+
readonly name: "EpochNotFinalized";
|
|
527
|
+
readonly type: "error";
|
|
528
|
+
readonly inputs: readonly [];
|
|
529
|
+
}, {
|
|
530
|
+
readonly name: "InflationInvalidAmount";
|
|
531
|
+
readonly type: "error";
|
|
532
|
+
readonly inputs: readonly [];
|
|
533
|
+
}, {
|
|
534
|
+
readonly name: "InflationAlreadyReceived";
|
|
535
|
+
readonly type: "error";
|
|
536
|
+
readonly inputs: readonly [];
|
|
537
|
+
}, {
|
|
538
|
+
readonly name: "InflationAlreadyInitialized";
|
|
539
|
+
readonly type: "error";
|
|
540
|
+
readonly inputs: readonly [];
|
|
541
|
+
}, {
|
|
542
|
+
readonly name: "EpochAlreadyFinalized";
|
|
543
|
+
readonly type: "error";
|
|
544
|
+
readonly inputs: readonly [];
|
|
545
|
+
}, {
|
|
546
|
+
readonly name: "PendingTribunals";
|
|
547
|
+
readonly type: "error";
|
|
548
|
+
readonly inputs: readonly [{
|
|
549
|
+
readonly name: "epoch";
|
|
550
|
+
readonly type: "uint256";
|
|
551
|
+
}];
|
|
552
|
+
}, {
|
|
553
|
+
readonly name: "FailedTransfer";
|
|
554
|
+
readonly type: "error";
|
|
555
|
+
readonly inputs: readonly [{
|
|
556
|
+
readonly name: "validator";
|
|
557
|
+
readonly type: "address";
|
|
558
|
+
}];
|
|
559
|
+
}, {
|
|
560
|
+
readonly name: "NFTMinterCallFailed";
|
|
407
561
|
readonly type: "error";
|
|
408
562
|
readonly inputs: readonly [];
|
|
409
563
|
}, {
|
|
410
|
-
readonly name: "
|
|
564
|
+
readonly name: "DeepthoughtCallFailed";
|
|
411
565
|
readonly type: "error";
|
|
412
566
|
readonly inputs: readonly [];
|
|
413
567
|
}, {
|
|
414
|
-
readonly name: "
|
|
568
|
+
readonly name: "NFTMinterNotConfigured";
|
|
415
569
|
readonly type: "error";
|
|
416
570
|
readonly inputs: readonly [];
|
|
417
571
|
}, {
|
|
418
|
-
readonly name: "
|
|
572
|
+
readonly name: "NumberOfValidatorsExceedsAvailable";
|
|
419
573
|
readonly type: "error";
|
|
420
574
|
readonly inputs: readonly [];
|
|
421
575
|
}, {
|
|
422
|
-
readonly name: "
|
|
576
|
+
readonly name: "EpochAdvanceNotReady";
|
|
423
577
|
readonly type: "error";
|
|
424
578
|
readonly inputs: readonly [];
|
|
425
579
|
}, {
|
|
426
|
-
readonly name: "
|
|
580
|
+
readonly name: "PreviousEpochNotFinalizable";
|
|
427
581
|
readonly type: "error";
|
|
428
582
|
readonly inputs: readonly [];
|
|
429
583
|
}, {
|
|
430
|
-
readonly name: "
|
|
584
|
+
readonly name: "NoBurning";
|
|
431
585
|
readonly type: "error";
|
|
432
586
|
readonly inputs: readonly [];
|
|
433
587
|
}, {
|
|
434
|
-
readonly name: "
|
|
588
|
+
readonly name: "ReductionFactorCannotBeZero";
|
|
435
589
|
readonly type: "error";
|
|
436
590
|
readonly inputs: readonly [];
|
|
437
591
|
}, {
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkI23SLL2Acjs = require('./chunk-I23SLL2A.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -31,7 +31,7 @@ var _viem = require('viem');
|
|
|
31
31
|
function accountActions(client) {
|
|
32
32
|
return {
|
|
33
33
|
fundAccount: async ({ address, amount }) => {
|
|
34
|
-
if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !==
|
|
34
|
+
if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !== _chunkI23SLL2Acjs.localnet.id) {
|
|
35
35
|
throw new Error("Client is not connected to the localnet");
|
|
36
36
|
}
|
|
37
37
|
return client.request({
|
|
@@ -415,8 +415,8 @@ function serialize(data) {
|
|
|
415
415
|
// src/abi/index.ts
|
|
416
416
|
var abi_exports = {};
|
|
417
417
|
_chunk75ZPJI57cjs.__export.call(void 0, abi_exports, {
|
|
418
|
-
STAKING_ABI: () =>
|
|
419
|
-
VALIDATOR_WALLET_ABI: () =>
|
|
418
|
+
STAKING_ABI: () => _chunkI23SLL2Acjs.STAKING_ABI,
|
|
419
|
+
VALIDATOR_WALLET_ABI: () => _chunkI23SLL2Acjs.VALIDATOR_WALLET_ABI,
|
|
420
420
|
calldata: () => calldata,
|
|
421
421
|
transactions: () => transactions
|
|
422
422
|
});
|
|
@@ -516,7 +516,7 @@ function _toJsonSafeDeep(value, seen) {
|
|
|
516
516
|
var contractActions = (client, publicClient) => {
|
|
517
517
|
return {
|
|
518
518
|
getContractCode: async (address) => {
|
|
519
|
-
if (client.chain.id !==
|
|
519
|
+
if (client.chain.id !== _chunkI23SLL2Acjs.localnet.id) {
|
|
520
520
|
throw new Error("Getting contract code is not supported on this network");
|
|
521
521
|
}
|
|
522
522
|
const result = await client.request({
|
|
@@ -527,7 +527,7 @@ var contractActions = (client, publicClient) => {
|
|
|
527
527
|
return new TextDecoder().decode(codeBytes);
|
|
528
528
|
},
|
|
529
529
|
getContractSchema: async (address) => {
|
|
530
|
-
if (client.chain.id !==
|
|
530
|
+
if (client.chain.id !== _chunkI23SLL2Acjs.localnet.id) {
|
|
531
531
|
throw new Error("Contract schema is not supported on this network");
|
|
532
532
|
}
|
|
533
533
|
const schema = await client.request({
|
|
@@ -537,7 +537,7 @@ var contractActions = (client, publicClient) => {
|
|
|
537
537
|
return schema;
|
|
538
538
|
},
|
|
539
539
|
getContractSchemaForCode: async (contractCode) => {
|
|
540
|
-
if (client.chain.id !==
|
|
540
|
+
if (client.chain.id !== _chunkI23SLL2Acjs.localnet.id) {
|
|
541
541
|
throw new Error("Contract schema is not supported on this network");
|
|
542
542
|
}
|
|
543
543
|
const schema = await client.request({
|
|
@@ -1054,7 +1054,7 @@ var receiptActions = (client, publicClient) => ({
|
|
|
1054
1054
|
const requestedStatus = _chunkW4V73RPNcjs.transactionsStatusNameToNumber[status];
|
|
1055
1055
|
if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && _chunkW4V73RPNcjs.isDecidedState.call(void 0, transactionStatusString)) {
|
|
1056
1056
|
let finalTransaction = transaction;
|
|
1057
|
-
if (client.chain.id ===
|
|
1057
|
+
if (client.chain.id === _chunkI23SLL2Acjs.localnet.id) {
|
|
1058
1058
|
finalTransaction = decodeLocalnetTransaction(transaction);
|
|
1059
1059
|
}
|
|
1060
1060
|
if (!fullTransaction) {
|
|
@@ -1119,9 +1119,9 @@ var snapID = {
|
|
|
1119
1119
|
|
|
1120
1120
|
// src/wallet/connect.ts
|
|
1121
1121
|
var networks = {
|
|
1122
|
-
localnet:
|
|
1123
|
-
studionet:
|
|
1124
|
-
testnetAsimov:
|
|
1122
|
+
localnet: _chunkI23SLL2Acjs.localnet,
|
|
1123
|
+
studionet: _chunkI23SLL2Acjs.studionet,
|
|
1124
|
+
testnetAsimov: _chunkI23SLL2Acjs.testnetAsimov
|
|
1125
1125
|
};
|
|
1126
1126
|
var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
1127
1127
|
if (!window.ethereum) {
|
|
@@ -1237,11 +1237,45 @@ function formatStakingAmount(amount) {
|
|
|
1237
1237
|
// src/staking/actions.ts
|
|
1238
1238
|
var FALLBACK_GAS = 1000000n;
|
|
1239
1239
|
var GAS_BUFFER_MULTIPLIER = 2n;
|
|
1240
|
+
var COMBINED_ERROR_ABI = [..._chunkI23SLL2Acjs.STAKING_ABI, ..._chunkI23SLL2Acjs.VALIDATOR_WALLET_ABI];
|
|
1240
1241
|
function extractRevertReason(err) {
|
|
1241
1242
|
if (err instanceof _viem.BaseError) {
|
|
1243
|
+
const rawError = err.walk((e) => e instanceof _viem.RawContractError);
|
|
1244
|
+
if (rawError instanceof _viem.RawContractError && rawError.data && typeof rawError.data === "string") {
|
|
1245
|
+
try {
|
|
1246
|
+
const decoded = _viem.decodeErrorResult.call(void 0, {
|
|
1247
|
+
abi: COMBINED_ERROR_ABI,
|
|
1248
|
+
data: rawError.data
|
|
1249
|
+
});
|
|
1250
|
+
return decoded.errorName;
|
|
1251
|
+
} catch (e2) {
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
let current = err;
|
|
1255
|
+
while (current) {
|
|
1256
|
+
if (current && typeof current === "object") {
|
|
1257
|
+
const obj = current;
|
|
1258
|
+
if (obj.data && typeof obj.data === "string" && obj.data.startsWith("0x")) {
|
|
1259
|
+
try {
|
|
1260
|
+
const decoded = _viem.decodeErrorResult.call(void 0, {
|
|
1261
|
+
abi: COMBINED_ERROR_ABI,
|
|
1262
|
+
data: obj.data
|
|
1263
|
+
});
|
|
1264
|
+
return decoded.errorName;
|
|
1265
|
+
} catch (e3) {
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
current = obj.cause;
|
|
1269
|
+
} else {
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1242
1273
|
const revertError = err.walk((e) => e instanceof _viem.ContractFunctionRevertedError);
|
|
1243
1274
|
if (revertError instanceof _viem.ContractFunctionRevertedError) {
|
|
1244
|
-
|
|
1275
|
+
if (_optionalChain([revertError, 'access', _54 => _54.data, 'optionalAccess', _55 => _55.errorName])) {
|
|
1276
|
+
return revertError.data.errorName;
|
|
1277
|
+
}
|
|
1278
|
+
return revertError.reason || "Unknown reason";
|
|
1245
1279
|
}
|
|
1246
1280
|
if (err.shortMessage) return err.shortMessage;
|
|
1247
1281
|
}
|
|
@@ -1275,7 +1309,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1275
1309
|
value: options.value
|
|
1276
1310
|
});
|
|
1277
1311
|
gasLimit = estimated * GAS_BUFFER_MULTIPLIER;
|
|
1278
|
-
} catch (
|
|
1312
|
+
} catch (e4) {
|
|
1279
1313
|
gasLimit = FALLBACK_GAS;
|
|
1280
1314
|
}
|
|
1281
1315
|
}
|
|
@@ -1335,7 +1369,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1335
1369
|
const address = getStakingAddress();
|
|
1336
1370
|
return _viem.getContract.call(void 0, {
|
|
1337
1371
|
address,
|
|
1338
|
-
abi:
|
|
1372
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1339
1373
|
client: { public: publicClient, wallet: client }
|
|
1340
1374
|
});
|
|
1341
1375
|
};
|
|
@@ -1343,7 +1377,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1343
1377
|
const address = getStakingAddress();
|
|
1344
1378
|
return _viem.getContract.call(void 0, {
|
|
1345
1379
|
address,
|
|
1346
|
-
abi:
|
|
1380
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1347
1381
|
client: publicClient
|
|
1348
1382
|
});
|
|
1349
1383
|
};
|
|
@@ -1352,11 +1386,11 @@ var stakingActions = (client, publicClient) => {
|
|
|
1352
1386
|
const amount = parseStakingAmount(options.amount);
|
|
1353
1387
|
const stakingAddress = getStakingAddress();
|
|
1354
1388
|
const data = options.operator ? _viem.encodeFunctionData.call(void 0, {
|
|
1355
|
-
abi:
|
|
1389
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1356
1390
|
functionName: "validatorJoin",
|
|
1357
1391
|
args: [options.operator]
|
|
1358
1392
|
}) : _viem.encodeFunctionData.call(void 0, {
|
|
1359
|
-
abi:
|
|
1393
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1360
1394
|
functionName: "validatorJoin"
|
|
1361
1395
|
});
|
|
1362
1396
|
const result = await executeWrite({ to: stakingAddress, data, value: amount });
|
|
@@ -1365,13 +1399,13 @@ var stakingActions = (client, publicClient) => {
|
|
|
1365
1399
|
let eventFound = false;
|
|
1366
1400
|
for (const log of receipt.logs) {
|
|
1367
1401
|
try {
|
|
1368
|
-
const decoded = _viem.decodeEventLog.call(void 0, { abi:
|
|
1402
|
+
const decoded = _viem.decodeEventLog.call(void 0, { abi: _chunkI23SLL2Acjs.STAKING_ABI, data: log.data, topics: log.topics });
|
|
1369
1403
|
if (decoded.eventName === "ValidatorJoin") {
|
|
1370
1404
|
validatorWallet = decoded.args.validator;
|
|
1371
1405
|
eventFound = true;
|
|
1372
1406
|
break;
|
|
1373
1407
|
}
|
|
1374
|
-
} catch (
|
|
1408
|
+
} catch (e5) {
|
|
1375
1409
|
}
|
|
1376
1410
|
}
|
|
1377
1411
|
if (!eventFound) {
|
|
@@ -1392,7 +1426,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1392
1426
|
validatorDeposit: async (options) => {
|
|
1393
1427
|
const amount = parseStakingAmount(options.amount);
|
|
1394
1428
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1395
|
-
abi:
|
|
1429
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1396
1430
|
functionName: "validatorDeposit"
|
|
1397
1431
|
});
|
|
1398
1432
|
return executeWrite({ to: getStakingAddress(), data, value: amount });
|
|
@@ -1400,7 +1434,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1400
1434
|
validatorExit: async (options) => {
|
|
1401
1435
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1402
1436
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1403
|
-
abi:
|
|
1437
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1404
1438
|
functionName: "validatorExit",
|
|
1405
1439
|
args: [shares]
|
|
1406
1440
|
});
|
|
@@ -1412,7 +1446,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1412
1446
|
}
|
|
1413
1447
|
const validatorAddress = _optionalChain([options, 'optionalAccess', _58 => _58.validator]) || client.account.address;
|
|
1414
1448
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1415
|
-
abi:
|
|
1449
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1416
1450
|
functionName: "validatorClaim",
|
|
1417
1451
|
args: [validatorAddress]
|
|
1418
1452
|
});
|
|
@@ -1421,7 +1455,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1421
1455
|
},
|
|
1422
1456
|
validatorPrime: async (options) => {
|
|
1423
1457
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1424
|
-
abi:
|
|
1458
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1425
1459
|
functionName: "validatorPrime",
|
|
1426
1460
|
args: [options.validator]
|
|
1427
1461
|
});
|
|
@@ -1429,7 +1463,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1429
1463
|
},
|
|
1430
1464
|
setOperator: async (options) => {
|
|
1431
1465
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1432
|
-
abi:
|
|
1466
|
+
abi: _chunkI23SLL2Acjs.VALIDATOR_WALLET_ABI,
|
|
1433
1467
|
functionName: "setOperator",
|
|
1434
1468
|
args: [options.operator]
|
|
1435
1469
|
});
|
|
@@ -1445,7 +1479,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1445
1479
|
}
|
|
1446
1480
|
}
|
|
1447
1481
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1448
|
-
abi:
|
|
1482
|
+
abi: _chunkI23SLL2Acjs.VALIDATOR_WALLET_ABI,
|
|
1449
1483
|
functionName: "setIdentity",
|
|
1450
1484
|
args: [
|
|
1451
1485
|
options.moniker,
|
|
@@ -1464,7 +1498,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1464
1498
|
delegatorJoin: async (options) => {
|
|
1465
1499
|
const amount = parseStakingAmount(options.amount);
|
|
1466
1500
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1467
|
-
abi:
|
|
1501
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1468
1502
|
functionName: "delegatorJoin",
|
|
1469
1503
|
args: [options.validator]
|
|
1470
1504
|
});
|
|
@@ -1480,7 +1514,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1480
1514
|
delegatorExit: async (options) => {
|
|
1481
1515
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1482
1516
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1483
|
-
abi:
|
|
1517
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1484
1518
|
functionName: "delegatorExit",
|
|
1485
1519
|
args: [options.validator, shares]
|
|
1486
1520
|
});
|
|
@@ -1492,7 +1526,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1492
1526
|
}
|
|
1493
1527
|
const delegatorAddress = options.delegator || client.account.address;
|
|
1494
1528
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1495
|
-
abi:
|
|
1529
|
+
abi: _chunkI23SLL2Acjs.STAKING_ABI,
|
|
1496
1530
|
functionName: "delegatorClaim",
|
|
1497
1531
|
args: [delegatorAddress, options.validator]
|
|
1498
1532
|
});
|
|
@@ -1510,7 +1544,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1510
1544
|
}
|
|
1511
1545
|
const walletContract = _viem.getContract.call(void 0, {
|
|
1512
1546
|
address: validator,
|
|
1513
|
-
abi:
|
|
1547
|
+
abi: _chunkI23SLL2Acjs.VALIDATOR_WALLET_ABI,
|
|
1514
1548
|
client: publicClient
|
|
1515
1549
|
});
|
|
1516
1550
|
const [view, owner, operator, identityRaw, currentEpoch] = await Promise.all([
|
|
@@ -1723,7 +1757,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1723
1757
|
function chainActions(client) {
|
|
1724
1758
|
return {
|
|
1725
1759
|
initializeConsensusSmartContract: async (forceReset = false) => {
|
|
1726
|
-
if (_optionalChain([client, 'access', _59 => _59.chain, 'optionalAccess', _60 => _60.id]) ===
|
|
1760
|
+
if (_optionalChain([client, 'access', _59 => _59.chain, 'optionalAccess', _60 => _60.id]) === _chunkI23SLL2Acjs.testnetAsimov.id) {
|
|
1727
1761
|
return;
|
|
1728
1762
|
}
|
|
1729
1763
|
if (!forceReset && _optionalChain([client, 'access', _61 => _61.chain, 'access', _62 => _62.consensusMainContract, 'optionalAccess', _63 => _63.address]) && _optionalChain([client, 'access', _64 => _64.chain, 'access', _65 => _65.consensusMainContract, 'optionalAccess', _66 => _66.abi])) {
|
|
@@ -1796,8 +1830,8 @@ var getCustomTransportConfig = (config) => {
|
|
|
1796
1830
|
}
|
|
1797
1831
|
};
|
|
1798
1832
|
};
|
|
1799
|
-
var createClient = (config = { chain:
|
|
1800
|
-
const chainConfig = config.chain ||
|
|
1833
|
+
var createClient = (config = { chain: _chunkI23SLL2Acjs.localnet }) => {
|
|
1834
|
+
const chainConfig = config.chain || _chunkI23SLL2Acjs.localnet;
|
|
1801
1835
|
if (config.endpoint) {
|
|
1802
1836
|
chainConfig.rpcUrls.default.http = [config.endpoint];
|
|
1803
1837
|
}
|
|
@@ -1858,4 +1892,4 @@ var createAccount = (accountPrivateKey) => {
|
|
|
1858
1892
|
|
|
1859
1893
|
|
|
1860
1894
|
|
|
1861
|
-
exports.abi = abi_exports; exports.chains =
|
|
1895
|
+
exports.abi = abi_exports; exports.chains = _chunkI23SLL2Acjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.decodeInputData = decodeInputData; exports.decodeLocalnetTransaction = decodeLocalnetTransaction; exports.decodeTransaction = decodeTransaction; exports.formatStakingAmount = formatStakingAmount; exports.generatePrivateKey = generatePrivateKey; exports.parseStakingAmount = parseStakingAmount; exports.simplifyTransactionReceipt = simplifyTransactionReceipt;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account, Address, Hex } from 'viem';
|
|
3
3
|
import { G as GenLayerChain } from './chains-B7B7UXdn.cjs';
|
|
4
|
-
import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI } from './index-
|
|
4
|
+
import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI } from './index-DM646L5c.cjs';
|
|
5
5
|
import * as abitype from 'abitype';
|
|
6
6
|
import * as viem__types_types_authorization from 'viem/_types/types/authorization';
|
|
7
7
|
import * as viem_accounts from 'viem/accounts';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account, Address, Hex } from 'viem';
|
|
3
3
|
import { G as GenLayerChain } from './chains-B7B7UXdn.js';
|
|
4
|
-
import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI } from './index-
|
|
4
|
+
import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI } from './index-9QkkDjYm.js';
|
|
5
5
|
import * as abitype from 'abitype';
|
|
6
6
|
import * as viem__types_types_authorization from 'viem/_types/types/authorization';
|
|
7
7
|
import * as viem_accounts from 'viem/accounts';
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
localnet,
|
|
6
6
|
studionet,
|
|
7
7
|
testnetAsimov
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RW6PLN5W.js";
|
|
9
9
|
import {
|
|
10
10
|
CalldataAddress,
|
|
11
11
|
isDecidedState,
|
|
@@ -1217,7 +1217,7 @@ function walletActions(client) {
|
|
|
1217
1217
|
}
|
|
1218
1218
|
|
|
1219
1219
|
// src/staking/actions.ts
|
|
1220
|
-
import { getContract, decodeEventLog, toHex as toHex4, encodeFunctionData as encodeFunctionData2, BaseError, ContractFunctionRevertedError } from "viem";
|
|
1220
|
+
import { getContract, decodeEventLog, toHex as toHex4, encodeFunctionData as encodeFunctionData2, BaseError, ContractFunctionRevertedError, decodeErrorResult, RawContractError } from "viem";
|
|
1221
1221
|
|
|
1222
1222
|
// src/staking/utils.ts
|
|
1223
1223
|
import { parseEther, formatEther } from "viem";
|
|
@@ -1237,11 +1237,45 @@ function formatStakingAmount(amount) {
|
|
|
1237
1237
|
// src/staking/actions.ts
|
|
1238
1238
|
var FALLBACK_GAS = 1000000n;
|
|
1239
1239
|
var GAS_BUFFER_MULTIPLIER = 2n;
|
|
1240
|
+
var COMBINED_ERROR_ABI = [...STAKING_ABI, ...VALIDATOR_WALLET_ABI];
|
|
1240
1241
|
function extractRevertReason(err) {
|
|
1241
1242
|
if (err instanceof BaseError) {
|
|
1243
|
+
const rawError = err.walk((e) => e instanceof RawContractError);
|
|
1244
|
+
if (rawError instanceof RawContractError && rawError.data && typeof rawError.data === "string") {
|
|
1245
|
+
try {
|
|
1246
|
+
const decoded = decodeErrorResult({
|
|
1247
|
+
abi: COMBINED_ERROR_ABI,
|
|
1248
|
+
data: rawError.data
|
|
1249
|
+
});
|
|
1250
|
+
return decoded.errorName;
|
|
1251
|
+
} catch {
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
let current = err;
|
|
1255
|
+
while (current) {
|
|
1256
|
+
if (current && typeof current === "object") {
|
|
1257
|
+
const obj = current;
|
|
1258
|
+
if (obj.data && typeof obj.data === "string" && obj.data.startsWith("0x")) {
|
|
1259
|
+
try {
|
|
1260
|
+
const decoded = decodeErrorResult({
|
|
1261
|
+
abi: COMBINED_ERROR_ABI,
|
|
1262
|
+
data: obj.data
|
|
1263
|
+
});
|
|
1264
|
+
return decoded.errorName;
|
|
1265
|
+
} catch {
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
current = obj.cause;
|
|
1269
|
+
} else {
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1242
1273
|
const revertError = err.walk((e) => e instanceof ContractFunctionRevertedError);
|
|
1243
1274
|
if (revertError instanceof ContractFunctionRevertedError) {
|
|
1244
|
-
|
|
1275
|
+
if (revertError.data?.errorName) {
|
|
1276
|
+
return revertError.data.errorName;
|
|
1277
|
+
}
|
|
1278
|
+
return revertError.reason || "Unknown reason";
|
|
1245
1279
|
}
|
|
1246
1280
|
if (err.shortMessage) return err.shortMessage;
|
|
1247
1281
|
}
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Account, Address } from 'viem';
|
|
2
|
-
export { I as BannedValidatorInfo, d as CalldataAddress, C as CalldataEncodable, i as ContractMethod, h as ContractMethodBase, f as ContractParamsArraySchemaElement, g as ContractParamsSchema, j as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a3 as DelegatorClaimOptions, a2 as DelegatorExitOptions, a1 as DelegatorJoinOptions, R as DelegatorJoinResult, K as EpochData, L as EpochInfo, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a0 as SetIdentityOptions, $ as SetOperatorOptions, y as SnapSource, J as StakeInfo, a4 as StakingActions, z as StakingContract, O as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, Z as ValidatorClaimOptions, X as ValidatorDepositOptions, Y as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, U as ValidatorJoinOptions, Q as ValidatorJoinResult, _ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-
|
|
2
|
+
export { I as BannedValidatorInfo, d as CalldataAddress, C as CalldataEncodable, i as ContractMethod, h as ContractMethodBase, f as ContractParamsArraySchemaElement, g as ContractParamsSchema, j as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a3 as DelegatorClaimOptions, a2 as DelegatorExitOptions, a1 as DelegatorJoinOptions, R as DelegatorJoinResult, K as EpochData, L as EpochInfo, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a0 as SetIdentityOptions, $ as SetOperatorOptions, y as SnapSource, J as StakeInfo, a4 as StakingActions, z as StakingContract, O as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, Z as ValidatorClaimOptions, X as ValidatorDepositOptions, Y as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, U as ValidatorJoinOptions, Q as ValidatorJoinResult, _ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-DM646L5c.cjs';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-B7B7UXdn.cjs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Account, Address } from 'viem';
|
|
2
|
-
export { I as BannedValidatorInfo, d as CalldataAddress, C as CalldataEncodable, i as ContractMethod, h as ContractMethodBase, f as ContractParamsArraySchemaElement, g as ContractParamsSchema, j as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a3 as DelegatorClaimOptions, a2 as DelegatorExitOptions, a1 as DelegatorJoinOptions, R as DelegatorJoinResult, K as EpochData, L as EpochInfo, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a0 as SetIdentityOptions, $ as SetOperatorOptions, y as SnapSource, J as StakeInfo, a4 as StakingActions, z as StakingContract, O as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, Z as ValidatorClaimOptions, X as ValidatorDepositOptions, Y as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, U as ValidatorJoinOptions, Q as ValidatorJoinResult, _ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-
|
|
2
|
+
export { I as BannedValidatorInfo, d as CalldataAddress, C as CalldataEncodable, i as ContractMethod, h as ContractMethodBase, f as ContractParamsArraySchemaElement, g as ContractParamsSchema, j as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a3 as DelegatorClaimOptions, a2 as DelegatorExitOptions, a1 as DelegatorJoinOptions, R as DelegatorJoinResult, K as EpochData, L as EpochInfo, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a0 as SetIdentityOptions, $ as SetOperatorOptions, y as SnapSource, J as StakeInfo, a4 as StakingActions, z as StakingContract, O as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, Z as ValidatorClaimOptions, X as ValidatorDepositOptions, Y as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, U as ValidatorJoinOptions, Q as ValidatorJoinResult, _ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-9QkkDjYm.js';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-B7B7UXdn.js';
|
package/package.json
CHANGED
package/src/abi/staking.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
// ValidatorWallet ABI for querying and managing validator wallet
|
|
2
2
|
export const VALIDATOR_WALLET_ABI = [
|
|
3
|
+
// Custom errors
|
|
4
|
+
{name: "NotOperator", type: "error", inputs: []},
|
|
5
|
+
{name: "InvalidAddress", type: "error", inputs: []},
|
|
6
|
+
{name: "TransferFailed", type: "error", inputs: []},
|
|
7
|
+
{name: "OperatorTransferNotReady", type: "error", inputs: []},
|
|
8
|
+
{name: "NoPendingOperator", type: "error", inputs: []},
|
|
9
|
+
|
|
10
|
+
// Functions
|
|
3
11
|
{
|
|
4
12
|
name: "operator",
|
|
5
13
|
type: "function",
|
|
@@ -64,19 +72,51 @@ export const VALIDATOR_WALLET_ABI = [
|
|
|
64
72
|
] as const;
|
|
65
73
|
|
|
66
74
|
export const STAKING_ABI = [
|
|
67
|
-
// Custom errors
|
|
68
|
-
{name: "
|
|
69
|
-
{name: "
|
|
70
|
-
{name: "
|
|
71
|
-
{name: "
|
|
72
|
-
{name: "
|
|
73
|
-
{name: "
|
|
74
|
-
{name: "
|
|
75
|
-
{name: "
|
|
76
|
-
{name: "
|
|
77
|
-
{name: "
|
|
78
|
-
{name: "
|
|
79
|
-
{name: "
|
|
75
|
+
// Custom errors from IGenLayerStaking
|
|
76
|
+
{name: "OnlyGEN", type: "error", inputs: []},
|
|
77
|
+
{name: "OnlyTribunal", type: "error", inputs: []},
|
|
78
|
+
{name: "OnlyIdleness", type: "error", inputs: []},
|
|
79
|
+
{name: "OnlyTransactions", type: "error", inputs: []},
|
|
80
|
+
{name: "OnlyIdlenessOrTribunal", type: "error", inputs: []},
|
|
81
|
+
{name: "OnlyTransactionsOrTribunal", type: "error", inputs: []},
|
|
82
|
+
{name: "InvalidAtEpoch", type: "error", inputs: []},
|
|
83
|
+
{name: "MaxValidatorsCannotBeZero", type: "error", inputs: []},
|
|
84
|
+
{name: "ValidatorExitExceedsShares", type: "error", inputs: []},
|
|
85
|
+
{name: "DelegatorExitExceedsShares", type: "error", inputs: []},
|
|
86
|
+
{name: "DelegatorMayNotJoinWithZeroValue", type: "error", inputs: []},
|
|
87
|
+
{name: "DelegatorMayNotJoinTwoValidatorsSimultaneously", type: "error", inputs: []},
|
|
88
|
+
{name: "DelegatorBelowMinimumStake", type: "error", inputs: []},
|
|
89
|
+
{name: "DelegatorExitWouldBeBelowMinimum", type: "error", inputs: []},
|
|
90
|
+
{name: "ValidatorNotActive", type: "error", inputs: []},
|
|
91
|
+
{name: "ValidatorMayNotBeDelegator", type: "error", inputs: []},
|
|
92
|
+
{name: "ValidatorMustNotBeDelegator", type: "error", inputs: []},
|
|
93
|
+
{name: "ValidatorMayNotJoinWithZeroValue", type: "error", inputs: []},
|
|
94
|
+
{name: "ValidatorMayNotDepositZeroValue", type: "error", inputs: []},
|
|
95
|
+
{name: "ValidatorWithdrawalExceedsStake", type: "error", inputs: []},
|
|
96
|
+
{name: "ValidatorAlreadyJoined", type: "error", inputs: []},
|
|
97
|
+
{name: "ValidatorNotJoined", type: "error", inputs: []},
|
|
98
|
+
{name: "ValidatorBelowMinimumStake", type: "error", inputs: []},
|
|
99
|
+
{name: "OperatorAlreadyAssigned", type: "error", inputs: []},
|
|
100
|
+
{name: "InvalidOperatorAddress", type: "error", inputs: []},
|
|
101
|
+
{name: "MaxNumberOfValidatorsReached", type: "error", inputs: []},
|
|
102
|
+
{name: "ValidatorsConsumed", type: "error", inputs: []},
|
|
103
|
+
{name: "ValidatorsUnavailable", type: "error", inputs: []},
|
|
104
|
+
{name: "EpochNotFinished", type: "error", inputs: []},
|
|
105
|
+
{name: "EpochNotFinalized", type: "error", inputs: []},
|
|
106
|
+
{name: "InflationInvalidAmount", type: "error", inputs: []},
|
|
107
|
+
{name: "InflationAlreadyReceived", type: "error", inputs: []},
|
|
108
|
+
{name: "InflationAlreadyInitialized", type: "error", inputs: []},
|
|
109
|
+
{name: "EpochAlreadyFinalized", type: "error", inputs: []},
|
|
110
|
+
{name: "PendingTribunals", type: "error", inputs: [{name: "epoch", type: "uint256"}]},
|
|
111
|
+
{name: "FailedTransfer", type: "error", inputs: [{name: "validator", type: "address"}]},
|
|
112
|
+
{name: "NFTMinterCallFailed", type: "error", inputs: []},
|
|
113
|
+
{name: "DeepthoughtCallFailed", type: "error", inputs: []},
|
|
114
|
+
{name: "NFTMinterNotConfigured", type: "error", inputs: []},
|
|
115
|
+
{name: "NumberOfValidatorsExceedsAvailable", type: "error", inputs: []},
|
|
116
|
+
{name: "EpochAdvanceNotReady", type: "error", inputs: []},
|
|
117
|
+
{name: "PreviousEpochNotFinalizable", type: "error", inputs: []},
|
|
118
|
+
{name: "NoBurning", type: "error", inputs: []},
|
|
119
|
+
{name: "ReductionFactorCannotBeZero", type: "error", inputs: []},
|
|
80
120
|
|
|
81
121
|
// Validator functions
|
|
82
122
|
{
|
package/src/staking/actions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {getContract, decodeEventLog, PublicClient, Client, Transport, Chain, Account, Address as ViemAddress, GetContractReturnType, toHex, encodeFunctionData, BaseError, ContractFunctionRevertedError} from "viem";
|
|
1
|
+
import {getContract, decodeEventLog, PublicClient, Client, Transport, Chain, Account, Address as ViemAddress, GetContractReturnType, toHex, encodeFunctionData, BaseError, ContractFunctionRevertedError, decodeErrorResult, RawContractError} from "viem";
|
|
2
2
|
import {GenLayerClient, GenLayerChain, Address} from "@/types";
|
|
3
3
|
import {STAKING_ABI, VALIDATOR_WALLET_ABI} from "@/abi/staking";
|
|
4
4
|
import {parseStakingAmount, formatStakingAmount} from "./utils";
|
|
@@ -32,11 +32,55 @@ type WalletClientWithAccount = Client<Transport, Chain, Account>;
|
|
|
32
32
|
const FALLBACK_GAS = 1000000n;
|
|
33
33
|
const GAS_BUFFER_MULTIPLIER = 2n;
|
|
34
34
|
|
|
35
|
+
// Combined ABI for error decoding (both staking and validator wallet errors)
|
|
36
|
+
const COMBINED_ERROR_ABI = [...STAKING_ABI, ...VALIDATOR_WALLET_ABI];
|
|
37
|
+
|
|
35
38
|
function extractRevertReason(err: unknown): string {
|
|
36
39
|
if (err instanceof BaseError) {
|
|
40
|
+
// Try to find raw error data and decode it with our ABI
|
|
41
|
+
const rawError = err.walk((e) => e instanceof RawContractError);
|
|
42
|
+
if (rawError instanceof RawContractError && rawError.data && typeof rawError.data === "string") {
|
|
43
|
+
try {
|
|
44
|
+
const decoded = decodeErrorResult({
|
|
45
|
+
abi: COMBINED_ERROR_ABI,
|
|
46
|
+
data: rawError.data as `0x${string}`,
|
|
47
|
+
});
|
|
48
|
+
return decoded.errorName;
|
|
49
|
+
} catch {
|
|
50
|
+
// Fall through to other methods
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Try to extract error data from the cause chain
|
|
55
|
+
let current: unknown = err;
|
|
56
|
+
while (current) {
|
|
57
|
+
if (current && typeof current === "object") {
|
|
58
|
+
const obj = current as Record<string, unknown>;
|
|
59
|
+
// Check for data property that looks like hex error data
|
|
60
|
+
if (obj.data && typeof obj.data === "string" && obj.data.startsWith("0x")) {
|
|
61
|
+
try {
|
|
62
|
+
const decoded = decodeErrorResult({
|
|
63
|
+
abi: COMBINED_ERROR_ABI,
|
|
64
|
+
data: obj.data as `0x${string}`,
|
|
65
|
+
});
|
|
66
|
+
return decoded.errorName;
|
|
67
|
+
} catch {
|
|
68
|
+
// Continue searching
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
current = obj.cause;
|
|
72
|
+
} else {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
37
77
|
const revertError = err.walk((e) => e instanceof ContractFunctionRevertedError);
|
|
38
78
|
if (revertError instanceof ContractFunctionRevertedError) {
|
|
39
|
-
|
|
79
|
+
// If viem already decoded it, use that
|
|
80
|
+
if (revertError.data?.errorName) {
|
|
81
|
+
return revertError.data.errorName;
|
|
82
|
+
}
|
|
83
|
+
return revertError.reason || "Unknown reason";
|
|
40
84
|
}
|
|
41
85
|
if (err.shortMessage) return err.shortMessage;
|
|
42
86
|
}
|