@overcast-xyz/cli 0.1.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.
Files changed (44) hide show
  1. package/README.md +272 -0
  2. package/dist/bin.d.ts +2 -0
  3. package/dist/bin.js +200 -0
  4. package/dist/client.d.ts +12 -0
  5. package/dist/client.js +18 -0
  6. package/dist/commands/accept.d.ts +11 -0
  7. package/dist/commands/accept.js +112 -0
  8. package/dist/commands/assets.d.ts +9 -0
  9. package/dist/commands/assets.js +80 -0
  10. package/dist/commands/balance.d.ts +9 -0
  11. package/dist/commands/balance.js +74 -0
  12. package/dist/commands/deposit.d.ts +7 -0
  13. package/dist/commands/deposit.js +67 -0
  14. package/dist/commands/exercise.d.ts +14 -0
  15. package/dist/commands/exercise.js +88 -0
  16. package/dist/commands/key.d.ts +15 -0
  17. package/dist/commands/key.js +98 -0
  18. package/dist/commands/mm-webhook.d.ts +36 -0
  19. package/dist/commands/mm-webhook.js +152 -0
  20. package/dist/commands/mm.d.ts +37 -0
  21. package/dist/commands/mm.js +345 -0
  22. package/dist/commands/offer.d.ts +29 -0
  23. package/dist/commands/offer.js +149 -0
  24. package/dist/commands/option.d.ts +28 -0
  25. package/dist/commands/option.js +138 -0
  26. package/dist/commands/quote-webhook.d.ts +36 -0
  27. package/dist/commands/quote-webhook.js +152 -0
  28. package/dist/commands/quote.d.ts +37 -0
  29. package/dist/commands/quote.js +345 -0
  30. package/dist/commands/redeem.d.ts +14 -0
  31. package/dist/commands/redeem.js +88 -0
  32. package/dist/commands/rfq-view.d.ts +25 -0
  33. package/dist/commands/rfq-view.js +172 -0
  34. package/dist/commands/rfq.d.ts +4 -0
  35. package/dist/commands/rfq.js +280 -0
  36. package/dist/commands/shared.d.ts +81 -0
  37. package/dist/commands/shared.js +296 -0
  38. package/dist/commands/withdraw.d.ts +7 -0
  39. package/dist/commands/withdraw.js +67 -0
  40. package/dist/config.d.ts +53 -0
  41. package/dist/config.js +58 -0
  42. package/dist/index.d.ts +18 -0
  43. package/dist/index.js +50 -0
  44. package/package.json +38 -0
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.withdraw = withdraw;
40
+ const p = __importStar(require("@clack/prompts"));
41
+ const picocolors_1 = __importDefault(require("picocolors"));
42
+ const client_1 = require("../client");
43
+ const config_1 = require("../config");
44
+ const shared_1 = require("./shared");
45
+ /** `overcast withdraw` — pull funds back out of the wallet's escrow vault. */
46
+ async function withdraw(opts) {
47
+ const config = (0, config_1.resolveConfig)(opts);
48
+ const app = await (0, client_1.createClient)(config);
49
+ const mint = opts.mint ?? (await (0, shared_1.promptMint)("Mint to withdraw"));
50
+ const amount = opts.amount
51
+ ? BigInt(opts.amount)
52
+ : await (0, shared_1.promptAmount)("Amount to withdraw (native units)");
53
+ const spinner = p.spinner();
54
+ spinner.start(`Withdrawing ${amount} of ${mint}`);
55
+ try {
56
+ const { hash } = await app.chain.withdraw({
57
+ withdrawer: app.publicKey,
58
+ mint,
59
+ amount,
60
+ });
61
+ spinner.stop(picocolors_1.default.green(`Withdrew. tx ${picocolors_1.default.bold(hash)}`));
62
+ }
63
+ catch (err) {
64
+ spinner.stop(picocolors_1.default.red(`Withdraw failed: ${err.message}`));
65
+ throw err;
66
+ }
67
+ }
@@ -0,0 +1,53 @@
1
+ import { SolanaConfig } from "@overcast-xyz/solana-client";
2
+ /** Connection + wallet configuration resolved from CLI flags and the environment. */
3
+ export interface CliConfig {
4
+ /** Solana RPC endpoint. */
5
+ rpcUrl: string;
6
+ /** Base URL of the Overcast backend (the RFQ socket.io server). */
7
+ backendUrl: string;
8
+ /**
9
+ * Inlined signing key material — a raw JSON byte array string or a
10
+ * base58-encoded secret key. Any `id.json` file path is already resolved to
11
+ * its contents here, so `solana-client` never touches the filesystem.
12
+ *
13
+ * `undefined` for a read-only client (no keypair supplied): on-chain reads
14
+ * work, but anything that signs / needs a wallet identity will throw.
15
+ */
16
+ privateKey?: string;
17
+ /**
18
+ * The transport to use, either websocket or polling
19
+ */
20
+ transport?: "polling" | "websocket";
21
+ }
22
+ /** Global flags every command accepts (set on the root commander program). */
23
+ export interface GlobalFlags {
24
+ keypair?: string;
25
+ rpc?: string;
26
+ backend?: string;
27
+ transport?: "polling" | "websocket";
28
+ }
29
+ /** Options controlling how {@link resolveConfig} treats a missing keypair. */
30
+ export interface ResolveConfigOptions {
31
+ /**
32
+ * Allow the keypair to be absent — for read-only commands that never sign.
33
+ * The resulting {@link CliConfig.privateKey} is `undefined` and the client is
34
+ * built read-only. Defaults to `false` (a wallet is required).
35
+ */
36
+ keypairOptional?: boolean;
37
+ }
38
+ /**
39
+ * Resolve {@link CliConfig} from flags first, then environment, then localhost
40
+ * defaults. The keypair is required unless `keypairOptional` is set (read-only
41
+ * commands); everything else has a sane default.
42
+ *
43
+ * Keypair sources (via `--keypair` or `OVERCAST_KEYPAIR`):
44
+ * - a path to a Solana CLI `id.json` file,
45
+ * - a raw JSON byte array string, or
46
+ * - a base58-encoded secret key string.
47
+ *
48
+ * A file path is read here (the CLI owns filesystem access) so only inlined key
49
+ * material is handed to `solana-client`.
50
+ */
51
+ export declare function resolveConfig(flags: GlobalFlags, options?: ResolveConfigOptions): CliConfig;
52
+ /** Map the CLI config onto the {@link SolanaConfig} the client + signer expect. */
53
+ export declare function toSolanaConfig(config: CliConfig): SolanaConfig;
package/dist/config.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveConfig = resolveConfig;
4
+ exports.toSolanaConfig = toSolanaConfig;
5
+ const fs_1 = require("fs");
6
+ const solana_program_1 = require("@overcast-xyz/solana-program");
7
+ const DEFAULT_RPC_URL = "http://127.0.0.1:8899";
8
+ const DEFAULT_BACKEND_URL = "http://127.0.0.1:3000";
9
+ /**
10
+ * Resolve {@link CliConfig} from flags first, then environment, then localhost
11
+ * defaults. The keypair is required unless `keypairOptional` is set (read-only
12
+ * commands); everything else has a sane default.
13
+ *
14
+ * Keypair sources (via `--keypair` or `OVERCAST_KEYPAIR`):
15
+ * - a path to a Solana CLI `id.json` file,
16
+ * - a raw JSON byte array string, or
17
+ * - a base58-encoded secret key string.
18
+ *
19
+ * A file path is read here (the CLI owns filesystem access) so only inlined key
20
+ * material is handed to `solana-client`.
21
+ */
22
+ function resolveConfig(flags, options = {}) {
23
+ const rpcUrl = flags.rpc ?? process.env.SOLANA_RPC_URL ?? DEFAULT_RPC_URL;
24
+ const backendUrl = flags.backend ?? process.env.OVERCAST_BACKEND_URL ?? DEFAULT_BACKEND_URL;
25
+ const rawKey = flags.keypair ?? process.env.OVERCAST_KEYPAIR;
26
+ if (!rawKey && !options.keypairOptional) {
27
+ throw new Error("no wallet: pass --keypair <path|base58|json> or set OVERCAST_KEYPAIR");
28
+ }
29
+ return {
30
+ rpcUrl,
31
+ backendUrl,
32
+ privateKey: rawKey ? maybeReadFile(rawKey) : undefined,
33
+ transport: flags.transport,
34
+ };
35
+ }
36
+ /** Map the CLI config onto the {@link SolanaConfig} the client + signer expect. */
37
+ function toSolanaConfig(config) {
38
+ return {
39
+ rpcUrl: config.rpcUrl,
40
+ backend: config.backendUrl,
41
+ privateKey: config.privateKey,
42
+ domain: solana_program_1.SOLANA_DOMAIN,
43
+ transport: config.transport,
44
+ };
45
+ }
46
+ /** If `raw` points at an existing file, return its contents; otherwise `raw`. */
47
+ function maybeReadFile(raw) {
48
+ const trimmed = raw.trim();
49
+ // A base58 secret key or JSON array never looks like a plausible file path.
50
+ if (trimmed.startsWith("["))
51
+ return trimmed;
52
+ try {
53
+ return (0, fs_1.readFileSync)(trimmed, "utf8").trim();
54
+ }
55
+ catch {
56
+ return trimmed;
57
+ }
58
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `@overcast-xyz/cli` — programmatic entry points. The executable lives in `bin.ts`;
3
+ * these exports let the command implementations be reused or tested.
4
+ */
5
+ export * from "./config";
6
+ export * from "./client";
7
+ export { deposit } from "./commands/deposit";
8
+ export { withdraw } from "./commands/withdraw";
9
+ export { balance } from "./commands/balance";
10
+ export { optionShow, optionList } from "./commands/option";
11
+ export { offerShow, offerList } from "./commands/offer";
12
+ export { assetsList } from "./commands/assets";
13
+ export { accept } from "./commands/accept";
14
+ export { exercise } from "./commands/exercise";
15
+ export { keyAdd, keyRemove } from "./commands/key";
16
+ export { redeem } from "./commands/redeem";
17
+ export { rfqCreate } from "./commands/rfq";
18
+ export { runQuoter } from "./commands/quote";
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.runQuoter = exports.rfqCreate = exports.redeem = exports.keyRemove = exports.keyAdd = exports.exercise = exports.accept = exports.assetsList = exports.offerList = exports.offerShow = exports.optionList = exports.optionShow = exports.balance = exports.withdraw = exports.deposit = void 0;
18
+ /**
19
+ * `@overcast-xyz/cli` — programmatic entry points. The executable lives in `bin.ts`;
20
+ * these exports let the command implementations be reused or tested.
21
+ */
22
+ __exportStar(require("./config"), exports);
23
+ __exportStar(require("./client"), exports);
24
+ var deposit_1 = require("./commands/deposit");
25
+ Object.defineProperty(exports, "deposit", { enumerable: true, get: function () { return deposit_1.deposit; } });
26
+ var withdraw_1 = require("./commands/withdraw");
27
+ Object.defineProperty(exports, "withdraw", { enumerable: true, get: function () { return withdraw_1.withdraw; } });
28
+ var balance_1 = require("./commands/balance");
29
+ Object.defineProperty(exports, "balance", { enumerable: true, get: function () { return balance_1.balance; } });
30
+ var option_1 = require("./commands/option");
31
+ Object.defineProperty(exports, "optionShow", { enumerable: true, get: function () { return option_1.optionShow; } });
32
+ Object.defineProperty(exports, "optionList", { enumerable: true, get: function () { return option_1.optionList; } });
33
+ var offer_1 = require("./commands/offer");
34
+ Object.defineProperty(exports, "offerShow", { enumerable: true, get: function () { return offer_1.offerShow; } });
35
+ Object.defineProperty(exports, "offerList", { enumerable: true, get: function () { return offer_1.offerList; } });
36
+ var assets_1 = require("./commands/assets");
37
+ Object.defineProperty(exports, "assetsList", { enumerable: true, get: function () { return assets_1.assetsList; } });
38
+ var accept_1 = require("./commands/accept");
39
+ Object.defineProperty(exports, "accept", { enumerable: true, get: function () { return accept_1.accept; } });
40
+ var exercise_1 = require("./commands/exercise");
41
+ Object.defineProperty(exports, "exercise", { enumerable: true, get: function () { return exercise_1.exercise; } });
42
+ var key_1 = require("./commands/key");
43
+ Object.defineProperty(exports, "keyAdd", { enumerable: true, get: function () { return key_1.keyAdd; } });
44
+ Object.defineProperty(exports, "keyRemove", { enumerable: true, get: function () { return key_1.keyRemove; } });
45
+ var redeem_1 = require("./commands/redeem");
46
+ Object.defineProperty(exports, "redeem", { enumerable: true, get: function () { return redeem_1.redeem; } });
47
+ var rfq_1 = require("./commands/rfq");
48
+ Object.defineProperty(exports, "rfqCreate", { enumerable: true, get: function () { return rfq_1.rfqCreate; } });
49
+ var quote_1 = require("./commands/quote");
50
+ Object.defineProperty(exports, "runQuoter", { enumerable: true, get: function () { return quote_1.runQuoter; } });
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@overcast-xyz/cli",
3
+ "version": "0.1.0",
4
+ "description": "CLI for the Overcast Solana protocol: deposits, withdrawals and the RFQ engine (user + RFQ quoter).",
5
+ "license": "Apache-2.0",
6
+ "author": "info@overcast.xyz",
7
+ "keywords": [
8
+ "solana",
9
+ "overcast-cli"
10
+ ],
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "bin": {
14
+ "overcast": "dist/bin.js"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@clack/prompts": "^0.8.2",
21
+ "@overcast-xyz/solana-program": "0.1.1",
22
+ "commander": "^12.1.0",
23
+ "picocolors": "^1.1.1",
24
+ "@overcast-xyz/solana-client": "0.1.0",
25
+ "@overcast-xyz/core": "0.1.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^20.0.0",
29
+ "esbuild": "^0.28.1",
30
+ "typescript": "^5.7.3"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc -p tsconfig.json",
34
+ "bundle": "node build.mjs",
35
+ "clean": "rm -rf dist dist-bundle index.js",
36
+ "start": "node dist/bin.js"
37
+ }
38
+ }