Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
e7f67f3 to
2da2ad3
Compare
6bbe4ee to
9ee8dd9
Compare
f4e9275 to
294da99
Compare
Greptile OverviewGreptile SummaryThis PR implements a comprehensive CLI for the Grid API, adding commands for managing customers, accounts, quotes, transactions, transfers, and sandbox testing. Major additions:
Issue found:
Confidence Score: 4/5
|
| 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
| if (options.sourceAccount) { | ||
| body.source = { accountId: options.sourceAccount }; | ||
| } else if (options.sourceCustomer) { | ||
| body.source = { | ||
| customerId: options.sourceCustomer, | ||
| currency: options.sourceCurrency, | ||
| }; | ||
| } |
There was a problem hiding this comment.
missing validation for required --source-currency when using --source-customer
when --source-customer is provided, --source-currency is required but not validated
| 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.8adaf9e to
c534755
Compare
| } else if (options.sourceCustomer) { | ||
| body.source = { | ||
| customerId: options.sourceCustomer, | ||
| currency: options.sourceCurrency, |
There was a problem hiding this comment.
--source-currency is required but not validated when using --source-customer
| } 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.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>
c534755 to
2d4aaa9
Compare
There was a problem hiding this comment.
2d4aaa9 is a pure rebase onto 012b259. Approving based on @JasonCWang's previous approval of c534755.
| } else if (options.sourceCustomer) { | ||
| body.source = { | ||
| customerId: options.sourceCustomer, | ||
| currency: options.sourceCurrency, | ||
| }; |
There was a problem hiding this 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.
| } 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.
Commands for interacting with the Grid API: