mirror of
https://github.com/aljazceru/mcp-code.git
synced 2025-12-17 12:45:28 +01:00
- Implemented the `zap` command in the CLI to allow users to send sats to a user, event, or snippet using a NIP-60 wallet. - Created a new `zap.ts` file to handle the command logic and integrated it into the MCP server. - Added wallet balance command to check the balance of a user's wallet. - Enhanced the MCP server to register the new zap command and wallet balance command. - Introduced caching for wallets to optimize performance and reduce redundant network requests. - Updated database schema to include snippets table for storing code snippets. - Improved logging functionality for better debugging and tracking of operations. - Added functionality to save snippets to the database upon retrieval. - Updated project overview documentation to reflect new features and structure. - Refactored existing commands and logic for better modularity and maintainability.
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import type { NDKEvent, NDKSigner } from "@nostr-dev-kit/ndk";
|
|
import { NDKPrivateKeySigner } from "@nostr-dev-kit/ndk";
|
|
import { ndk } from "../../ndk.js";
|
|
import { getUser } from "../../config.js";
|
|
import { toPubkeys, toSnippet } from "../converters/index.js";
|
|
|
|
export const SNIPPET_KIND = 1337;
|
|
|
|
export function getUsernameFromPubkey(pubkey: string): string | null {
|
|
|
|
}
|
|
|
|
/**
|
|
* Gets the appropriate signer based on the username
|
|
* @param username Username to get signer for (or "main" for default)
|
|
* @returns The signer to use
|
|
* @throws Error if user not found or missing nsec
|
|
*/
|
|
export async function getSigner(username?: string): Promise<NDKSigner> {
|
|
// If no username or "main", return the default signer
|
|
if (!username || username === "main") {
|
|
if (!ndk.signer) {
|
|
throw new Error("No default signer configured");
|
|
}
|
|
return ndk.signer;
|
|
}
|
|
|
|
// Otherwise, get the user's signer
|
|
const userData = getUser(username);
|
|
|
|
if (!userData?.nsec) {
|
|
throw new Error(`User "${username}" not found in config or missing nsec`);
|
|
}
|
|
|
|
return new NDKPrivateKeySigner(userData.nsec);
|
|
}
|
|
|
|
// Re-export converter functions for backward compatibility
|
|
export { toPubkeys as identifierToPubkeys, toSnippet as eventToSnippet };
|