Skip to content

Commit 9bc9958

Browse files
committed
address review comments
1 parent 4656eff commit 9bc9958

File tree

6 files changed

+64
-52
lines changed

6 files changed

+64
-52
lines changed
Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
# Test Signer CLI
22

3-
Command-line helper for drafting, signing, and broadcasting Mina payments via the public GraphQL API. It wraps the `mina-signer` library so you can submit transactions without wiring up a full wallet or SDK.
3+
Command-line helper for drafting, signing, and broadcasting Mina payments via
4+
the public GraphQL API. It wraps the `mina-signer` library so you can submit
5+
transactions without wiring up a full wallet or SDK.
46

57
## Getting Started
8+
69
- **Prerequisites:** Node.js 18+ (for native `fetch`) and npm.
710
- **Install dependencies:** `npm install`
8-
- **Quick run:** `node mina-test-signer.js <private_key> <recipient_address> [graphql_url] [nonce]`
11+
- **Quick run:**
12+
`node mina-test-signer.js <private_key> <recipient_address> [graphql_url] [nonce]`
913

10-
The optional `graphql_url` flag lets you override the default target defined in `config.js`.
14+
The optional `graphql_url` flag lets you override the default target defined in
15+
`config.js`.
1116

1217
## Workflow
18+
1319
1. `mina-test-signer.js` parses CLI arguments and wires the supporting services.
14-
2. `payment-service.js` derives the sender public key, composes a payment payload, and signs it with `mina-signer`.
15-
3. `graphql-client.js` sends the signed payload to the Mina daemon and can check whether the transaction reached the pool.
16-
4. `utils.js` provides small helpers for GraphQL string construction and CLI validation.
17-
5. `config.js` centralises network defaults and usage messaging.
18-
19-
- `mina-test-signer.js` – CLI entry point orchestrating validation, signing, submission, and pool verification.
20-
- `payment-service.js` – Thin wrapper around `mina-signer` with sensible defaults for MINA amounts and fees.
21-
- `graphql-client.js` – Minimal fetch-based GraphQL transport for sending payments and querying pooled commands.
22-
- `utils.js` – GraphQL stringification helpers plus basic CLI argument validation/parsing.
20+
2. `graphql-client.js` sends the signed payload to the Mina daemon and can check
21+
whether the transaction reached the pool.
22+
3. `utils.js` provides small helpers for GraphQL string construction and CLI
23+
validation.
24+
4. `config.js` centralises network defaults and usage messaging.
25+
26+
- `mina-test-signer.js` – CLI entry point orchestrating validation, signing,
27+
submission, and pool verification.
28+
- `payment-service.js` – Thin wrapper around `mina-signer` with sensible
29+
defaults for MINA amounts and fees.
30+
- `graphql-client.js` – Minimal fetch-based GraphQL transport for sending
31+
payments and querying pooled commands.
32+
- `utils.js` – GraphQL stringification helpers plus basic CLI argument
33+
validation/parsing.
2334
- `config.js` – Configuration constants and usage text surfaced by the CLI.
24-
- `key/` – Sample key material for experimentation; do not use in production environments.
35+
- `key/` – Sample key material for experimentation; do not use in production
36+
environments.
2537

26-
Check the console output for a transaction id; you can re-run the pool check or the `getPooledUserCommands` helper to confirm inclusion.
27-
Provide a `nonce` argument when you need to synchronise with on-chain account state manually.
28-
The CLI prints emoji-enhanced step logs and a summary table so you can spot successes and failures at a glance.
29-
GraphQL errors (including malformed responses) cause the CLI to exit with a non-zero status so they can be surfaced in scripts and CI.
30-
31-
## Customisation Tips
32-
- Update `CONFIG.DEFAULT_GRAPHQL_URL` in `config.js` to point at your daemon or a hosted GraphQL endpoint.
33-
- Tweak `CONFIG.MINA_UNITS.DEFAULT_AMOUNT_MULTIPLIER` and `DEFAULT_FEE_MULTIPLIER` to adjust the default transaction values.
34-
- Extend `GraphQLClient` with additional queries (e.g. account state, balances) if you need richer diagnostics.
38+
Check the console output for a transaction id; you can re-run the pool check or
39+
the `getPooledUserCommands` helper to confirm inclusion. Provide a `nonce`
40+
argument when you need to synchronise with on-chain account state manually. The
41+
CLI prints emoji-enhanced step logs and a summary table so you can spot
42+
successes and failures at a glance. GraphQL errors (including malformed
43+
responses) cause the CLI to exit with a non-zero status so they can be surfaced
44+
in scripts and CI.
3545

