genlayer-js 0.18.6 → 0.18.8
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 +9 -0
- package/dist/chains/index.cjs +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/{chunk-KVHGQTAI.js → chunk-V4ZFI4GV.js} +113 -13
- package/dist/{chunk-QAAO2WJL.cjs → chunk-WTAFQOXC.cjs} +113 -13
- package/dist/{index-BBh1NZjP.d.ts → index-BNui_XYa.d.ts} +229 -12
- package/dist/{index-3leEwFoq.d.cts → index-C3KT8eu_.d.cts} +229 -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 +114 -13
- package/src/staking/actions.ts +46 -2
|
@@ -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";
|
|
@@ -385,53 +405,250 @@ declare const VALIDATOR_WALLET_ABI: readonly [{
|
|
|
385
405
|
readonly type: "bytes";
|
|
386
406
|
}];
|
|
387
407
|
readonly outputs: readonly [];
|
|
408
|
+
}, {
|
|
409
|
+
readonly name: "validatorDeposit";
|
|
410
|
+
readonly type: "function";
|
|
411
|
+
readonly stateMutability: "payable";
|
|
412
|
+
readonly inputs: readonly [];
|
|
413
|
+
readonly outputs: readonly [];
|
|
414
|
+
}, {
|
|
415
|
+
readonly name: "validatorExit";
|
|
416
|
+
readonly type: "function";
|
|
417
|
+
readonly stateMutability: "nonpayable";
|
|
418
|
+
readonly inputs: readonly [{
|
|
419
|
+
readonly name: "_shares";
|
|
420
|
+
readonly type: "uint256";
|
|
421
|
+
}];
|
|
422
|
+
readonly outputs: readonly [];
|
|
423
|
+
}, {
|
|
424
|
+
readonly name: "validatorClaim";
|
|
425
|
+
readonly type: "function";
|
|
426
|
+
readonly stateMutability: "nonpayable";
|
|
427
|
+
readonly inputs: readonly [];
|
|
428
|
+
readonly outputs: readonly [];
|
|
429
|
+
}, {
|
|
430
|
+
readonly name: "initiateOperatorTransfer";
|
|
431
|
+
readonly type: "function";
|
|
432
|
+
readonly stateMutability: "nonpayable";
|
|
433
|
+
readonly inputs: readonly [{
|
|
434
|
+
readonly name: "_newOperator";
|
|
435
|
+
readonly type: "address";
|
|
436
|
+
}];
|
|
437
|
+
readonly outputs: readonly [];
|
|
438
|
+
}, {
|
|
439
|
+
readonly name: "completeOperatorTransfer";
|
|
440
|
+
readonly type: "function";
|
|
441
|
+
readonly stateMutability: "nonpayable";
|
|
442
|
+
readonly inputs: readonly [];
|
|
443
|
+
readonly outputs: readonly [];
|
|
444
|
+
}, {
|
|
445
|
+
readonly name: "cancelOperatorTransfer";
|
|
446
|
+
readonly type: "function";
|
|
447
|
+
readonly stateMutability: "nonpayable";
|
|
448
|
+
readonly inputs: readonly [];
|
|
449
|
+
readonly outputs: readonly [];
|
|
450
|
+
}, {
|
|
451
|
+
readonly name: "getPendingOperator";
|
|
452
|
+
readonly type: "function";
|
|
453
|
+
readonly stateMutability: "view";
|
|
454
|
+
readonly inputs: readonly [];
|
|
455
|
+
readonly outputs: readonly [{
|
|
456
|
+
readonly name: "";
|
|
457
|
+
readonly type: "address";
|
|
458
|
+
}, {
|
|
459
|
+
readonly name: "";
|
|
460
|
+
readonly type: "uint256";
|
|
461
|
+
}];
|
|
462
|
+
}, {
|
|
463
|
+
readonly name: "getOperator";
|
|
464
|
+
readonly type: "function";
|
|
465
|
+
readonly stateMutability: "view";
|
|
466
|
+
readonly inputs: readonly [];
|
|
467
|
+
readonly outputs: readonly [{
|
|
468
|
+
readonly name: "";
|
|
469
|
+
readonly type: "address";
|
|
470
|
+
}];
|
|
388
471
|
}];
|
|
389
472
|
declare const STAKING_ABI: readonly [{
|
|
390
|
-
readonly name: "
|
|
473
|
+
readonly name: "OnlyGEN";
|
|
391
474
|
readonly type: "error";
|
|
392
475
|
readonly inputs: readonly [];
|
|
393
476
|
}, {
|
|
394
|
-
readonly name: "
|
|
477
|
+
readonly name: "OnlyTribunal";
|
|
395
478
|
readonly type: "error";
|
|
396
479
|
readonly inputs: readonly [];
|
|
397
480
|
}, {
|
|
398
|
-
readonly name: "
|
|
481
|
+
readonly name: "OnlyIdleness";
|
|
399
482
|
readonly type: "error";
|
|
400
483
|
readonly inputs: readonly [];
|
|
401
484
|
}, {
|
|
402
|
-
readonly name: "
|
|
485
|
+
readonly name: "OnlyTransactions";
|
|
403
486
|
readonly type: "error";
|
|
404
487
|
readonly inputs: readonly [];
|
|
405
488
|
}, {
|
|
406
|
-
readonly name: "
|
|
489
|
+
readonly name: "OnlyIdlenessOrTribunal";
|
|
490
|
+
readonly type: "error";
|
|
491
|
+
readonly inputs: readonly [];
|
|
492
|
+
}, {
|
|
493
|
+
readonly name: "OnlyTransactionsOrTribunal";
|
|
494
|
+
readonly type: "error";
|
|
495
|
+
readonly inputs: readonly [];
|
|
496
|
+
}, {
|
|
497
|
+
readonly name: "InvalidAtEpoch";
|
|
498
|
+
readonly type: "error";
|
|
499
|
+
readonly inputs: readonly [];
|
|
500
|
+
}, {
|
|
501
|
+
readonly name: "MaxValidatorsCannotBeZero";
|
|
502
|
+
readonly type: "error";
|
|
503
|
+
readonly inputs: readonly [];
|
|
504
|
+
}, {
|
|
505
|
+
readonly name: "ValidatorExitExceedsShares";
|
|
506
|
+
readonly type: "error";
|
|
507
|
+
readonly inputs: readonly [];
|
|
508
|
+
}, {
|
|
509
|
+
readonly name: "DelegatorExitExceedsShares";
|
|
510
|
+
readonly type: "error";
|
|
511
|
+
readonly inputs: readonly [];
|
|
512
|
+
}, {
|
|
513
|
+
readonly name: "DelegatorMayNotJoinWithZeroValue";
|
|
514
|
+
readonly type: "error";
|
|
515
|
+
readonly inputs: readonly [];
|
|
516
|
+
}, {
|
|
517
|
+
readonly name: "DelegatorMayNotJoinTwoValidatorsSimultaneously";
|
|
518
|
+
readonly type: "error";
|
|
519
|
+
readonly inputs: readonly [];
|
|
520
|
+
}, {
|
|
521
|
+
readonly name: "DelegatorBelowMinimumStake";
|
|
522
|
+
readonly type: "error";
|
|
523
|
+
readonly inputs: readonly [];
|
|
524
|
+
}, {
|
|
525
|
+
readonly name: "DelegatorExitWouldBeBelowMinimum";
|
|
526
|
+
readonly type: "error";
|
|
527
|
+
readonly inputs: readonly [];
|
|
528
|
+
}, {
|
|
529
|
+
readonly name: "ValidatorNotActive";
|
|
530
|
+
readonly type: "error";
|
|
531
|
+
readonly inputs: readonly [];
|
|
532
|
+
}, {
|
|
533
|
+
readonly name: "ValidatorMayNotBeDelegator";
|
|
534
|
+
readonly type: "error";
|
|
535
|
+
readonly inputs: readonly [];
|
|
536
|
+
}, {
|
|
537
|
+
readonly name: "ValidatorMustNotBeDelegator";
|
|
538
|
+
readonly type: "error";
|
|
539
|
+
readonly inputs: readonly [];
|
|
540
|
+
}, {
|
|
541
|
+
readonly name: "ValidatorMayNotJoinWithZeroValue";
|
|
542
|
+
readonly type: "error";
|
|
543
|
+
readonly inputs: readonly [];
|
|
544
|
+
}, {
|
|
545
|
+
readonly name: "ValidatorMayNotDepositZeroValue";
|
|
546
|
+
readonly type: "error";
|
|
547
|
+
readonly inputs: readonly [];
|
|
548
|
+
}, {
|
|
549
|
+
readonly name: "ValidatorWithdrawalExceedsStake";
|
|
550
|
+
readonly type: "error";
|
|
551
|
+
readonly inputs: readonly [];
|
|
552
|
+
}, {
|
|
553
|
+
readonly name: "ValidatorAlreadyJoined";
|
|
554
|
+
readonly type: "error";
|
|
555
|
+
readonly inputs: readonly [];
|
|
556
|
+
}, {
|
|
557
|
+
readonly name: "ValidatorNotJoined";
|
|
558
|
+
readonly type: "error";
|
|
559
|
+
readonly inputs: readonly [];
|
|
560
|
+
}, {
|
|
561
|
+
readonly name: "ValidatorBelowMinimumStake";
|
|
562
|
+
readonly type: "error";
|
|
563
|
+
readonly inputs: readonly [];
|
|
564
|
+
}, {
|
|
565
|
+
readonly name: "OperatorAlreadyAssigned";
|
|
566
|
+
readonly type: "error";
|
|
567
|
+
readonly inputs: readonly [];
|
|
568
|
+
}, {
|
|
569
|
+
readonly name: "InvalidOperatorAddress";
|
|
570
|
+
readonly type: "error";
|
|
571
|
+
readonly inputs: readonly [];
|
|
572
|
+
}, {
|
|
573
|
+
readonly name: "MaxNumberOfValidatorsReached";
|
|
574
|
+
readonly type: "error";
|
|
575
|
+
readonly inputs: readonly [];
|
|
576
|
+
}, {
|
|
577
|
+
readonly name: "ValidatorsConsumed";
|
|
578
|
+
readonly type: "error";
|
|
579
|
+
readonly inputs: readonly [];
|
|
580
|
+
}, {
|
|
581
|
+
readonly name: "ValidatorsUnavailable";
|
|
582
|
+
readonly type: "error";
|
|
583
|
+
readonly inputs: readonly [];
|
|
584
|
+
}, {
|
|
585
|
+
readonly name: "EpochNotFinished";
|
|
586
|
+
readonly type: "error";
|
|
587
|
+
readonly inputs: readonly [];
|
|
588
|
+
}, {
|
|
589
|
+
readonly name: "EpochNotFinalized";
|
|
590
|
+
readonly type: "error";
|
|
591
|
+
readonly inputs: readonly [];
|
|
592
|
+
}, {
|
|
593
|
+
readonly name: "InflationInvalidAmount";
|
|
594
|
+
readonly type: "error";
|
|
595
|
+
readonly inputs: readonly [];
|
|
596
|
+
}, {
|
|
597
|
+
readonly name: "InflationAlreadyReceived";
|
|
598
|
+
readonly type: "error";
|
|
599
|
+
readonly inputs: readonly [];
|
|
600
|
+
}, {
|
|
601
|
+
readonly name: "InflationAlreadyInitialized";
|
|
602
|
+
readonly type: "error";
|
|
603
|
+
readonly inputs: readonly [];
|
|
604
|
+
}, {
|
|
605
|
+
readonly name: "EpochAlreadyFinalized";
|
|
606
|
+
readonly type: "error";
|
|
607
|
+
readonly inputs: readonly [];
|
|
608
|
+
}, {
|
|
609
|
+
readonly name: "PendingTribunals";
|
|
610
|
+
readonly type: "error";
|
|
611
|
+
readonly inputs: readonly [{
|
|
612
|
+
readonly name: "epoch";
|
|
613
|
+
readonly type: "uint256";
|
|
614
|
+
}];
|
|
615
|
+
}, {
|
|
616
|
+
readonly name: "FailedTransfer";
|
|
617
|
+
readonly type: "error";
|
|
618
|
+
readonly inputs: readonly [{
|
|
619
|
+
readonly name: "validator";
|
|
620
|
+
readonly type: "address";
|
|
621
|
+
}];
|
|
622
|
+
}, {
|
|
623
|
+
readonly name: "NFTMinterCallFailed";
|
|
407
624
|
readonly type: "error";
|
|
408
625
|
readonly inputs: readonly [];
|
|
409
626
|
}, {
|
|
410
|
-
readonly name: "
|
|
627
|
+
readonly name: "DeepthoughtCallFailed";
|
|
411
628
|
readonly type: "error";
|
|
412
629
|
readonly inputs: readonly [];
|
|
413
630
|
}, {
|
|
414
|
-
readonly name: "
|
|
631
|
+
readonly name: "NFTMinterNotConfigured";
|
|
415
632
|
readonly type: "error";
|
|
416
633
|
readonly inputs: readonly [];
|
|
417
634
|
}, {
|
|
418
|
-
readonly name: "
|
|
635
|
+
readonly name: "NumberOfValidatorsExceedsAvailable";
|
|
419
636
|
readonly type: "error";
|
|
420
637
|
readonly inputs: readonly [];
|
|
421
638
|
}, {
|
|
422
|
-
readonly name: "
|
|
639
|
+
readonly name: "EpochAdvanceNotReady";
|
|
423
640
|
readonly type: "error";
|
|
424
641
|
readonly inputs: readonly [];
|
|
425
642
|
}, {
|
|
426
|
-
readonly name: "
|
|
643
|
+
readonly name: "PreviousEpochNotFinalizable";
|
|
427
644
|
readonly type: "error";
|
|
428
645
|
readonly inputs: readonly [];
|
|
429
646
|
}, {
|
|
430
|
-
readonly name: "
|
|
647
|
+
readonly name: "NoBurning";
|
|
431
648
|
readonly type: "error";
|
|
432
649
|
readonly inputs: readonly [];
|
|
433
650
|
}, {
|
|
434
|
-
readonly name: "
|
|
651
|
+
readonly name: "ReductionFactorCannotBeZero";
|
|
435
652
|
readonly type: "error";
|
|
436
653
|
readonly inputs: readonly [];
|
|
437
654
|
}, {
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkWTAFQOXCcjs = require('./chunk-WTAFQOXC.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]) !== _chunkWTAFQOXCcjs.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: () => _chunkWTAFQOXCcjs.STAKING_ABI,
|
|
419
|
+
VALIDATOR_WALLET_ABI: () => _chunkWTAFQOXCcjs.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 !== _chunkWTAFQOXCcjs.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 !== _chunkWTAFQOXCcjs.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 !== _chunkWTAFQOXCcjs.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 === _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.localnet,
|
|
1123
|
+
studionet: _chunkWTAFQOXCcjs.studionet,
|
|
1124
|
+
testnetAsimov: _chunkWTAFQOXCcjs.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 = [..._chunkWTAFQOXCcjs.STAKING_ABI, ..._chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.STAKING_ABI,
|
|
1356
1390
|
functionName: "validatorJoin",
|
|
1357
1391
|
args: [options.operator]
|
|
1358
1392
|
}) : _viem.encodeFunctionData.call(void 0, {
|
|
1359
|
-
abi:
|
|
1393
|
+
abi: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.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]) === _chunkWTAFQOXCcjs.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: _chunkWTAFQOXCcjs.localnet }) => {
|
|
1834
|
+
const chainConfig = config.chain || _chunkWTAFQOXCcjs.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 = _chunkWTAFQOXCcjs.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-C3KT8eu_.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-BNui_XYa.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-V4ZFI4GV.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-C3KT8eu_.cjs';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-B7B7UXdn.cjs';
|