whale-market-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 (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +322 -0
  3. package/bin/whales +2 -0
  4. package/dist/api.d.ts +29 -0
  5. package/dist/api.d.ts.map +1 -0
  6. package/dist/api.js +98 -0
  7. package/dist/api.js.map +1 -0
  8. package/dist/auth.d.ts +11 -0
  9. package/dist/auth.d.ts.map +1 -0
  10. package/dist/auth.js +83 -0
  11. package/dist/auth.js.map +1 -0
  12. package/dist/commands/help.d.ts +3 -0
  13. package/dist/commands/help.d.ts.map +1 -0
  14. package/dist/commands/help.js +146 -0
  15. package/dist/commands/help.js.map +1 -0
  16. package/dist/commands/networks.d.ts +3 -0
  17. package/dist/commands/networks.d.ts.map +1 -0
  18. package/dist/commands/networks.js +27 -0
  19. package/dist/commands/networks.js.map +1 -0
  20. package/dist/commands/offers.d.ts +3 -0
  21. package/dist/commands/offers.d.ts.map +1 -0
  22. package/dist/commands/offers.js +121 -0
  23. package/dist/commands/offers.js.map +1 -0
  24. package/dist/commands/orderbook.d.ts +3 -0
  25. package/dist/commands/orderbook.d.ts.map +1 -0
  26. package/dist/commands/orderbook.js +127 -0
  27. package/dist/commands/orderbook.js.map +1 -0
  28. package/dist/commands/orders.d.ts +3 -0
  29. package/dist/commands/orders.d.ts.map +1 -0
  30. package/dist/commands/orders.js +119 -0
  31. package/dist/commands/orders.js.map +1 -0
  32. package/dist/commands/portfolio.d.ts +3 -0
  33. package/dist/commands/portfolio.d.ts.map +1 -0
  34. package/dist/commands/portfolio.js +102 -0
  35. package/dist/commands/portfolio.js.map +1 -0
  36. package/dist/commands/referral.d.ts +3 -0
  37. package/dist/commands/referral.d.ts.map +1 -0
  38. package/dist/commands/referral.js +138 -0
  39. package/dist/commands/referral.js.map +1 -0
  40. package/dist/commands/setup.d.ts +3 -0
  41. package/dist/commands/setup.d.ts.map +1 -0
  42. package/dist/commands/setup.js +133 -0
  43. package/dist/commands/setup.js.map +1 -0
  44. package/dist/commands/shell.d.ts +3 -0
  45. package/dist/commands/shell.d.ts.map +1 -0
  46. package/dist/commands/shell.js +87 -0
  47. package/dist/commands/shell.js.map +1 -0
  48. package/dist/commands/status.d.ts +3 -0
  49. package/dist/commands/status.d.ts.map +1 -0
  50. package/dist/commands/status.js +57 -0
  51. package/dist/commands/status.js.map +1 -0
  52. package/dist/commands/tokens.d.ts +3 -0
  53. package/dist/commands/tokens.d.ts.map +1 -0
  54. package/dist/commands/tokens.js +147 -0
  55. package/dist/commands/tokens.js.map +1 -0
  56. package/dist/commands/upgrade.d.ts +3 -0
  57. package/dist/commands/upgrade.d.ts.map +1 -0
  58. package/dist/commands/upgrade.js +48 -0
  59. package/dist/commands/upgrade.js.map +1 -0
  60. package/dist/commands/wallet.d.ts +3 -0
  61. package/dist/commands/wallet.d.ts.map +1 -0
  62. package/dist/commands/wallet.js +159 -0
  63. package/dist/commands/wallet.js.map +1 -0
  64. package/dist/config.d.ts +20 -0
  65. package/dist/config.d.ts.map +1 -0
  66. package/dist/config.js +49 -0
  67. package/dist/config.js.map +1 -0
  68. package/dist/index.d.ts +3 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +67 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/output/index.d.ts +7 -0
  73. package/dist/output/index.d.ts.map +1 -0
  74. package/dist/output/index.js +53 -0
  75. package/dist/output/index.js.map +1 -0
  76. package/dist/output/json.d.ts +3 -0
  77. package/dist/output/json.d.ts.map +1 -0
  78. package/dist/output/json.js +12 -0
  79. package/dist/output/json.js.map +1 -0
  80. package/dist/output/plain.d.ts +3 -0
  81. package/dist/output/plain.d.ts.map +1 -0
  82. package/dist/output/plain.js +130 -0
  83. package/dist/output/plain.js.map +1 -0
  84. package/dist/output/table.d.ts +11 -0
  85. package/dist/output/table.d.ts.map +1 -0
  86. package/dist/output/table.js +254 -0
  87. package/dist/output/table.js.map +1 -0
  88. package/dist/types.d.ts +36 -0
  89. package/dist/types.d.ts.map +1 -0
  90. package/dist/types.js +4 -0
  91. package/dist/types.js.map +1 -0
  92. package/dist/utils/format.d.ts +4 -0
  93. package/dist/utils/format.d.ts.map +1 -0
  94. package/dist/utils/format.js +26 -0
  95. package/dist/utils/format.js.map +1 -0
  96. package/dist/utils/wallet.d.ts +17 -0
  97. package/dist/utils/wallet.d.ts.map +1 -0
  98. package/dist/utils/wallet.js +84 -0
  99. package/dist/utils/wallet.js.map +1 -0
  100. package/package.json +70 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Whales Market
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,322 @@
1
+ # Whale Market CLI
2
+
3
+ A command-line interface for the Whales Market trading platform, built with Node.js and TypeScript.
4
+
5
+ **Repository:** [https://github.com/whalemarketdev/whale-market-cli](https://github.com/whalemarketdev/whale-market-cli)
6
+
7
+ ## Features
8
+
9
+ - 🐋 **Multi-chain Support**: Solana and EVM chains (Ethereum, BSC, Polygon, etc.)
10
+ - 💼 **Wallet Management**: Create, import, and manage wallets
11
+ - 📊 **Token Operations**: Browse, search, and view token details
12
+ - 💰 **Trading**: View and manage offers and orders
13
+ - 📈 **Portfolio Tracking**: Monitor your positions and portfolio
14
+ - 📚 **Order Book**: Access order book v2 operations
15
+ - 🎁 **Referral System**: Track campaigns and earnings
16
+ - 🎨 **Beautiful Output**: Table and JSON output formats
17
+ - ⚡ **Fast & Reliable**: Built with TypeScript for type safety
18
+
19
+ ## Installation
20
+
21
+ ### NPM (Recommended)
22
+
23
+ ```bash
24
+ npm install -g whale-market-cli
25
+ ```
26
+
27
+ ### Shell Script
28
+
29
+ ```bash
30
+ curl -fsSL https://raw.githubusercontent.com/whalemarketdev/whale-market-cli/main/install.sh | bash
31
+ ```
32
+
33
+ ### Requirements
34
+
35
+ - Node.js 18.0.0 or higher
36
+ - npm or yarn
37
+
38
+ ## Quick Start
39
+
40
+ ### 1. Setup
41
+
42
+ Run the interactive setup wizard:
43
+
44
+ ```bash
45
+ whales setup
46
+ ```
47
+
48
+ This will guide you through:
49
+ - Creating a new wallet or importing an existing one
50
+ - Configuring the API endpoint
51
+ - Saving your configuration
52
+
53
+ ### 2. First Commands
54
+
55
+ ```bash
56
+ # List tokens
57
+ whales tokens list
58
+
59
+ # View your offers
60
+ whales offers my
61
+
62
+ # Check your portfolio
63
+ whales portfolio show
64
+
65
+ # Get help
66
+ whales --help
67
+ ```
68
+
69
+ ## Commands
70
+
71
+ ### Setup & Configuration
72
+
73
+ - `whales setup` - Interactive first-time setup wizard
74
+ - `whales status` - Check API connectivity and wallet status
75
+ - `whales upgrade` - Self-update from npm registry
76
+
77
+ ### Wallet Management
78
+
79
+ - `whales wallet create [--type solana|evm]` - Generate new wallet
80
+ - `whales wallet import <private-key>` - Import existing wallet
81
+ - `whales wallet show` - Display wallet details
82
+ - `whales wallet address` - Show wallet address
83
+ - `whales wallet link <target-address>` - Link multiple wallets
84
+
85
+ ### Token Operations
86
+
87
+ - `whales tokens list [--status active|ended] [--chain <id>]` - List tokens
88
+ - `whales tokens get <token-id>` - Get token details
89
+ - `whales tokens search <query> [--limit <n>]` - Search tokens
90
+ - `whales tokens highlight` - Get highlighted/trending tokens
91
+ - `whales tokens stats` - Get prediction stats
92
+
93
+ ### Offer Management
94
+
95
+ - `whales offers list [--type buy|sell] [--token <symbol>]` - List all offers
96
+ - `whales offers my [--status open|filled]` - List my offers
97
+ - `whales offers get <offer-id>` - Get offer details
98
+ - `whales offers react <offer-id>` - React to an offer
99
+
100
+ ### Order Management
101
+
102
+ - `whales orders list [--token <symbol>]` - List all orders
103
+ - `whales orders my [--side buy|sell]` - List my orders
104
+ - `whales orders get <order-id>` - Get order details
105
+ - `whales orders by-offer <address>` - Orders for my offers
106
+
107
+ ### Portfolio & Positions
108
+
109
+ - `whales portfolio show [--address <addr>]` - Show portfolio summary
110
+ - `whales portfolio positions [--type open|filled]` - List positions
111
+ - `whales portfolio balance [--token <symbol>]` - Show token balances
112
+
113
+ ### Order Book V2
114
+
115
+ - `whales orderbook snapshot` - Order book snapshot statistics
116
+ - `whales orderbook positions --telegram-id <id>` - Get positions
117
+ - `whales orderbook pairs --telegram-id <id>` - List trading pairs
118
+ - `whales orderbook filled <id>` - Get filled order details
119
+
120
+ ### Referral System
121
+
122
+ - `whales referral summary [--address <addr>]` - Campaign summary
123
+ - `whales referral campaigns [--address <addr>]` - List campaigns
124
+ - `whales referral earnings [--address <addr>]` - Show earnings
125
+ - `whales referral transactions [--address <addr>]` - Get transactions
126
+
127
+ ### Utilities
128
+
129
+ - `whales networks list` - List supported blockchain networks
130
+ - `whales shell` - Interactive REPL mode
131
+
132
+ ## Output Formats
133
+
134
+ ### Table Format (Default)
135
+
136
+ ```bash
137
+ whales tokens list
138
+ ```
139
+
140
+ ```
141
+ ┌────────┬─────────────────────────────┬──────────┬────────┬───────────┬─────────────┐
142
+ │ ID │ Name │ Symbol │ Status │ Price │ Chain │
143
+ ├────────┼─────────────────────────────┼──────────┼────────┼───────────┼─────────────┤
144
+ │ 123 │ Example Token │ EXMP │ active │ $0.45 │ Solana │
145
+ └────────┴─────────────────────────────┴──────────┴────────┴───────────┴─────────────┘
146
+ ```
147
+
148
+ ### JSON Format
149
+
150
+ ```bash
151
+ whales tokens list --output json
152
+ ```
153
+
154
+ ```json
155
+ {
156
+ "data": [
157
+ {
158
+ "id": 123,
159
+ "name": "Example Token",
160
+ "symbol": "EXMP",
161
+ "status": "active",
162
+ "price": "0.45",
163
+ "chain_id": 666666
164
+ }
165
+ ]
166
+ }
167
+ ```
168
+
169
+ ## Configuration
170
+
171
+ Configuration is stored in platform-specific locations:
172
+
173
+ - **macOS**: `~/Library/Preferences/whales-market-cli/config.json`
174
+ - **Linux**: `~/.config/whales-market-cli/config.json`
175
+ - **Windows**: `%APPDATA%\whales-market-cli\config.json`
176
+
177
+ ### Environment Variables
178
+
179
+ You can override config values with environment variables:
180
+
181
+ ```bash
182
+ export WHALES_API_URL="https://api.whales.market"
183
+ export WHALES_PRIVATE_KEY="your-private-key"
184
+ export WHALES_WALLET_TYPE="solana"
185
+ export WHALES_CHAIN_ID="666666"
186
+ ```
187
+
188
+ ### Global Options
189
+
190
+ All commands support these global options:
191
+
192
+ - `-o, --output <format>` - Output format (table|json), default: table
193
+ - `-k, --private-key <key>` - Private key (overrides config)
194
+ - `--api-url <url>` - API endpoint URL
195
+ - `--chain-id <id>` - Chain ID
196
+
197
+ ## Examples
198
+
199
+ ### Browse Tokens
200
+
201
+ ```bash
202
+ # List active tokens
203
+ whales tokens list --status active --limit 10
204
+
205
+ # Search for a token
206
+ whales tokens search "example"
207
+
208
+ # Get token details
209
+ whales tokens get 123
210
+ ```
211
+
212
+ ### Manage Offers
213
+
214
+ ```bash
215
+ # View all buy offers
216
+ whales offers list --type buy
217
+
218
+ # View my open offers
219
+ whales offers my --status open
220
+
221
+ # Get offer details
222
+ whales offers get 456
223
+ ```
224
+
225
+ ### Check Portfolio
226
+
227
+ ```bash
228
+ # Show portfolio summary
229
+ whales portfolio show
230
+
231
+ # List open positions
232
+ whales portfolio positions --type open
233
+ ```
234
+
235
+ ### Use JSON Output for Scripting
236
+
237
+ ```bash
238
+ # Get tokens as JSON
239
+ whales tokens list --output json | jq '.data[0].name'
240
+
241
+ # Check if wallet is configured
242
+ whales wallet address --output json | jq -r '.address'
243
+ ```
244
+
245
+ ## Development
246
+
247
+ ### Building from Source
248
+
249
+ ```bash
250
+ # Clone repository
251
+ git clone https://github.com/whalemarketdev/whale-market-cli.git
252
+ cd whale-market-cli
253
+
254
+ # Install dependencies
255
+ npm install
256
+
257
+ # Build
258
+ npm run build
259
+
260
+ # Link for local testing
261
+ npm link
262
+
263
+ # Use CLI
264
+ whales --help
265
+ ```
266
+
267
+ ### Running Tests
268
+
269
+ ```bash
270
+ npm test
271
+ ```
272
+
273
+ ### Development Mode
274
+
275
+ ```bash
276
+ # Run with ts-node (no build needed)
277
+ npm run dev -- tokens list
278
+ ```
279
+
280
+ ## Troubleshooting
281
+
282
+ ### "No wallet configured"
283
+
284
+ Run the setup wizard:
285
+
286
+ ```bash
287
+ whales setup
288
+ ```
289
+
290
+ ### "API connection failed"
291
+
292
+ Check your API URL:
293
+
294
+ ```bash
295
+ whales status
296
+ ```
297
+
298
+ Or set it explicitly:
299
+
300
+ ```bash
301
+ whales --api-url https://api.whales.market tokens list
302
+ ```
303
+
304
+ ### "Invalid private key format"
305
+
306
+ Make sure you're using the correct format:
307
+ - **Solana**: Base58 encoded private key
308
+ - **EVM**: Hex-encoded private key (with or without 0x prefix)
309
+
310
+ ## Contributing
311
+
312
+ Contributions are welcome! Please feel free to submit a Pull Request.
313
+
314
+ ## License
315
+
316
+ MIT
317
+
318
+ ## Support
319
+
320
+ For issues and questions:
321
+ - GitHub Issues: https://github.com/whalemarketdev/whale-market-cli/issues
322
+ - Documentation: https://docs.whales.market
package/bin/whales ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/index.js');
package/dist/api.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { ApiResponse } from './types';
2
+ export declare class ApiClient {
3
+ private client;
4
+ constructor();
5
+ get<T>(url: string, params?: any): Promise<T>;
6
+ post<T>(url: string, data?: any): Promise<T>;
7
+ put<T>(url: string, data?: any): Promise<T>;
8
+ delete<T>(url: string): Promise<T>;
9
+ getTokens(params?: any): Promise<ApiResponse<any[]>>;
10
+ getToken(id: string): Promise<ApiResponse<any>>;
11
+ getOffers(params?: any): Promise<ApiResponse<any[]>>;
12
+ getOffer(id: string): Promise<ApiResponse<any>>;
13
+ getOffersByAddress(address: string): Promise<ApiResponse<any[]>>;
14
+ getOrders(params?: any): Promise<ApiResponse<any[]>>;
15
+ getOrder(id: string): Promise<ApiResponse<any>>;
16
+ getOrdersByAddress(address: string): Promise<ApiResponse<any[]>>;
17
+ getOrdersByOffer(address: string): Promise<ApiResponse<any[]>>;
18
+ getNetworks(): Promise<ApiResponse<any[]>>;
19
+ getOrderBookPositions(telegramId: string): Promise<ApiResponse<any[]>>;
20
+ getOrderBookPairs(telegramId: string): Promise<ApiResponse<any[]>>;
21
+ getOrderBookSnapshot(): Promise<ApiResponse<any>>;
22
+ getOrderBook(id: string): Promise<ApiResponse<any>>;
23
+ getReferralCampaigns(address: string): Promise<ApiResponse<any[]>>;
24
+ getReferralSummary(address: string): Promise<ApiResponse<any>>;
25
+ getReferralPerformance(address: string): Promise<ApiResponse<any[]>>;
26
+ getReferralTransactions(address: string): Promise<ApiResponse<any[]>>;
27
+ }
28
+ export declare const apiClient: ApiClient;
29
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,qBAAa,SAAS;IACpB,OAAO,CAAC,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,GAAG,EAAE,CAAC,CAAC;IAI9D,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAI1C,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAItE,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAIlE,oBAAoB,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAIjD,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAInD,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAIlE,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAI9D,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAIpE,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;CAG5E;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
package/dist/api.js ADDED
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.apiClient = exports.ApiClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const config_1 = require("./config");
9
+ class ApiClient {
10
+ constructor() {
11
+ const baseURL = config_1.config.get('apiUrl') || 'https://api.whales.market';
12
+ this.client = axios_1.default.create({
13
+ baseURL,
14
+ timeout: 30000,
15
+ headers: {
16
+ 'Content-Type': 'application/json'
17
+ }
18
+ });
19
+ // Response interceptor: handle errors
20
+ this.client.interceptors.response.use(response => response.data, (error) => {
21
+ if (error.response?.data) {
22
+ const data = error.response.data;
23
+ throw new Error(data.message || data.error || error.message);
24
+ }
25
+ throw error;
26
+ });
27
+ }
28
+ async get(url, params) {
29
+ return this.client.get(url, { params });
30
+ }
31
+ async post(url, data) {
32
+ return this.client.post(url, data);
33
+ }
34
+ async put(url, data) {
35
+ return this.client.put(url, data);
36
+ }
37
+ async delete(url) {
38
+ return this.client.delete(url);
39
+ }
40
+ // Typed API methods for common endpoints
41
+ async getTokens(params) {
42
+ return this.get('/tokens', params);
43
+ }
44
+ async getToken(id) {
45
+ return this.get(`/tokens/${id}`);
46
+ }
47
+ async getOffers(params) {
48
+ return this.get('/transactions/offers', params);
49
+ }
50
+ async getOffer(id) {
51
+ return this.get(`/transactions/offers/${id}`);
52
+ }
53
+ async getOffersByAddress(address) {
54
+ return this.get(`/transactions/offers-by-address/${address}`);
55
+ }
56
+ async getOrders(params) {
57
+ return this.get('/transactions/orders', params);
58
+ }
59
+ async getOrder(id) {
60
+ return this.get(`/transactions/orders/${id}`);
61
+ }
62
+ async getOrdersByAddress(address) {
63
+ return this.get(`/transactions/orders-by-address/${address}`);
64
+ }
65
+ async getOrdersByOffer(address) {
66
+ return this.get(`/transactions/orders-by-offer/${address}`);
67
+ }
68
+ async getNetworks() {
69
+ return this.get('/network-chains');
70
+ }
71
+ async getOrderBookPositions(telegramId) {
72
+ return this.get(`/order-books/position/${telegramId}`);
73
+ }
74
+ async getOrderBookPairs(telegramId) {
75
+ return this.get(`/order-books/pairs/${telegramId}`);
76
+ }
77
+ async getOrderBookSnapshot() {
78
+ return this.get('/order-books/snapshot');
79
+ }
80
+ async getOrderBook(id) {
81
+ return this.get(`/order-books/${id}`);
82
+ }
83
+ async getReferralCampaigns(address) {
84
+ return this.get(`/referral/my-campaigns/${address}`);
85
+ }
86
+ async getReferralSummary(address) {
87
+ return this.get(`/referral/my-campaigns/${address}/summary`);
88
+ }
89
+ async getReferralPerformance(address) {
90
+ return this.get(`/referral/my-campaigns/${address}/performance`);
91
+ }
92
+ async getReferralTransactions(address) {
93
+ return this.get(`/referral/my-campaigns/${address}/transactions`);
94
+ }
95
+ }
96
+ exports.ApiClient = ApiClient;
97
+ exports.apiClient = new ApiClient();
98
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyD;AACzD,qCAAkC;AAGlC,MAAa,SAAS;IAGpB;QACE,MAAM,OAAO,GAAI,eAAM,CAAC,GAAG,CAAC,QAAQ,CAAY,IAAI,2BAA2B,CAAC;QAEhF,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO;YACP,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,sCAAsC;QACtC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CACnC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EACzB,CAAC,KAAiB,EAAE,EAAE;YACpB,IAAI,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACzB,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAW,CAAC;gBACxC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YAC/D,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC,CACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,GAAW,EAAE,MAAY;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAA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mHC;AAEY,QAAA,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC"}
package/dist/auth.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export declare class Auth {
2
+ getWallet(privateKey?: string): {
3
+ address: string;
4
+ type: 'solana' | 'evm';
5
+ };
6
+ signTransaction(transaction: any, privateKey?: string): Promise<string>;
7
+ signMessage(message: string, privateKey?: string): Promise<string>;
8
+ getAddress(privateKey?: string): string;
9
+ }
10
+ export declare const auth: Auth;
11
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAMA,qBAAa,IAAI;IAEf,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,GAAG,KAAK,CAAA;KAAE;IA0BrE,eAAe,CAAC,WAAW,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqBvE,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxE,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;CAGxC;AAED,eAAO,MAAM,IAAI,MAAa,CAAC"}
package/dist/auth.js ADDED
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.auth = exports.Auth = void 0;
7
+ const web3_js_1 = require("@solana/web3.js");
8
+ const ethers_1 = require("ethers");
9
+ const tweetnacl_1 = __importDefault(require("tweetnacl"));
10
+ const bs58_1 = __importDefault(require("bs58"));
11
+ const config_1 = require("./config");
12
+ class Auth {
13
+ // Get wallet from config or CLI flag
14
+ getWallet(privateKey) {
15
+ const key = privateKey || config_1.config.get('privateKey');
16
+ const type = config_1.config.get('walletType') || 'solana';
17
+ if (!key) {
18
+ throw new Error('No wallet configured. Run: whales setup');
19
+ }
20
+ if (type === 'solana') {
21
+ try {
22
+ const keypair = web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(key));
23
+ return { address: keypair.publicKey.toBase58(), type: 'solana' };
24
+ }
25
+ catch (error) {
26
+ throw new Error('Invalid Solana private key format');
27
+ }
28
+ }
29
+ else {
30
+ try {
31
+ const wallet = new ethers_1.Wallet(key);
32
+ return { address: wallet.address, type: 'evm' };
33
+ }
34
+ catch (error) {
35
+ throw new Error('Invalid EVM private key format');
36
+ }
37
+ }
38
+ }
39
+ // Sign transaction/message (for when transactions are needed)
40
+ async signTransaction(transaction, privateKey) {
41
+ const key = privateKey || config_1.config.get('privateKey');
42
+ const type = config_1.config.get('walletType') || 'solana';
43
+ if (!key) {
44
+ throw new Error('No private key provided');
45
+ }
46
+ if (type === 'solana') {
47
+ const keypair = web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(key));
48
+ // Sign Solana transaction
49
+ transaction.sign([keypair]);
50
+ return transaction.serialize().toString('base64');
51
+ }
52
+ else {
53
+ const wallet = new ethers_1.Wallet(key);
54
+ // Sign EVM transaction
55
+ return await wallet.signTransaction(transaction);
56
+ }
57
+ }
58
+ // Sign message for authentication
59
+ async signMessage(message, privateKey) {
60
+ const key = privateKey || config_1.config.get('privateKey');
61
+ const type = config_1.config.get('walletType') || 'solana';
62
+ if (!key) {
63
+ throw new Error('No private key provided');
64
+ }
65
+ if (type === 'solana') {
66
+ const keypair = web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(key));
67
+ const messageBytes = Buffer.from(message);
68
+ const signature = tweetnacl_1.default.sign.detached(messageBytes, keypair.secretKey);
69
+ return bs58_1.default.encode(signature);
70
+ }
71
+ else {
72
+ const wallet = new ethers_1.Wallet(key);
73
+ return await wallet.signMessage(message);
74
+ }
75
+ }
76
+ // Get wallet address without private key (for read-only operations)
77
+ getAddress(privateKey) {
78
+ return this.getWallet(privateKey).address;
79
+ }
80
+ }
81
+ exports.Auth = Auth;
82
+ exports.auth = new Auth();
83
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA0C;AAC1C,mCAAgC;AAChC,0DAA6B;AAC7B,gDAAwB;AACxB,qCAAkC;AAElC,MAAa,IAAI;IACf,qCAAqC;IACrC,SAAS,CAAC,UAAmB;QAC3B,MAAM,GAAG,GAAG,UAAU,IAAI,eAAM,CAAC,GAAG,CAAC,YAAY,CAAW,CAAC;QAC7D,MAAM,IAAI,GAAG,eAAM,CAAC,GAAG,CAAC,YAAY,CAAqB,IAAI,QAAQ,CAAC;QAEtE,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,iBAAO,CAAC,aAAa,CAAC,cAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBACxD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YACnE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,GAAG,CAAC,CAAC;gBAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;YAClD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAA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AAC;YACtB,MAAM,OAAO,GAAG,iBAAO,CAAC,aAAa,CAAC,cAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACxD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1C,MAAM,SAAS,GAAG,mBAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;YACtE,OAAO,cAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,GAAG,CAAC,CAAC;YAC/B,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,UAAU,CAAC,UAAmB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IAC5C,CAAC;CACF;AAxED,oBAwEC;AAEY,QAAA,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const helpCommand: Command;
3
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,WAAW,SA8JpB,CAAC"}