@x402storage/mcp 1.0.4 → 1.0.6
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/dist/config.d.ts +4 -0
- package/dist/config.js +18 -0
- package/dist/index.js +5 -2
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -66,6 +66,10 @@ export declare function getAllWalletInfo(): Promise<WalletInfo[]>;
|
|
|
66
66
|
* Returns error message if wallet type not configured, null on success
|
|
67
67
|
*/
|
|
68
68
|
export declare function setActiveWallet(type: WalletType): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Gets wallet address without fetching balance (fast)
|
|
71
|
+
*/
|
|
72
|
+
export declare function getWalletAddress(type: WalletType): string | null;
|
|
69
73
|
/**
|
|
70
74
|
* Checks if legacy wallet file exists and returns migration info
|
|
71
75
|
*/
|
package/dist/config.js
CHANGED
|
@@ -183,6 +183,24 @@ export function setActiveWallet(type) {
|
|
|
183
183
|
saveConfig(config);
|
|
184
184
|
return null;
|
|
185
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Gets wallet address without fetching balance (fast)
|
|
188
|
+
*/
|
|
189
|
+
export function getWalletAddress(type) {
|
|
190
|
+
const config = loadConfig();
|
|
191
|
+
if (!config || !config.wallets[type]) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
if (type === 'sol') {
|
|
195
|
+
const secretKey = Uint8Array.from(JSON.parse(config.wallets.sol));
|
|
196
|
+
const keypair = Keypair.fromSecretKey(secretKey);
|
|
197
|
+
return keypair.publicKey.toBase58();
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const account = privateKeyToAccount(config.wallets.evm);
|
|
201
|
+
return account.address;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
186
204
|
/**
|
|
187
205
|
* Checks if legacy wallet file exists and returns migration info
|
|
188
206
|
*/
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { homedir } from 'node:os';
|
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
10
10
|
import { Keypair } from '@solana/web3.js';
|
|
11
|
-
import { validateEnvironment, getPrivateKey, getAllWalletInfo, setActiveWallet, loadConfig, saveConfig, } from './config.js';
|
|
11
|
+
import { validateEnvironment, getPrivateKey, getAllWalletInfo, setActiveWallet, getWalletAddress, loadConfig, saveConfig, } from './config.js';
|
|
12
12
|
import { uploadFile, FileNotFoundError, UploadError } from './upload.js';
|
|
13
13
|
const CONFIG_PATH = join(homedir(), '.x402-config.json');
|
|
14
14
|
// Handle CLI flags before MCP server setup
|
|
@@ -57,7 +57,9 @@ if (setActiveIdx !== -1) {
|
|
|
57
57
|
console.error(`Error: ${error}`);
|
|
58
58
|
process.exit(1);
|
|
59
59
|
}
|
|
60
|
+
const address = getWalletAddress(walletType);
|
|
60
61
|
console.log(`Active wallet set to ${walletType === 'evm' ? 'EVM (Base)' : 'Solana'}`);
|
|
62
|
+
console.log(`Address: ${address}`);
|
|
61
63
|
process.exit(0);
|
|
62
64
|
}
|
|
63
65
|
// Create MCP server
|
|
@@ -177,11 +179,12 @@ server.tool('set_active_wallet', 'Set which wallet (evm or sol) to use for payme
|
|
|
177
179
|
};
|
|
178
180
|
}
|
|
179
181
|
const chainLabel = wallet_type === 'evm' ? 'EVM (Base)' : 'Solana';
|
|
182
|
+
const address = getWalletAddress(wallet_type);
|
|
180
183
|
return {
|
|
181
184
|
content: [
|
|
182
185
|
{
|
|
183
186
|
type: 'text',
|
|
184
|
-
text: `Active wallet set to ${chainLabel}.\n\nNote: Restart Claude Code for the change to take effect.`,
|
|
187
|
+
text: `Active wallet set to ${chainLabel}.\nAddress: ${address}\n\nNote: Restart Claude Code for the change to take effect.`,
|
|
185
188
|
},
|
|
186
189
|
],
|
|
187
190
|
};
|