@gonkfun/cli 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/gonk-cli.mjs +30 -0
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Gonk CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read public Solana data from [gonk.fun](https://gonk.fun). Requires Node.js 22 or later. No account, wallet, or API key is needed. The CLI cannot submit transactions.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx @gonkfun/cli status
|
|
7
|
+
npx @gonkfun/cli coins
|
|
8
|
+
npx @gonkfun/cli coin <mint>
|
|
9
|
+
npx @gonkfun/cli balance <wallet> <mint>
|
|
10
|
+
npx @gonkfun/cli quotes
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`quotes` lists supported quote tokens; it does not request an executable trade quote. Use `So11111111111111111111111111111111111111112` as the mint for a native SOL balance. Successful commands print JSON. Invalid commands exit with code 2; API and network failures exit with code 1.
|
|
14
|
+
|
|
15
|
+
See the [Gonk API guide](https://gonk.fun/api-guide.md) for the data schema and limits.
|
package/gonk-cli.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const base = 'https://api.gonk.fun/api/solana/v1';
|
|
3
|
+
const routes = { status: '/status', quotes: '/quotes', coins: '/coins' };
|
|
4
|
+
const address = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
5
|
+
const [command, a, b, ...rest] = process.argv.slice(2);
|
|
6
|
+
if (!command || ['-h', '--help'].includes(command)) {
|
|
7
|
+
console.log('Usage: node gonk-cli.mjs status | quotes | coins | coin <mint> | balance <wallet> <mint>\nPublic Solana data only. Native SOL mint: So11111111111111111111111111111111111111112');
|
|
8
|
+
} else {
|
|
9
|
+
const path = rest.length ? null : Object.hasOwn(routes, command) && !a ? routes[command]
|
|
10
|
+
: command === 'coin' && address.test(a ?? '') && !b ? '/coins/' + a
|
|
11
|
+
: command === 'balance' && address.test(a ?? '') && address.test(b ?? '') ? '/holdings/' + a + '/' + b : null;
|
|
12
|
+
if (!path) {
|
|
13
|
+
console.error('Invalid command or address. Use --help.');
|
|
14
|
+
process.exitCode = 2;
|
|
15
|
+
} else {
|
|
16
|
+
try {
|
|
17
|
+
const response = await fetch(base + path, { headers: { Accept: 'application/json' }, signal: AbortSignal.timeout(15000) });
|
|
18
|
+
const data = await response.json();
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
console.error(JSON.stringify(data, null, 2));
|
|
21
|
+
const retry = response.headers.get('Retry-After');
|
|
22
|
+
if (retry) console.error('Retry-After:', retry);
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
} else console.log(JSON.stringify(data, null, 2));
|
|
25
|
+
} catch {
|
|
26
|
+
console.error('Could not reach the Gonk public API.');
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gonkfun/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Read public Solana launchpad and coin data from gonk.fun",
|
|
5
|
+
"bin": { "gonk": "./gonk-cli.mjs" },
|
|
6
|
+
"files": ["gonk-cli.mjs", "README.md"],
|
|
7
|
+
"scripts": { "prepack": "node prepare-package.mjs" },
|
|
8
|
+
"engines": { "node": ">=22" },
|
|
9
|
+
"license": "UNLICENSED",
|
|
10
|
+
"homepage": "https://gonk.fun/docs",
|
|
11
|
+
"author": "gonk.fun <contact@gonk.fun>",
|
|
12
|
+
"publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" }
|
|
13
|
+
}
|