genlayer-js 0.18.9 → 0.18.11
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/.eslintignore +2 -1
- package/.github/workflows/publish.yml +73 -16
- package/.github/workflows/smoke.yml +27 -0
- package/.release-it.json +3 -1
- package/CHANGELOG.md +4 -0
- package/dist/chains/index.cjs +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/{chunk-SC2VXHL3.cjs → chunk-5TKVNHAO.cjs} +1124 -309
- package/dist/{chunk-V3MYVW3P.js → chunk-NOFMB7RP.js} +1124 -309
- package/dist/{index-D9ONjYgl.d.cts → index-DsN7LGHA.d.cts} +1615 -459
- package/dist/{index-ZDqJWXj0.d.ts → index-sw3NAvBf.d.ts} +1615 -459
- package/dist/index.cjs +58 -58
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -28
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +6 -1
- package/src/abi/staking.ts +1111 -297
- package/src/chains/testnetAsimov.ts +6 -4
- package/src/staking/actions.ts +29 -30
- package/src/types/staking.ts +0 -5
- package/tests/smoke.test.ts +291 -0
- package/vitest.config.ts +1 -0
- package/vitest.smoke.config.ts +16 -0
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk5TKVNHAOcjs = require('./chunk-5TKVNHAO.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]) !== _chunk5TKVNHAOcjs.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: () => _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
419
|
+
VALIDATOR_WALLET_ABI: () => _chunk5TKVNHAOcjs.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 !== _chunk5TKVNHAOcjs.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 !== _chunk5TKVNHAOcjs.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 !== _chunk5TKVNHAOcjs.localnet.id) {
|
|
541
541
|
throw new Error("Contract schema is not supported on this network");
|
|
542
542
|
}
|
|
543
543
|
const schema = await client.request({
|
|
@@ -1068,7 +1068,7 @@ var receiptActions = (client, publicClient) => ({
|
|
|
1068
1068
|
const requestedStatus = _chunkW4V73RPNcjs.transactionsStatusNameToNumber[status];
|
|
1069
1069
|
if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && _chunkW4V73RPNcjs.isDecidedState.call(void 0, transactionStatusString)) {
|
|
1070
1070
|
let finalTransaction = transaction;
|
|
1071
|
-
if (client.chain.id ===
|
|
1071
|
+
if (client.chain.id === _chunk5TKVNHAOcjs.localnet.id) {
|
|
1072
1072
|
finalTransaction = decodeLocalnetTransaction(transaction);
|
|
1073
1073
|
}
|
|
1074
1074
|
if (!fullTransaction) {
|
|
@@ -1133,9 +1133,9 @@ var snapID = {
|
|
|
1133
1133
|
|
|
1134
1134
|
// src/wallet/connect.ts
|
|
1135
1135
|
var networks = {
|
|
1136
|
-
localnet:
|
|
1137
|
-
studionet:
|
|
1138
|
-
testnetAsimov:
|
|
1136
|
+
localnet: _chunk5TKVNHAOcjs.localnet,
|
|
1137
|
+
studionet: _chunk5TKVNHAOcjs.studionet,
|
|
1138
|
+
testnetAsimov: _chunk5TKVNHAOcjs.testnetAsimov
|
|
1139
1139
|
};
|
|
1140
1140
|
var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
1141
1141
|
if (!window.ethereum) {
|
|
@@ -1251,7 +1251,7 @@ function formatStakingAmount(amount) {
|
|
|
1251
1251
|
// src/staking/actions.ts
|
|
1252
1252
|
var FALLBACK_GAS = 1000000n;
|
|
1253
1253
|
var GAS_BUFFER_MULTIPLIER = 2n;
|
|
1254
|
-
var COMBINED_ERROR_ABI = [...
|
|
1254
|
+
var COMBINED_ERROR_ABI = [..._chunk5TKVNHAOcjs.STAKING_ABI, ..._chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI];
|
|
1255
1255
|
function extractRevertReason(err) {
|
|
1256
1256
|
if (err instanceof _viem.BaseError) {
|
|
1257
1257
|
const rawError = err.walk((e) => e instanceof _viem.RawContractError);
|
|
@@ -1383,7 +1383,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1383
1383
|
const address = getStakingAddress();
|
|
1384
1384
|
return _viem.getContract.call(void 0, {
|
|
1385
1385
|
address,
|
|
1386
|
-
abi:
|
|
1386
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1387
1387
|
client: { public: publicClient, wallet: client }
|
|
1388
1388
|
});
|
|
1389
1389
|
};
|
|
@@ -1391,7 +1391,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1391
1391
|
const address = getStakingAddress();
|
|
1392
1392
|
return _viem.getContract.call(void 0, {
|
|
1393
1393
|
address,
|
|
1394
|
-
abi:
|
|
1394
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1395
1395
|
client: publicClient
|
|
1396
1396
|
});
|
|
1397
1397
|
};
|
|
@@ -1400,11 +1400,11 @@ var stakingActions = (client, publicClient) => {
|
|
|
1400
1400
|
const amount = parseStakingAmount(options.amount);
|
|
1401
1401
|
const stakingAddress = getStakingAddress();
|
|
1402
1402
|
const data = options.operator ? _viem.encodeFunctionData.call(void 0, {
|
|
1403
|
-
abi:
|
|
1403
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1404
1404
|
functionName: "validatorJoin",
|
|
1405
1405
|
args: [options.operator]
|
|
1406
1406
|
}) : _viem.encodeFunctionData.call(void 0, {
|
|
1407
|
-
abi:
|
|
1407
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1408
1408
|
functionName: "validatorJoin"
|
|
1409
1409
|
});
|
|
1410
1410
|
const result = await executeWrite({ to: stakingAddress, data, value: amount });
|
|
@@ -1413,7 +1413,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1413
1413
|
let eventFound = false;
|
|
1414
1414
|
for (const log of receipt.logs) {
|
|
1415
1415
|
try {
|
|
1416
|
-
const decoded = _viem.decodeEventLog.call(void 0, { abi:
|
|
1416
|
+
const decoded = _viem.decodeEventLog.call(void 0, { abi: _chunk5TKVNHAOcjs.STAKING_ABI, data: log.data, topics: log.topics });
|
|
1417
1417
|
if (decoded.eventName === "ValidatorJoin") {
|
|
1418
1418
|
validatorWallet = decoded.args.validator;
|
|
1419
1419
|
eventFound = true;
|
|
@@ -1440,7 +1440,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1440
1440
|
validatorDeposit: async (options) => {
|
|
1441
1441
|
const amount = parseStakingAmount(options.amount);
|
|
1442
1442
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1443
|
-
abi:
|
|
1443
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1444
1444
|
functionName: "validatorDeposit"
|
|
1445
1445
|
});
|
|
1446
1446
|
return executeWrite({ to: getStakingAddress(), data, value: amount });
|
|
@@ -1448,7 +1448,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1448
1448
|
validatorExit: async (options) => {
|
|
1449
1449
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1450
1450
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1451
|
-
abi:
|
|
1451
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1452
1452
|
functionName: "validatorExit",
|
|
1453
1453
|
args: [shares]
|
|
1454
1454
|
});
|
|
@@ -1460,7 +1460,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1460
1460
|
}
|
|
1461
1461
|
const validatorAddress = _optionalChain([options, 'optionalAccess', _61 => _61.validator]) || client.account.address;
|
|
1462
1462
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1463
|
-
abi:
|
|
1463
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1464
1464
|
functionName: "validatorClaim",
|
|
1465
1465
|
args: [validatorAddress]
|
|
1466
1466
|
});
|
|
@@ -1469,7 +1469,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1469
1469
|
},
|
|
1470
1470
|
validatorPrime: async (options) => {
|
|
1471
1471
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1472
|
-
abi:
|
|
1472
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1473
1473
|
functionName: "validatorPrime",
|
|
1474
1474
|
args: [options.validator]
|
|
1475
1475
|
});
|
|
@@ -1477,7 +1477,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1477
1477
|
},
|
|
1478
1478
|
setOperator: async (options) => {
|
|
1479
1479
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1480
|
-
abi:
|
|
1480
|
+
abi: _chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI,
|
|
1481
1481
|
functionName: "setOperator",
|
|
1482
1482
|
args: [options.operator]
|
|
1483
1483
|
});
|
|
@@ -1493,7 +1493,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
1495
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1496
|
-
abi:
|
|
1496
|
+
abi: _chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI,
|
|
1497
1497
|
functionName: "setIdentity",
|
|
1498
1498
|
args: [
|
|
1499
1499
|
options.moniker,
|
|
@@ -1512,7 +1512,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1512
1512
|
delegatorJoin: async (options) => {
|
|
1513
1513
|
const amount = parseStakingAmount(options.amount);
|
|
1514
1514
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1515
|
-
abi:
|
|
1515
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1516
1516
|
functionName: "delegatorJoin",
|
|
1517
1517
|
args: [options.validator]
|
|
1518
1518
|
});
|
|
@@ -1528,7 +1528,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1528
1528
|
delegatorExit: async (options) => {
|
|
1529
1529
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1530
1530
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1531
|
-
abi:
|
|
1531
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1532
1532
|
functionName: "delegatorExit",
|
|
1533
1533
|
args: [options.validator, shares]
|
|
1534
1534
|
});
|
|
@@ -1540,7 +1540,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1540
1540
|
}
|
|
1541
1541
|
const delegatorAddress = options.delegator || client.account.address;
|
|
1542
1542
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1543
|
-
abi:
|
|
1543
|
+
abi: _chunk5TKVNHAOcjs.STAKING_ABI,
|
|
1544
1544
|
functionName: "delegatorClaim",
|
|
1545
1545
|
args: [delegatorAddress, options.validator]
|
|
1546
1546
|
});
|
|
@@ -1558,7 +1558,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1558
1558
|
}
|
|
1559
1559
|
const walletContract = _viem.getContract.call(void 0, {
|
|
1560
1560
|
address: validator,
|
|
1561
|
-
abi:
|
|
1561
|
+
abi: _chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI,
|
|
1562
1562
|
client: publicClient
|
|
1563
1563
|
});
|
|
1564
1564
|
const [view, owner, operator, identityRaw, currentEpoch] = await Promise.all([
|
|
@@ -1687,8 +1687,6 @@ var stakingActions = (client, publicClient) => {
|
|
|
1687
1687
|
const [
|
|
1688
1688
|
epoch,
|
|
1689
1689
|
finalized,
|
|
1690
|
-
validatorMinStake,
|
|
1691
|
-
delegatorMinStake,
|
|
1692
1690
|
activeCount,
|
|
1693
1691
|
epochMinDuration,
|
|
1694
1692
|
epochZeroMinDuration,
|
|
@@ -1697,15 +1695,26 @@ var stakingActions = (client, publicClient) => {
|
|
|
1697
1695
|
] = await Promise.all([
|
|
1698
1696
|
contract.read.epoch(),
|
|
1699
1697
|
contract.read.finalized(),
|
|
1700
|
-
contract.read.validatorMinStake(),
|
|
1701
|
-
contract.read.delegatorMinStake(),
|
|
1702
1698
|
contract.read.activeValidatorsCount(),
|
|
1703
1699
|
contract.read.epochMinDuration(),
|
|
1704
1700
|
contract.read.epochZeroMinDuration(),
|
|
1705
1701
|
contract.read.epochOdd(),
|
|
1706
1702
|
contract.read.epochEven()
|
|
1707
1703
|
]);
|
|
1708
|
-
const
|
|
1704
|
+
const raw = epoch % 2n === 0n ? epochEven : epochOdd;
|
|
1705
|
+
const currentEpochData = {
|
|
1706
|
+
start: raw[0],
|
|
1707
|
+
end: raw[1],
|
|
1708
|
+
inflation: raw[2],
|
|
1709
|
+
weight: raw[3],
|
|
1710
|
+
weightDeposit: raw[4],
|
|
1711
|
+
weightWithdrawal: raw[5],
|
|
1712
|
+
vcount: raw[6],
|
|
1713
|
+
claimed: raw[7],
|
|
1714
|
+
stakeDeposit: raw[8],
|
|
1715
|
+
stakeWithdrawal: raw[9],
|
|
1716
|
+
slashed: raw[10]
|
|
1717
|
+
};
|
|
1709
1718
|
const currentEpochEnd = currentEpochData.end > 0n;
|
|
1710
1719
|
let nextEpochEstimate = null;
|
|
1711
1720
|
if (!currentEpochEnd) {
|
|
@@ -1716,10 +1725,6 @@ var stakingActions = (client, publicClient) => {
|
|
|
1716
1725
|
return {
|
|
1717
1726
|
currentEpoch: epoch,
|
|
1718
1727
|
lastFinalizedEpoch: finalized,
|
|
1719
|
-
validatorMinStake: formatStakingAmount(validatorMinStake),
|
|
1720
|
-
validatorMinStakeRaw: validatorMinStake,
|
|
1721
|
-
delegatorMinStake: formatStakingAmount(delegatorMinStake),
|
|
1722
|
-
delegatorMinStakeRaw: delegatorMinStake,
|
|
1723
1728
|
activeValidatorsCount: activeCount,
|
|
1724
1729
|
epochMinDuration,
|
|
1725
1730
|
nextEpochEstimate
|
|
@@ -1738,19 +1743,19 @@ var stakingActions = (client, publicClient) => {
|
|
|
1738
1743
|
if (epochNumber < currentEpoch - 1n && currentEpoch > 0n) {
|
|
1739
1744
|
throw new Error(`Epoch ${epochNumber} data no longer available (only current and previous epoch stored)`);
|
|
1740
1745
|
}
|
|
1741
|
-
const
|
|
1746
|
+
const raw = epochNumber % 2n === 0n ? epochEven : epochOdd;
|
|
1742
1747
|
return {
|
|
1743
|
-
start:
|
|
1744
|
-
end:
|
|
1745
|
-
inflation:
|
|
1746
|
-
weight:
|
|
1747
|
-
weightDeposit:
|
|
1748
|
-
weightWithdrawal:
|
|
1749
|
-
vcount:
|
|
1750
|
-
claimed:
|
|
1751
|
-
stakeDeposit:
|
|
1752
|
-
stakeWithdrawal:
|
|
1753
|
-
slashed:
|
|
1748
|
+
start: raw[0],
|
|
1749
|
+
end: raw[1],
|
|
1750
|
+
inflation: raw[2],
|
|
1751
|
+
weight: raw[3],
|
|
1752
|
+
weightDeposit: raw[4],
|
|
1753
|
+
weightWithdrawal: raw[5],
|
|
1754
|
+
vcount: raw[6],
|
|
1755
|
+
claimed: raw[7],
|
|
1756
|
+
stakeDeposit: raw[8],
|
|
1757
|
+
stakeWithdrawal: raw[9],
|
|
1758
|
+
slashed: raw[10]
|
|
1754
1759
|
};
|
|
1755
1760
|
},
|
|
1756
1761
|
getActiveValidators: async () => {
|
|
@@ -1764,7 +1769,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1764
1769
|
},
|
|
1765
1770
|
getQuarantinedValidators: async () => {
|
|
1766
1771
|
const contract = getReadOnlyStakingContract();
|
|
1767
|
-
return contract.read.
|
|
1772
|
+
return contract.read.getValidatorQuarantineList();
|
|
1768
1773
|
},
|
|
1769
1774
|
getBannedValidators: async (startIndex = 0n, size = 100n) => {
|
|
1770
1775
|
const contract = getReadOnlyStakingContract();
|
|
@@ -1784,11 +1789,6 @@ var stakingActions = (client, publicClient) => {
|
|
|
1784
1789
|
permanentlyBanned: v.permanentlyBanned
|
|
1785
1790
|
}));
|
|
1786
1791
|
},
|
|
1787
|
-
getSlashingAddress: async () => {
|
|
1788
|
-
const contract = getReadOnlyStakingContract();
|
|
1789
|
-
const externalContracts = await contract.read.contracts();
|
|
1790
|
-
return externalContracts[4];
|
|
1791
|
-
},
|
|
1792
1792
|
getStakingContract,
|
|
1793
1793
|
parseStakingAmount,
|
|
1794
1794
|
formatStakingAmount
|
|
@@ -1799,7 +1799,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1799
1799
|
function chainActions(client) {
|
|
1800
1800
|
return {
|
|
1801
1801
|
initializeConsensusSmartContract: async (forceReset = false) => {
|
|
1802
|
-
if (_optionalChain([client, 'access', _62 => _62.chain, 'optionalAccess', _63 => _63.id]) ===
|
|
1802
|
+
if (_optionalChain([client, 'access', _62 => _62.chain, 'optionalAccess', _63 => _63.id]) === _chunk5TKVNHAOcjs.testnetAsimov.id) {
|
|
1803
1803
|
return;
|
|
1804
1804
|
}
|
|
1805
1805
|
if (!forceReset && _optionalChain([client, 'access', _64 => _64.chain, 'access', _65 => _65.consensusMainContract, 'optionalAccess', _66 => _66.address]) && _optionalChain([client, 'access', _67 => _67.chain, 'access', _68 => _68.consensusMainContract, 'optionalAccess', _69 => _69.abi])) {
|
|
@@ -1869,8 +1869,8 @@ var getCustomTransportConfig = (config, chainConfig) => {
|
|
|
1869
1869
|
}
|
|
1870
1870
|
};
|
|
1871
1871
|
};
|
|
1872
|
-
var createClient = (config = { chain:
|
|
1873
|
-
const chainConfig = config.chain ||
|
|
1872
|
+
var createClient = (config = { chain: _chunk5TKVNHAOcjs.localnet }) => {
|
|
1873
|
+
const chainConfig = config.chain || _chunk5TKVNHAOcjs.localnet;
|
|
1874
1874
|
if (config.endpoint) {
|
|
1875
1875
|
chainConfig.rpcUrls.default.http = [config.endpoint];
|
|
1876
1876
|
}
|
|
@@ -1931,4 +1931,4 @@ var createAccount = (accountPrivateKey) => {
|
|
|
1931
1931
|
|
|
1932
1932
|
|
|
1933
1933
|
|
|
1934
|
-
exports.abi = abi_exports; exports.chains =
|
|
1934
|
+
exports.abi = abi_exports; exports.chains = _chunk5TKVNHAOcjs.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-DsN7LGHA.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-sw3NAvBf.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-NOFMB7RP.js";
|
|
9
9
|
import {
|
|
10
10
|
CalldataAddress,
|
|
11
11
|
isDecidedState,
|
|
@@ -1687,8 +1687,6 @@ var stakingActions = (client, publicClient) => {
|
|
|
1687
1687
|
const [
|
|
1688
1688
|
epoch,
|
|
1689
1689
|
finalized,
|
|
1690
|
-
validatorMinStake,
|
|
1691
|
-
delegatorMinStake,
|
|
1692
1690
|
activeCount,
|
|
1693
1691
|
epochMinDuration,
|
|
1694
1692
|
epochZeroMinDuration,
|
|
@@ -1697,15 +1695,26 @@ var stakingActions = (client, publicClient) => {
|
|
|
1697
1695
|
] = await Promise.all([
|
|
1698
1696
|
contract.read.epoch(),
|
|
1699
1697
|
contract.read.finalized(),
|
|
1700
|
-
contract.read.validatorMinStake(),
|
|
1701
|
-
contract.read.delegatorMinStake(),
|
|
1702
1698
|
contract.read.activeValidatorsCount(),
|
|
1703
1699
|
contract.read.epochMinDuration(),
|
|
1704
1700
|
contract.read.epochZeroMinDuration(),
|
|
1705
1701
|
contract.read.epochOdd(),
|
|
1706
1702
|
contract.read.epochEven()
|
|
1707
1703
|
]);
|
|
1708
|
-
const
|
|
1704
|
+
const raw = epoch % 2n === 0n ? epochEven : epochOdd;
|
|
1705
|
+
const currentEpochData = {
|
|
1706
|
+
start: raw[0],
|
|
1707
|
+
end: raw[1],
|
|
1708
|
+
inflation: raw[2],
|
|
1709
|
+
weight: raw[3],
|
|
1710
|
+
weightDeposit: raw[4],
|
|
1711
|
+
weightWithdrawal: raw[5],
|
|
1712
|
+
vcount: raw[6],
|
|
1713
|
+
claimed: raw[7],
|
|
1714
|
+
stakeDeposit: raw[8],
|
|
1715
|
+
stakeWithdrawal: raw[9],
|
|
1716
|
+
slashed: raw[10]
|
|
1717
|
+
};
|
|
1709
1718
|
const currentEpochEnd = currentEpochData.end > 0n;
|
|
1710
1719
|
let nextEpochEstimate = null;
|
|
1711
1720
|
if (!currentEpochEnd) {
|
|
@@ -1716,10 +1725,6 @@ var stakingActions = (client, publicClient) => {
|
|
|
1716
1725
|
return {
|
|
1717
1726
|
currentEpoch: epoch,
|
|
1718
1727
|
lastFinalizedEpoch: finalized,
|
|
1719
|
-
validatorMinStake: formatStakingAmount(validatorMinStake),
|
|
1720
|
-
validatorMinStakeRaw: validatorMinStake,
|
|
1721
|
-
delegatorMinStake: formatStakingAmount(delegatorMinStake),
|
|
1722
|
-
delegatorMinStakeRaw: delegatorMinStake,
|
|
1723
1728
|
activeValidatorsCount: activeCount,
|
|
1724
1729
|
epochMinDuration,
|
|
1725
1730
|
nextEpochEstimate
|
|
@@ -1738,19 +1743,19 @@ var stakingActions = (client, publicClient) => {
|
|
|
1738
1743
|
if (epochNumber < currentEpoch - 1n && currentEpoch > 0n) {
|
|
1739
1744
|
throw new Error(`Epoch ${epochNumber} data no longer available (only current and previous epoch stored)`);
|
|
1740
1745
|
}
|
|
1741
|
-
const
|
|
1746
|
+
const raw = epochNumber % 2n === 0n ? epochEven : epochOdd;
|
|
1742
1747
|
return {
|
|
1743
|
-
start:
|
|
1744
|
-
end:
|
|
1745
|
-
inflation:
|
|
1746
|
-
weight:
|
|
1747
|
-
weightDeposit:
|
|
1748
|
-
weightWithdrawal:
|
|
1749
|
-
vcount:
|
|
1750
|
-
claimed:
|
|
1751
|
-
stakeDeposit:
|
|
1752
|
-
stakeWithdrawal:
|
|
1753
|
-
slashed:
|
|
1748
|
+
start: raw[0],
|
|
1749
|
+
end: raw[1],
|
|
1750
|
+
inflation: raw[2],
|
|
1751
|
+
weight: raw[3],
|
|
1752
|
+
weightDeposit: raw[4],
|
|
1753
|
+
weightWithdrawal: raw[5],
|
|
1754
|
+
vcount: raw[6],
|
|
1755
|
+
claimed: raw[7],
|
|
1756
|
+
stakeDeposit: raw[8],
|
|
1757
|
+
stakeWithdrawal: raw[9],
|
|
1758
|
+
slashed: raw[10]
|
|
1754
1759
|
};
|
|
1755
1760
|
},
|
|
1756
1761
|
getActiveValidators: async () => {
|
|
@@ -1764,7 +1769,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1764
1769
|
},
|
|
1765
1770
|
getQuarantinedValidators: async () => {
|
|
1766
1771
|
const contract = getReadOnlyStakingContract();
|
|
1767
|
-
return contract.read.
|
|
1772
|
+
return contract.read.getValidatorQuarantineList();
|
|
1768
1773
|
},
|
|
1769
1774
|
getBannedValidators: async (startIndex = 0n, size = 100n) => {
|
|
1770
1775
|
const contract = getReadOnlyStakingContract();
|
|
@@ -1784,11 +1789,6 @@ var stakingActions = (client, publicClient) => {
|
|
|
1784
1789
|
permanentlyBanned: v.permanentlyBanned
|
|
1785
1790
|
}));
|
|
1786
1791
|
},
|
|
1787
|
-
getSlashingAddress: async () => {
|
|
1788
|
-
const contract = getReadOnlyStakingContract();
|
|
1789
|
-
const externalContracts = await contract.read.contracts();
|
|
1790
|
-
return externalContracts[4];
|
|
1791
|
-
},
|
|
1792
1792
|
getStakingContract,
|
|
1793
1793
|
parseStakingAmount,
|
|
1794
1794
|
formatStakingAmount
|
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, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R 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, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R 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-DsN7LGHA.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, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R 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, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R 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-sw3NAvBf.js';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-B7B7UXdn.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genlayer-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.11",
|
|
5
5
|
"description": "GenLayer JavaScript SDK",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"build": "tsup src/index.ts src/chains/index.ts src/types/index.ts --format cjs,esm --dts --splitting --out-dir dist --no-treeshake",
|
|
10
10
|
"build:watch": "tsup src/index.ts src/chains/index.ts src/types/index.ts --format cjs,esm --dts --splitting --out-dir dist --no-treeshake --watch",
|
|
11
11
|
"test": "vitest --typecheck",
|
|
12
|
+
"test:smoke": "vitest run --config vitest.smoke.config.ts",
|
|
12
13
|
"test:watch": "vitest --watch",
|
|
13
14
|
"lint": "eslint . --fix --ext .ts",
|
|
14
15
|
"release": "release-it --ci"
|
|
@@ -30,6 +31,10 @@
|
|
|
30
31
|
"keywords": [],
|
|
31
32
|
"author": "GenLayer",
|
|
32
33
|
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/genlayerlabs/genlayer-js.git"
|
|
37
|
+
},
|
|
33
38
|
"devDependencies": {
|
|
34
39
|
"@release-it/conventional-changelog": "^8.0.2",
|
|
35
40
|
"@types/jest": "^29.5.13",
|