Skip to content

XRPLF/xrpl-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XRPLF CLI

This CLI tool provides a common interface for interacting with XRPL-related repositories and tools.

Install

Clone the repository

git clone [email protected]:XRPLF/xrpl-infra.git

Install dependencies

pnpm install

Make the CLI globally available

To make the CLI globally available, you can use pnpm link:

pnpm link --global

Usage

xrplf help

List Commands

You can list all commands by running:

xrpl

Config

You can set config options with:

xrplf config set <key> <value>

You can get config options with:

xrplf config get <key>

You can list all config options with:

xrplf config list

Secrets

You can interface with a secret manager using the xrplf secrets command. Currently supported secret managers are:

  • local - Local secret manager (OS keychain)
  • gcp - Google Cloud Secret Manager

You can set a secret with:

xrplf secrets set --service="$optionalKeyPrefix" <key> <value>

You can read a secret with:

xrplf secrets get --service="$optionalKeyPrefix" <key>

You can set the default secret manager with:

xrplf secrets provider <provider:local|gcp>

If you use GCP Secret Manager, you will be prompted to authenticate with your Google account. You can also set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to a service account key file.

Unique Node List (UNL)

You can also create a signed UNL using the xrplf unl command. This command will create a signed UNL file from keys that are stored in your secret manager.

 xrplf unl generate  --validators="../unl/data/unl-raw.yaml" --output="/tmp/unl.json"

This will create a signed UNL file in the specified output directory. The --validators flag is required and should point to the raw YAML file containing the list of validators. The --output flag is optional and defaults to ./unl.json.

Example (truncated) YAML file:

nodes:
  - id: nHBgyVGAEhgU6GoEqoriKmkNBjzhy6WJhX9Z7cZ71yJbv28dzvVN
    name: v2.xrpl-commons.org
  - id: nHU4bLE3EmSqNwfL4AP1UZeTNPrSPPP6FXLKXo2uqfHuvBQxDVKd
    name: ripple.com

Adding New Commands

You can add new commands by creating a new file in the src/actions directory. There are two ways to add a command: 1) as a javascript file or 2) as a shell script. The CLI will automatically detect and load the command, preferring the javascript file if both are present.

If the command is a javascript file, it should export an exec function:

import chalk from "chalk";
import getStdin from "get-stdin";

const log = console.log;

export const exec = async (context) => {
  const input = await getStdin();

  // context contains the flags and input

  if (!context.flags.quiet) {
    log(`via: ${context.personality}\n`);
    log(
      chalk.white(
        JSON.stringify(
          { ...context, stdin: input, env: { ...process.env } },
          null,
          2
        )
      )
    );
  }
};

export const description = "hello world example in javascript";

Google Cloud Setup

You may need to set:

export GOOGLE_CLOUD_PROJECT=xrplf-infra-shared

before running the CLI commands that interact with GCP.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published