3646
## Private key format
3747

@@ -42,5 +52,8 @@ For clarity, private key is in output format of:
4252
```
4353

4454
## Safety Notes
45-
- Treat private keys in plain text with care. Prefer environment variables or a secure secrets manager for real deployments.
46-
- The example keys under `key/` are for local testing only; they are publicly known and should never hold funds.
55+
56+
- Treat private keys in plain text with care. Prefer environment variables or a
57+
secure secrets manager for real deployments.
58+
- The example keys under `key/` are for local testing only; they are publicly
59+
known and should never hold funds.

src/mina-signer/tests/mina-signer-test-app/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export const CONFIG = {
1414
};
1515

1616
/**
17-
* Human-friendly CLI usage text that `test-signer.js` displays when
17+
* Human-friendly CLI usage text that `mina-test-signer.js` displays when
1818
* the caller provides incomplete arguments.
1919
*/
2020
export const USAGE_INFO = {
21-
message: 'Usage: node test-signer.js <private_key> <recipient_address> [graphql_url] [nonce]',
22-
example: 'Example: node test-signer.js EKErBK1KznrJJY3raJafSyxSayJ6viejaVrmjzXkSmoxXiJQsesU B62qp4wcxoJyFFyXZ2RVw8kGPpWn6ncK4RtsTz29jFf6fY2XYN42R1v http://172.17.0.3:3085/graphql 3',
21+
message: 'Usage: node mina-test-signer.js <private_key> <recipient_address> [graphql_url] [nonce]',
22+
example: 'Example: node mina-test-signer.js EKErBK1KznrJJY3raJafSyxSayJ6viejaVrmjzXkSmoxXiJQsesU B62qp4wcxoJyFFyXZ2RVw8kGPpWn6ncK4RtsTz29jFf6fY2XYN42R1v http://172.17.0.3:3085/graphql 3',
2323
defaultUrl: `Default GraphQL URL: ${CONFIG.DEFAULT_GRAPHQL_URL}`
2424
};

src/mina-signer/tests/mina-signer-test-app/graphql-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class GraphQLClient {
2626
const response = await fetch(this.url, {
2727
method: 'POST',
2828
headers: { 'Content-Type': 'application/json' },
29-
body: JSON.stringify({ operationName: null, query, variables: {} }),
29+
body: JSON.stringify({ query }),
3030
});
3131

3232
return await this.handleResponse(response);

src/mina-signer/tests/mina-signer-test-app/mina-test-signer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* - Submit the signed payload to a Mina daemon and verify it reached the pool
1010
*
1111
* Usage:
12-
* node test-signer.js --private-key <key> --recipient <address> [--url <graphql_url>] [--nonce <nonce>]
12+
* node mina-test-signer.js --private-key <key> --recipient <address> [--url <graphql_url>] [--nonce <nonce>]
1313
*/
1414
import { Command } from 'commander';
1515
import { GraphQLClient } from './graphql-client.js';

src/mina-signer/tests/mina-signer-test-app/package-lock.json

Lines changed: 18 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "test-signer",
2+
"name": "mina-test-signer",
33
"type": "module",
44
"version": "1.0.0",
5-
"main": "test-signer.js",
5+
"main": "mina-test-signer.js",
66
"bin": {
77
"mina-test-signer": "mina-test-signer.js"
88
},
@@ -12,10 +12,10 @@
1212
},
1313
"author": "o1-labs",
1414
"license": "ISC",
15-
"description": "test app for mina-test-signer",
15+
"description": "test app for mina-signer",
1616
"dependencies": {
1717
"commander": "^14.0.2",
1818
"json-to-graphql-query": "^2.3.0",
19-
"mina-signer": "^1.7.0"
19+
"mina-signer": "../../../mina-signer"
2020
}
2121
}

0 commit comments

Comments
 (0)