Skip to content

Commit

Permalink
Pending index in root command
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgenKor committed May 30, 2024
1 parent eaa81cf commit 9d91d98
Show file tree
Hide file tree
Showing 5 changed files with 566 additions and 515 deletions.
2 changes: 1 addition & 1 deletion client-config-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"chainId": 11155111,
"poolAddress": "0x7D6BB1192c859fF5Cf9fC4a0dbFbD782F19aeE35",
"tokenAddress": "0x2C74B18e2f84B78ac67428d0c7a9898515f0c46f",
"proxyUrls": ["https://sepolia-decentralized-relayer.thgkjlr.website/", "https://sepolia-proxy.zkbob.evgen.space"],
"proxyUrls": ["http://127.0.0.1:8081", "https://sepolia-decentralized-relayer.thgkjlr.website/", "https://sepolia-proxy.zkbob.evgen.space"],
"feeDecimals": 2,
"depositScheme": "permit"
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zkbob-console",
"version": "4.0.0-beta5",
"version": "4.0.0-beta6",
"license": "MIT",
"author": "Dmitry Vdovin <[email protected]>",
"homepage": "https://github.com/zkBob/zkbob-console",
Expand Down Expand Up @@ -40,7 +40,7 @@
"tslib": "^2.3.1",
"uuid": "^9.0.0",
"web3": "^1.7.1",
"zkbob-client-js": "6.0.0-beta7",
"zkbob-client-js": "6.0.0-beta8",
"zkbob-support-js": "1.0.1"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ export class Account {
return this.getZpClient().getSequencerOptimisticState();
}

public async getSequencerPendingIndex(): Promise<bigint> {
return this.getZpClient().getSequencerPendingIndex();
}

public async getLocalTreeStartIndex(): Promise<bigint | undefined> {
return this.getZpClient().getTreeStartIndex();
}
Expand Down
13 changes: 8 additions & 5 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,26 +853,29 @@ export async function getRoot(index: string) {
this.pause();
const sequencerState = account(this).getSequencerTreeState().catch((e) => e.message);
let sequencerOptimisticState;
let sequencerPendingIndex;
if (idx === undefined) {
sequencerOptimisticState = account(this).getSequencerOptimisticTreeState().catch((e) => e.message);
sequencerPendingIndex = account(this).getSequencerPendingIndex().catch((e) => e.message);
}
const poolState = account(this).getPoolTreeState(idx).catch((e) => e.message);

let promises = [sequencerState, sequencerOptimisticState, poolState]
let promises = [sequencerState, sequencerOptimisticState, poolState, sequencerPendingIndex]
Promise.all(promises).then((states) => {
const sequencerState = typeof states[0] === "string" ? `[[;red;]${states[0]}]` :
`[[;white;]${states[0].root.toString()} @${states[0].index.toString()}]`;
const sequencerOpState = typeof states[1] === "string" ? `[[;red;]${states[1]}]` :
`[[;white;]${states[1].root.toString()} @${states[1].index.toString()}]`;
const poolState = typeof states[2] === "string" ? `[[;red;]${states[2]}]` :
`[[;white;]${states[2].root.toString()} @${states[2].index.toString()}]`;

if (sequencerOptimisticState !== undefined) {
if (idx === undefined) {
const sequencerOpState = typeof states[1] === "string" ? `[[;red;]${states[1]}]` :
`[[;white;]${states[1].root.toString()} @${states[1].index.toString()}]`;
const optimisticIdx = typeof states[1] !== "string" ? states[1].index as bigint : 0n;
const seqPendIdx = typeof states[3] === "bigint" && states[3] > optimisticIdx ?
` [pending: [[;white;]${states[3].toString()}]]` : '';

this.update(-1, `Sequencer: ${sequencerState}`);
this.echo(`Sequencer optimistic: ${sequencerOpState}`);
this.echo(`Sequencer optimistic: ${sequencerOpState}${seqPendIdx}`);
this.echo(`Pool contract: ${poolState}`);
} else {
this.update(-1, `Pool contract: ${poolState}`);
Expand Down
Loading

0 comments on commit 9d91d98

Please sign in to comment.