Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: json output for get_node_info #10771

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 57 additions & 22 deletions yarn-project/cli/src/cmds/pxe/get_node_info.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,69 @@
import { type AztecNode, type PXE, createAztecNodeClient, createCompatibleClient } from '@aztec/aztec.js';
import { type LogFn, type Logger } from '@aztec/foundation/log';

export async function getNodeInfo(rpcUrl: string, pxeRequest: boolean, debugLogger: Logger, log: LogFn) {
export async function getNodeInfo(
rpcUrl: string,
pxeRequest: boolean,
debugLogger: Logger,
json: boolean,
log: LogFn,
logJson: (output: any) => void,
) {
let client: AztecNode | PXE;
if (pxeRequest) {
client = await createCompatibleClient(rpcUrl, debugLogger);
} else {
client = createAztecNodeClient(rpcUrl);
}
const info = await client.getNodeInfo();
log(`Node Version: ${info.nodeVersion}`);
log(`Chain Id: ${info.l1ChainId}`);
log(`Protocol Version: ${info.protocolVersion}`);
log(`Node ENR: ${info.enr}`);
log(`L1 Contract Addresses:`);
log(` Rollup Address: ${info.l1ContractAddresses.rollupAddress.toString()}`);
log(` Registry Address: ${info.l1ContractAddresses.registryAddress.toString()}`);
log(` L1 -> L2 Inbox Address: ${info.l1ContractAddresses.inboxAddress.toString()}`);
log(` L2 -> L1 Outbox Address: ${info.l1ContractAddresses.outboxAddress.toString()}`);
log(` Fee Juice Address: ${info.l1ContractAddresses.feeJuiceAddress.toString()}`);
log(` Staking Asset Address: ${info.l1ContractAddresses.stakingAssetAddress.toString()}`);
log(` Fee Juice Portal Address: ${info.l1ContractAddresses.feeJuicePortalAddress.toString()}`);
log(` CoinIssuer Address: ${info.l1ContractAddresses.coinIssuerAddress.toString()}`);
log(` RewardDistributor Address: ${info.l1ContractAddresses.rewardDistributorAddress.toString()}`);
log(` GovernanceProposer Address: ${info.l1ContractAddresses.governanceProposerAddress.toString()}`);
log(` Governance Address: ${info.l1ContractAddresses.governanceAddress.toString()}`);
if (json) {
logJson({
nodeVersion: info.nodeVersion,
l1ChainId: info.l1ChainId,
protocolVersion: info.protocolVersion,
enr: info.enr,
l1ContractAddresses: {
rollup: info.l1ContractAddresses.rollupAddress.toString(),
registry: info.l1ContractAddresses.registryAddress.toString(),
inbox: info.l1ContractAddresses.inboxAddress.toString(),
outbox: info.l1ContractAddresses.outboxAddress.toString(),
feeJuice: info.l1ContractAddresses.feeJuiceAddress.toString(),
stakingAsset: info.l1ContractAddresses.stakingAssetAddress.toString(),
feeJuicePortal: info.l1ContractAddresses.feeJuicePortalAddress.toString(),
coinIssuer: info.l1ContractAddresses.coinIssuerAddress.toString(),
rewardDistributor: info.l1ContractAddresses.rewardDistributorAddress.toString(),
governanceProposer: info.l1ContractAddresses.governanceProposerAddress.toString(),
governance: info.l1ContractAddresses.governanceAddress.toString(),
},
protocolContractAddresses: {
classRegisterer: info.protocolContractAddresses.classRegisterer.toString(),
feeJuice: info.protocolContractAddresses.feeJuice.toString(),
instanceDeployer: info.protocolContractAddresses.instanceDeployer.toString(),
multiCallEntrypoint: info.protocolContractAddresses.multiCallEntrypoint.toString(),
},
});
} else {
log(`Node Version: ${info.nodeVersion}`);
log(`Chain Id: ${info.l1ChainId}`);
log(`Protocol Version: ${info.protocolVersion}`);
log(`Node ENR: ${info.enr}`);
log(`L1 Contract Addresses:`);
log(` Rollup Address: ${info.l1ContractAddresses.rollupAddress.toString()}`);
log(` Registry Address: ${info.l1ContractAddresses.registryAddress.toString()}`);
log(` L1 -> L2 Inbox Address: ${info.l1ContractAddresses.inboxAddress.toString()}`);
log(` L2 -> L1 Outbox Address: ${info.l1ContractAddresses.outboxAddress.toString()}`);
log(` Fee Juice Address: ${info.l1ContractAddresses.feeJuiceAddress.toString()}`);
log(` Staking Asset Address: ${info.l1ContractAddresses.stakingAssetAddress.toString()}`);
log(` Fee Juice Portal Address: ${info.l1ContractAddresses.feeJuicePortalAddress.toString()}`);
log(` CoinIssuer Address: ${info.l1ContractAddresses.coinIssuerAddress.toString()}`);
log(` RewardDistributor Address: ${info.l1ContractAddresses.rewardDistributorAddress.toString()}`);
log(` GovernanceProposer Address: ${info.l1ContractAddresses.governanceProposerAddress.toString()}`);
log(` Governance Address: ${info.l1ContractAddresses.governanceAddress.toString()}`);

log(`L2 Contract Addresses:`);
log(` Class Registerer: ${info.protocolContractAddresses.classRegisterer.toString()}`);
log(` Fee Juice: ${info.protocolContractAddresses.feeJuice.toString()}`);
log(` Instance Deployer: ${info.protocolContractAddresses.instanceDeployer.toString()}`);
log(` MultiCall: ${info.protocolContractAddresses.multiCallEntrypoint.toString()}`);
log(`L2 Contract Addresses:`);
log(` Class Registerer: ${info.protocolContractAddresses.classRegisterer.toString()}`);
log(` Fee Juice: ${info.protocolContractAddresses.feeJuice.toString()}`);
log(` Instance Deployer: ${info.protocolContractAddresses.instanceDeployer.toString()}`);
log(` MultiCall: ${info.protocolContractAddresses.multiCallEntrypoint.toString()}`);
}
}
3 changes: 2 additions & 1 deletion yarn-project/cli/src/cmds/pxe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
.command('get-node-info')
.description('Gets the information of an Aztec node from a PXE or directly from an Aztec node.')
.option('--node-url <string>', 'URL of the node.')
.option('--json', 'Emit output as json')
.addOption(makePxeOption(false))
.action(async options => {
const { getNodeInfo } = await import('./get_node_info.js');
Expand All @@ -153,7 +154,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
} else {
url = options.rpcUrl;
}
await getNodeInfo(url, !options.nodeUrl, debugLogger, log);
await getNodeInfo(url, !options.nodeUrl, debugLogger, options.json, log, logJson(log));
});

program
Expand Down
Loading