genlayer 0.35.3 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +140 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -20078,7 +20078,7 @@ var require_cli_table3 = __commonJS({
|
|
|
20078
20078
|
import { program } from "commander";
|
|
20079
20079
|
|
|
20080
20080
|
// package.json
|
|
20081
|
-
var version = "0.
|
|
20081
|
+
var version = "0.36.0";
|
|
20082
20082
|
var package_default = {
|
|
20083
20083
|
name: "genlayer",
|
|
20084
20084
|
version,
|
|
@@ -20156,7 +20156,7 @@ var package_default = {
|
|
|
20156
20156
|
dotenv: "^17.0.0",
|
|
20157
20157
|
ethers: "^6.13.4",
|
|
20158
20158
|
"fs-extra": "^11.3.0",
|
|
20159
|
-
"genlayer-js": "^0.
|
|
20159
|
+
"genlayer-js": "^0.22.1",
|
|
20160
20160
|
inquirer: "^12.0.0",
|
|
20161
20161
|
keytar: "^7.9.0",
|
|
20162
20162
|
"node-fetch": "^3.0.0",
|
|
@@ -33746,7 +33746,7 @@ init_toHex();
|
|
|
33746
33746
|
init_keccak256();
|
|
33747
33747
|
init_formatEther();
|
|
33748
33748
|
|
|
33749
|
-
// node_modules/genlayer-js/dist/chunk-
|
|
33749
|
+
// node_modules/genlayer-js/dist/chunk-BU7ME7KN.js
|
|
33750
33750
|
var chains_exports = {};
|
|
33751
33751
|
__export2(chains_exports, {
|
|
33752
33752
|
localnet: () => localnet,
|
|
@@ -37761,6 +37761,8 @@ var localnet = defineChain({
|
|
|
37761
37761
|
consensusMainContract: CONSENSUS_MAIN_CONTRACT,
|
|
37762
37762
|
consensusDataContract: CONSENSUS_DATA_CONTRACT,
|
|
37763
37763
|
stakingContract: null,
|
|
37764
|
+
feeManagerContract: null,
|
|
37765
|
+
roundsStorageContract: null,
|
|
37764
37766
|
defaultNumberOfInitialValidators: 5,
|
|
37765
37767
|
defaultConsensusMaxRotations: 3
|
|
37766
37768
|
});
|
|
@@ -41772,6 +41774,8 @@ var studionet = defineChain({
|
|
|
41772
41774
|
consensusMainContract: CONSENSUS_MAIN_CONTRACT2,
|
|
41773
41775
|
consensusDataContract: CONSENSUS_DATA_CONTRACT2,
|
|
41774
41776
|
stakingContract: null,
|
|
41777
|
+
feeManagerContract: null,
|
|
41778
|
+
roundsStorageContract: null,
|
|
41775
41779
|
defaultNumberOfInitialValidators: 5,
|
|
41776
41780
|
defaultConsensusMaxRotations: 3
|
|
41777
41781
|
});
|
|
@@ -43249,7 +43253,7 @@ var STAKING_ABI = [
|
|
|
43249
43253
|
outputs: [{ name: "", type: "address" }]
|
|
43250
43254
|
}
|
|
43251
43255
|
];
|
|
43252
|
-
var TESTNET_JSON_RPC_URL = "
|
|
43256
|
+
var TESTNET_JSON_RPC_URL = "https://rpc-asimov.genlayer.com";
|
|
43253
43257
|
var STAKING_CONTRACT = {
|
|
43254
43258
|
address: "0x63Fa5E0bb10fb6fA98F44726C5518223F767687A",
|
|
43255
43259
|
abi: STAKING_ABI
|
|
@@ -47249,14 +47253,44 @@ var testnetAsimov = defineChain({
|
|
|
47249
47253
|
consensusMainContract: CONSENSUS_MAIN_CONTRACT3,
|
|
47250
47254
|
consensusDataContract: CONSENSUS_DATA_CONTRACT3,
|
|
47251
47255
|
stakingContract: STAKING_CONTRACT,
|
|
47256
|
+
feeManagerContract: null,
|
|
47257
|
+
roundsStorageContract: null,
|
|
47252
47258
|
defaultNumberOfInitialValidators: 5,
|
|
47253
47259
|
defaultConsensusMaxRotations: 3
|
|
47254
47260
|
});
|
|
47255
|
-
var TESTNET_JSON_RPC_URL2 = "
|
|
47261
|
+
var TESTNET_JSON_RPC_URL2 = "https://rpc-bradbury.genlayer.com";
|
|
47256
47262
|
var STAKING_CONTRACT2 = {
|
|
47257
47263
|
address: "0x4A4449E617F8D10FDeD0b461CadEf83939E821A5",
|
|
47258
47264
|
abi: STAKING_ABI
|
|
47259
47265
|
};
|
|
47266
|
+
var FEE_MANAGER_CONTRACT = {
|
|
47267
|
+
address: "0xF205868bf5db79d2162843742D18D0900A9E462a",
|
|
47268
|
+
abi: [
|
|
47269
|
+
{
|
|
47270
|
+
type: "function",
|
|
47271
|
+
name: "calculateMinAppealBond",
|
|
47272
|
+
stateMutability: "view",
|
|
47273
|
+
inputs: [
|
|
47274
|
+
{ name: "_txId", type: "bytes32" },
|
|
47275
|
+
{ name: "_round", type: "uint256" },
|
|
47276
|
+
{ name: "_status", type: "uint8" }
|
|
47277
|
+
],
|
|
47278
|
+
outputs: [{ name: "totalFeesToPay", type: "uint256" }]
|
|
47279
|
+
}
|
|
47280
|
+
]
|
|
47281
|
+
};
|
|
47282
|
+
var ROUNDS_STORAGE_CONTRACT = {
|
|
47283
|
+
address: "0x7134D05af13A14c0b66Fe129fb930b1d0C420e33",
|
|
47284
|
+
abi: [
|
|
47285
|
+
{
|
|
47286
|
+
type: "function",
|
|
47287
|
+
name: "getRoundNumber",
|
|
47288
|
+
stateMutability: "view",
|
|
47289
|
+
inputs: [{ name: "_txId", type: "bytes32" }],
|
|
47290
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
47291
|
+
}
|
|
47292
|
+
]
|
|
47293
|
+
};
|
|
47260
47294
|
var EXPLORER_URL3 = "https://explorer-bradbury.genlayer.com/";
|
|
47261
47295
|
var CONSENSUS_MAIN_CONTRACT4 = {
|
|
47262
47296
|
address: "0x0112Bf6e83497965A5fdD6Dad1E447a6E004271D",
|
|
@@ -50598,6 +50632,8 @@ var testnetBradbury = defineChain({
|
|
|
50598
50632
|
consensusMainContract: CONSENSUS_MAIN_CONTRACT4,
|
|
50599
50633
|
consensusDataContract: CONSENSUS_DATA_CONTRACT4,
|
|
50600
50634
|
stakingContract: STAKING_CONTRACT2,
|
|
50635
|
+
feeManagerContract: FEE_MANAGER_CONTRACT,
|
|
50636
|
+
roundsStorageContract: ROUNDS_STORAGE_CONTRACT,
|
|
50601
50637
|
defaultNumberOfInitialValidators: 5,
|
|
50602
50638
|
defaultConsensusMaxRotations: 3
|
|
50603
50639
|
});
|
|
@@ -51347,6 +51383,19 @@ function _toJsonSafeDeep(value, seen) {
|
|
|
51347
51383
|
}
|
|
51348
51384
|
return value;
|
|
51349
51385
|
}
|
|
51386
|
+
function extractGenCallResult(result) {
|
|
51387
|
+
if (typeof result === "string") {
|
|
51388
|
+
return `0x${result}`;
|
|
51389
|
+
}
|
|
51390
|
+
if (result && typeof result === "object" && "data" in result) {
|
|
51391
|
+
const obj = result;
|
|
51392
|
+
if (obj.status && obj.status.code !== 0) {
|
|
51393
|
+
throw new Error(`gen_call failed: ${obj.status.message}`);
|
|
51394
|
+
}
|
|
51395
|
+
return `0x${obj.data}`;
|
|
51396
|
+
}
|
|
51397
|
+
throw new Error(`Unexpected gen_call response: ${JSON.stringify(result)}`);
|
|
51398
|
+
}
|
|
51350
51399
|
var contractActions = (client, publicClient) => {
|
|
51351
51400
|
return {
|
|
51352
51401
|
getContractCode: async (address) => {
|
|
@@ -51406,7 +51455,7 @@ var contractActions = (client, publicClient) => {
|
|
|
51406
51455
|
method: "gen_call",
|
|
51407
51456
|
params: [requestParams]
|
|
51408
51457
|
});
|
|
51409
|
-
const prefixedResult =
|
|
51458
|
+
const prefixedResult = extractGenCallResult(result);
|
|
51410
51459
|
if (args.rawReturn) {
|
|
51411
51460
|
return prefixedResult;
|
|
51412
51461
|
}
|
|
@@ -51442,7 +51491,7 @@ var contractActions = (client, publicClient) => {
|
|
|
51442
51491
|
method: "gen_call",
|
|
51443
51492
|
params: [requestParams]
|
|
51444
51493
|
});
|
|
51445
|
-
const prefixedResult =
|
|
51494
|
+
const prefixedResult = extractGenCallResult(result);
|
|
51446
51495
|
if (args.rawReturn) {
|
|
51447
51496
|
return prefixedResult;
|
|
51448
51497
|
}
|
|
@@ -51510,15 +51559,58 @@ var contractActions = (client, publicClient) => {
|
|
|
51510
51559
|
senderAccount
|
|
51511
51560
|
});
|
|
51512
51561
|
},
|
|
51562
|
+
getMinAppealBond: async (args) => {
|
|
51563
|
+
const { txId } = args;
|
|
51564
|
+
if (!client.chain.feeManagerContract?.address || !client.chain.roundsStorageContract?.address) {
|
|
51565
|
+
throw new Error("Appeal bond calculation not supported on this chain (missing feeManagerContract/roundsStorageContract)");
|
|
51566
|
+
}
|
|
51567
|
+
const roundNumber = await publicClient.readContract({
|
|
51568
|
+
address: client.chain.roundsStorageContract.address,
|
|
51569
|
+
abi: client.chain.roundsStorageContract.abi,
|
|
51570
|
+
functionName: "getRoundNumber",
|
|
51571
|
+
args: [txId]
|
|
51572
|
+
});
|
|
51573
|
+
const transaction = await client.getTransaction({ hash: txId });
|
|
51574
|
+
const txStatus = Number(transaction.status);
|
|
51575
|
+
const minBond = await publicClient.readContract({
|
|
51576
|
+
address: client.chain.feeManagerContract.address,
|
|
51577
|
+
abi: client.chain.feeManagerContract.abi,
|
|
51578
|
+
functionName: "calculateMinAppealBond",
|
|
51579
|
+
args: [txId, roundNumber, txStatus]
|
|
51580
|
+
});
|
|
51581
|
+
return minBond;
|
|
51582
|
+
},
|
|
51513
51583
|
appealTransaction: async (args) => {
|
|
51514
51584
|
const { account, txId } = args;
|
|
51585
|
+
let { value } = args;
|
|
51586
|
+
if (value === void 0) {
|
|
51587
|
+
if (client.chain.feeManagerContract?.address && client.chain.roundsStorageContract?.address) {
|
|
51588
|
+
const roundNumber = await publicClient.readContract({
|
|
51589
|
+
address: client.chain.roundsStorageContract.address,
|
|
51590
|
+
abi: client.chain.roundsStorageContract.abi,
|
|
51591
|
+
functionName: "getRoundNumber",
|
|
51592
|
+
args: [txId]
|
|
51593
|
+
});
|
|
51594
|
+
const transaction = await client.getTransaction({ hash: txId });
|
|
51595
|
+
const txStatus = Number(transaction.status);
|
|
51596
|
+
value = await publicClient.readContract({
|
|
51597
|
+
address: client.chain.feeManagerContract.address,
|
|
51598
|
+
abi: client.chain.feeManagerContract.abi,
|
|
51599
|
+
functionName: "calculateMinAppealBond",
|
|
51600
|
+
args: [txId, roundNumber, txStatus]
|
|
51601
|
+
});
|
|
51602
|
+
} else {
|
|
51603
|
+
value = 0n;
|
|
51604
|
+
}
|
|
51605
|
+
}
|
|
51515
51606
|
const senderAccount = account || client.account;
|
|
51516
51607
|
const encodedData = _encodeSubmitAppealData({ client, txId });
|
|
51517
51608
|
return _sendTransaction({
|
|
51518
51609
|
client,
|
|
51519
51610
|
publicClient,
|
|
51520
51611
|
encodedData,
|
|
51521
|
-
senderAccount
|
|
51612
|
+
senderAccount,
|
|
51613
|
+
value
|
|
51522
51614
|
});
|
|
51523
51615
|
}
|
|
51524
51616
|
};
|
|
@@ -55575,25 +55667,55 @@ var AppealAction = class extends BaseAction {
|
|
|
55575
55667
|
}
|
|
55576
55668
|
async appeal({
|
|
55577
55669
|
txId,
|
|
55578
|
-
rpc
|
|
55670
|
+
rpc,
|
|
55671
|
+
bond
|
|
55579
55672
|
}) {
|
|
55580
55673
|
const client = await this.getClient(rpc);
|
|
55581
|
-
await client.initializeConsensusSmartContract();
|
|
55582
|
-
this.startSpinner(`Appealing transaction ${txId}...`);
|
|
55583
55674
|
try {
|
|
55675
|
+
let value;
|
|
55676
|
+
if (bond) {
|
|
55677
|
+
value = parseStakingAmount(bond);
|
|
55678
|
+
} else {
|
|
55679
|
+
this.startSpinner("Calculating appeal bond...");
|
|
55680
|
+
try {
|
|
55681
|
+
value = await client.getMinAppealBond({ txId });
|
|
55682
|
+
this.stopSpinner();
|
|
55683
|
+
this.logInfo(`Appeal bond: ${formatStakingAmount(value)}`);
|
|
55684
|
+
} catch {
|
|
55685
|
+
this.stopSpinner();
|
|
55686
|
+
value = void 0;
|
|
55687
|
+
}
|
|
55688
|
+
}
|
|
55689
|
+
await this.confirmPrompt("Proceed with appeal?");
|
|
55690
|
+
this.startSpinner(`Appealing transaction ${txId}...`);
|
|
55584
55691
|
const hash3 = await client.appealTransaction({
|
|
55585
|
-
txId
|
|
55692
|
+
txId,
|
|
55693
|
+
value
|
|
55586
55694
|
});
|
|
55695
|
+
this.setSpinnerText("Waiting for finalization...");
|
|
55587
55696
|
const result = await client.waitForTransactionReceipt({
|
|
55588
55697
|
hash: hash3,
|
|
55589
55698
|
retries: 100,
|
|
55590
55699
|
interval: 5e3
|
|
55591
55700
|
});
|
|
55592
|
-
this.succeedSpinner("Appeal
|
|
55701
|
+
this.succeedSpinner("Appeal successfully executed", result);
|
|
55593
55702
|
} catch (error) {
|
|
55594
55703
|
this.failSpinner("Error during appeal operation", error);
|
|
55595
55704
|
}
|
|
55596
55705
|
}
|
|
55706
|
+
async appealBond({
|
|
55707
|
+
txId,
|
|
55708
|
+
rpc
|
|
55709
|
+
}) {
|
|
55710
|
+
const client = await this.getClient(rpc, true);
|
|
55711
|
+
this.startSpinner(`Calculating appeal bond for ${txId}...`);
|
|
55712
|
+
try {
|
|
55713
|
+
const bond = await client.getMinAppealBond({ txId });
|
|
55714
|
+
this.succeedSpinner(`Minimum appeal bond: ${formatStakingAmount(bond)}`);
|
|
55715
|
+
} catch (error) {
|
|
55716
|
+
this.failSpinner("Error calculating appeal bond", error);
|
|
55717
|
+
}
|
|
55718
|
+
}
|
|
55597
55719
|
};
|
|
55598
55720
|
|
|
55599
55721
|
// src/commands/transactions/index.ts
|
|
@@ -55607,10 +55729,14 @@ function initializeTransactionsCommands(program2) {
|
|
|
55607
55729
|
const receiptAction = new ReceiptAction();
|
|
55608
55730
|
await receiptAction.receipt({ txId, ...options });
|
|
55609
55731
|
});
|
|
55610
|
-
program2.command("appeal <txId>").description("Appeal a transaction by its hash").option("--rpc <rpcUrl>", "RPC URL for the network").action(async (txId, options) => {
|
|
55732
|
+
program2.command("appeal <txId>").description("Appeal a transaction by its hash").option("--bond <amount>", "Appeal bond amount (e.g. 500gen, 0.5gen). Auto-calculated if omitted").option("--rpc <rpcUrl>", "RPC URL for the network").action(async (txId, options) => {
|
|
55611
55733
|
const appealAction = new AppealAction();
|
|
55612
55734
|
await appealAction.appeal({ txId, ...options });
|
|
55613
55735
|
});
|
|
55736
|
+
program2.command("appeal-bond <txId>").description("Show minimum appeal bond required for a transaction").option("--rpc <rpcUrl>", "RPC URL for the network").action(async (txId, options) => {
|
|
55737
|
+
const appealAction = new AppealAction();
|
|
55738
|
+
await appealAction.appealBond({ txId, ...options });
|
|
55739
|
+
});
|
|
55614
55740
|
return program2;
|
|
55615
55741
|
}
|
|
55616
55742
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genlayer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "GenLayer Command Line Tool",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"dotenv": "^17.0.0",
|
|
76
76
|
"ethers": "^6.13.4",
|
|
77
77
|
"fs-extra": "^11.3.0",
|
|
78
|
-
"genlayer-js": "^0.
|
|
78
|
+
"genlayer-js": "^0.22.1",
|
|
79
79
|
"inquirer": "^12.0.0",
|
|
80
80
|
"keytar": "^7.9.0",
|
|
81
81
|
"node-fetch": "^3.0.0",
|