decharge-scout 1.4.0 → 1.5.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 (2) hide show
  1. package/index.js +36 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -46,7 +46,8 @@ const __dirname = dirname(__filename);
46
46
  // Configuration
47
47
  const STAKE_AMOUNT = parseFloat(process.env.STAKE_AMOUNT || '0.01');
48
48
  const CYCLE_INTERVAL_MS = 15 * 60 * 1000; // 15 minutes
49
- const DEFAULT_WALLET_PATH = path.join(__dirname, 'wallet.json');
49
+ // Use current working directory for wallet by default (not package installation dir)
50
+ const DEFAULT_WALLET_PATH = path.join(process.cwd(), 'wallet.json');
50
51
 
51
52
  // Global state
52
53
  let isRunning = true;
@@ -74,16 +75,35 @@ function generateAgentName() {
74
75
  */
75
76
  function findExistingWallets() {
76
77
  const wallets = [];
78
+ const homeDir = os.homedir();
79
+ const cwd = process.cwd();
80
+
77
81
  const searchPaths = [
78
- // Current directory
79
- path.join(process.cwd(), 'wallet.json'),
80
- path.join(process.cwd(), 'id.json'),
82
+ // Current directory - most common
83
+ path.join(cwd, 'wallet.json'),
84
+ path.join(cwd, 'id.json'),
85
+ path.join(cwd, 'keypair.json'),
86
+ path.join(cwd, 'solana-wallet.json'),
87
+ path.join(cwd, 'my-wallet.json'),
88
+
89
+ // Package directory (for global installations)
90
+ path.join(__dirname, 'wallet.json'),
91
+ path.join(__dirname, 'id.json'),
92
+
93
+ // Solana CLI default locations
94
+ path.join(homeDir, '.config', 'solana', 'id.json'),
95
+ path.join(homeDir, '.solana', 'id.json'),
96
+ path.join(homeDir, '.solana', 'devnet.json'),
97
+ path.join(homeDir, '.solana', 'testnet.json'),
98
+
81
99
  // Home directory
82
- path.join(os.homedir(), '.solana', 'id.json'),
83
- path.join(os.homedir(), 'wallet.json'),
84
- // Common wallet names in current dir
85
- path.join(process.cwd(), 'solana-wallet.json'),
86
- path.join(process.cwd(), 'keypair.json'),
100
+ path.join(homeDir, 'wallet.json'),
101
+ path.join(homeDir, 'solana-wallet.json'),
102
+
103
+ // Downloads (users often save here)
104
+ path.join(homeDir, 'Downloads', 'wallet.json'),
105
+ path.join(homeDir, 'Downloads', 'solana-wallet.json'),
106
+ path.join(homeDir, 'Downloads', 'keypair.json'),
87
107
  ];
88
108
 
89
109
  for (const walletPath of searchPaths) {
@@ -119,10 +139,11 @@ async function ensureWallet(walletPath) {
119
139
  console.log(chalk.yellow(`\n⚠️ No wallet found at ${walletPath}`));
120
140
 
121
141
  // Search for existing wallets
142
+ console.log(chalk.blue('🔍 Searching for existing Solana wallets...'));
122
143
  const existingWallets = findExistingWallets();
123
144
 
124
145
  if (existingWallets.length > 0) {
125
- console.log(chalk.green(`\n🔍 Found ${existingWallets.length} existing wallet(s):\n`));
146
+ console.log(chalk.green(`\n Found ${existingWallets.length} existing wallet(s):\n`));
126
147
 
127
148
  existingWallets.forEach((wallet, index) => {
128
149
  console.log(chalk.cyan(` ${index + 1}. ${wallet.name}`));
@@ -142,6 +163,9 @@ async function ensureWallet(walletPath) {
142
163
  console.log(chalk.yellow('Invalid selection, creating new wallet...'));
143
164
  }
144
165
  }
166
+ } else {
167
+ console.log(chalk.yellow('⚠️ No existing wallets found in common locations.'));
168
+ console.log(chalk.gray(' Searched: ~/.solana/id.json, ./wallet.json, ./id.json, etc.\n'));
145
169
  }
146
170
 
147
171
  const answer = await question('Create a new wallet? (Y/n): ');
@@ -177,6 +201,7 @@ async function ensureWallet(walletPath) {
177
201
  writeFileSync(walletPath, JSON.stringify(privateKey));
178
202
 
179
203
  console.log(chalk.green(`✓ Wallet imported: ${keypair.publicKey.toBase58()}`));
204
+ console.log(chalk.blue(`📁 Wallet saved to: ${walletPath}`));
180
205
  return walletPath;
181
206
  } catch (error) {
182
207
  console.log(chalk.red(`\n❌ Invalid private key: ${error.message}`));
@@ -193,6 +218,7 @@ async function ensureWallet(walletPath) {
193
218
  writeFileSync(walletPath, JSON.stringify(secretKey));
194
219
 
195
220
  console.log(chalk.green(`✓ Wallet created: ${keypair.publicKey.toBase58()}`));
221
+ console.log(chalk.blue(`📁 Wallet saved to: ${walletPath}`));
196
222
  console.log(chalk.yellow('⚠️ IMPORTANT: Backup this wallet file!'));
197
223
  console.log(chalk.blue(`\nYou need devnet SOL. Get it from:`));
198
224
  console.log(chalk.gray(' solana airdrop 1 ' + keypair.publicKey.toBase58() + ' --url devnet'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "decharge-scout",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "AI-powered energy grid data scout with Solana integration",
5
5
  "main": "index.js",
6
6
  "type": "module",