Skip to content

Add Grid CLI commands#135

Merged
jklein24 merged 3 commits intomainfrom
jk/grid-cli-commands
Feb 4, 2026
Merged

Add Grid CLI commands#135
jklein24 merged 3 commits intomainfrom
jk/grid-cli-commands

Conversation

@jklein24
Copy link
Contributor

Commands for interacting with the Grid API:

  • config: Get/update platform configuration
  • customers: List, get, create, update, delete customers and generate KYC links
  • accounts: List internal accounts (balances), list/create external accounts
  • quotes: List, get, create, execute cross-currency transfer quotes
  • transactions: List, get, approve, reject transactions
  • transfers: Same-currency transfer-in and transfer-out
  • receiver: Look up UMA addresses and external accounts
  • sandbox: Fund accounts, simulate send/receive in sandbox mode

Copy link
Contributor Author

jklein24 commented Jan 27, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@jklein24 jklein24 force-pushed the jk/grid-cli-commands branch from e7f67f3 to 2da2ad3 Compare January 27, 2026 19:30
@jklein24 jklein24 force-pushed the jk/grid-cli-commands branch from f4e9275 to 294da99 Compare January 27, 2026 19:55
@jklein24 jklein24 marked this pull request as ready for review February 1, 2026 06:31
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

This PR implements a comprehensive CLI for the Grid API, adding commands for managing customers, accounts, quotes, transactions, transfers, and sandbox testing.

Major additions:

  • Interactive configure command with credential validation and secure storage
  • Customer management (list, get, create, update, delete, KYC link generation)
  • Account management for both internal (balances) and external (bank/wallet) accounts
  • Quote creation and execution for cross-currency transfers with validation
  • Transaction listing, approval, and rejection
  • Same-currency transfer-in/transfer-out operations
  • Receiver lookup for UMA addresses and external accounts
  • Sandbox commands for testing (fund, send, receive)
  • Platform configuration get/update commands
  • Comprehensive validation utilities for dates, amounts, currencies
  • Table and JSON output formats with color support
  • Command aliases for convenience (cust, tx, acct)

Issue found:

  • quotes create command has missing validation for --source-currency when --source-customer is used, which will cause undefined to be sent in the API request

Confidence Score: 4/5

  • This PR is safe to merge after fixing the validation issue in quotes.ts
  • Score reflects well-structured code with proper error handling, validation patterns, and comprehensive functionality, but a critical validation bug in the quotes command prevents a higher score
  • cli/src/commands/quotes.ts requires fixing the missing --source-currency validation

Important Files Changed

Filename Overview
cli/src/validation.ts adds validation utilities for dates, amounts, currencies, customer types, and lock sides
cli/src/commands/quotes.ts implements quote management commands with validation issue when source-customer is used
cli/src/commands/configure.ts implements interactive credential configuration with validation and hidden password input
cli/src/client.ts adds timeout support and improved error handling for HTTP requests

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI
    participant Config
    participant GridClient
    participant GridAPI

    Note over User,GridAPI: Initial Setup
    User->>CLI: configure command
    CLI->>User: prompt for credentials
    User->>CLI: provide token ID & secret
    CLI->>GridAPI: test credentials (GET /config)
    GridAPI-->>CLI: 200 OK
    CLI->>Config: saveCredentials()
    Config-->>CLI: credentials saved
    CLI->>User: success message

    Note over User,GridAPI: Creating a Quote & Transfer
    User->>CLI: quotes create --amount 1000 --lock-side SENDING
    CLI->>Config: loadConfig()
    Config-->>CLI: credentials
    CLI->>CLI: validate inputs
    CLI->>GridClient: new GridClient(config)
    GridClient->>GridAPI: POST /quotes (with Basic Auth)
    GridAPI-->>GridClient: quote response
    GridClient-->>CLI: ApiResponse<Quote>
    CLI->>CLI: formatOutput()
    CLI->>User: display quote details

    User->>CLI: quotes execute <quoteId>
    CLI->>GridClient: POST /quotes/{id}/execute
    GridClient->>GridAPI: execute quote
    GridAPI-->>GridClient: transaction created
    GridClient-->>CLI: ApiResponse<Quote>
    CLI->>User: display result

    Note over User,GridAPI: Managing Customers & Accounts
    User->>CLI: customers create --platform-id user123
    CLI->>CLI: validateCustomerType()
    CLI->>GridClient: POST /customers
    GridClient->>GridAPI: create customer
    GridAPI-->>GridClient: customer response
    GridClient-->>CLI: ApiResponse<Customer>
    CLI->>User: display customer

    User->>CLI: accounts external create --customer-id cust_123
    CLI->>CLI: validateCurrency()
    CLI->>GridClient: POST /customers/external-accounts
    GridClient->>GridAPI: create external account
    GridAPI-->>GridClient: account response
    GridClient-->>CLI: ApiResponse<ExternalAccount>
    CLI->>User: display account

    Note over User,GridAPI: Sandbox Testing
    User->>CLI: sandbox fund <accountId> --amount 10000
    CLI->>CLI: validateAmount()
    CLI->>GridClient: POST /sandbox/internal-accounts/{id}/fund
    GridClient->>GridAPI: fund account (sandbox only)
    GridAPI-->>GridClient: success
    GridClient-->>CLI: ApiResponse
    CLI->>User: display result
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +145 to +152
if (options.sourceAccount) {
body.source = { accountId: options.sourceAccount };
} else if (options.sourceCustomer) {
body.source = {
customerId: options.sourceCustomer,
currency: options.sourceCurrency,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing validation for required --source-currency when using --source-customer

when --source-customer is provided, --source-currency is required but not validated

Suggested change
if (options.sourceAccount) {
body.source = { accountId: options.sourceAccount };
} else if (options.sourceCustomer) {
body.source = {
customerId: options.sourceCustomer,
currency: options.sourceCurrency,
};
}
if (options.sourceAccount) {
body.source = { accountId: options.sourceAccount };
} else if (options.sourceCustomer) {
if (!options.sourceCurrency) {
output(formatError("--source-currency is required when using --source-customer"));
process.exitCode = 1;
return;
}
body.source = {
Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/commands/quotes.ts
Line: 145:152

Comment:
missing validation for required `--source-currency` when using `--source-customer`

when `--source-customer` is provided, `--source-currency` is required but not validated

```suggestion
      if (options.sourceAccount) {
        body.source = { accountId: options.sourceAccount };
      } else if (options.sourceCustomer) {
        if (!options.sourceCurrency) {
          output(formatError("--source-currency is required when using --source-customer"));
          process.exitCode = 1;
          return;
        }
        body.source = {
```

How can I resolve this? If you propose a fix, please make it concise.

@jklein24 jklein24 force-pushed the jk/grid-cli-commands branch from 8adaf9e to c534755 Compare February 1, 2026 08:05
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +147 to +150
} else if (options.sourceCustomer) {
body.source = {
customerId: options.sourceCustomer,
currency: options.sourceCurrency,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--source-currency is required but not validated when using --source-customer

Suggested change
} else if (options.sourceCustomer) {
body.source = {
customerId: options.sourceCustomer,
currency: options.sourceCurrency,
} else if (options.sourceCustomer) {
if (!options.sourceCurrency) {
output(formatError("--source-currency is required when using --source-customer"));
process.exitCode = 1;
return;
}
body.source = {
customerId: options.sourceCustomer,
currency: options.sourceCurrency,
};
Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/commands/quotes.ts
Line: 147:150

Comment:
`--source-currency` is required but not validated when using `--source-customer`

```suggestion
      } else if (options.sourceCustomer) {
        if (!options.sourceCurrency) {
          output(formatError("--source-currency is required when using --source-customer"));
          process.exitCode = 1;
          return;
        }
        body.source = {
          customerId: options.sourceCustomer,
          currency: options.sourceCurrency,
        };
```

How can I resolve this? If you propose a fix, please make it concise.

@jklein24 jklein24 requested a review from shreyav February 3, 2026 19:58
JasonCWang
JasonCWang previously approved these changes Feb 4, 2026
Base automatically changed from jk/grid-cli-core to main February 4, 2026 06:48
@jklein24 jklein24 dismissed JasonCWang’s stale review February 4, 2026 06:48

The base branch was changed.

jklein24 and others added 3 commits February 3, 2026 22:49
Commands for interacting with the Grid API:
- config: Get/update platform configuration
- customers: List, get, create, update, delete customers and generate KYC links
- accounts: List internal accounts (balances), list/create external accounts
- quotes: List, get, create, execute cross-currency transfer quotes
- transactions: List, get, approve, reject transactions
- transfers: Same-currency transfer-in and transfer-out
- receiver: Look up UMA addresses and external accounts
- sandbox: Fund accounts, simulate send/receive in sandbox mode
- Add interactive `grid configure` command for credential setup
- Add input validation for dates, amounts, currencies before API calls
- Add confirmation prompt for destructive operations (customer delete)
- Add --format option (json/table) with colored JSON output
- Add --no-color flag for disabling colors
- Add command aliases: cust, tx, acct
- Add 30s request timeout to prevent hanging
- Add .gitignore for dist/ and node_modules/
- Add Node.js engine requirement (>=18.0.0)
- Fix parseInt calls to use radix 10
- Improve JSON parse error messages in config loading
- Read version from package.json instead of hardcoding
- Update README with new features and examples

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jklein24 jklein24 force-pushed the jk/grid-cli-commands branch from c534755 to 2d4aaa9 Compare February 4, 2026 06:49
Copy link

@restamp-bot restamp-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2d4aaa9 is a pure rebase onto 012b259. Approving based on @JasonCWang's previous approval of c534755.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +147 to +151
} else if (options.sourceCustomer) {
body.source = {
customerId: options.sourceCustomer,
currency: options.sourceCurrency,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--source-currency is required when --source-customer is provided, but not validated before being used on line 150. This will result in currency: undefined being sent in the request body.

Suggested change
} else if (options.sourceCustomer) {
body.source = {
customerId: options.sourceCustomer,
currency: options.sourceCurrency,
};
} else if (options.sourceCustomer) {
if (!options.sourceCurrency) {
output(formatError("--source-currency is required when using --source-customer"));
process.exitCode = 1;
return;
}
body.source = {
customerId: options.sourceCustomer,
currency: options.sourceCurrency,
};
Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/commands/quotes.ts
Line: 147:151

Comment:
`--source-currency` is required when `--source-customer` is provided, but not validated before being used on line 150. This will result in `currency: undefined` being sent in the request body.

```suggestion
      } else if (options.sourceCustomer) {
        if (!options.sourceCurrency) {
          output(formatError("--source-currency is required when using --source-customer"));
          process.exitCode = 1;
          return;
        }
        body.source = {
          customerId: options.sourceCustomer,
          currency: options.sourceCurrency,
        };
```

How can I resolve this? If you propose a fix, please make it concise.

@jklein24 jklein24 merged commit 3d24889 into main Feb 4, 2026
4 checks passed
@jklein24 jklein24 deleted the jk/grid-cli-commands branch February 4, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants