diff --git a/packages/plugin-coinbase/src/plugins/advancedTrade.ts b/packages/plugin-coinbase/src/plugins/advancedTrade.ts index 8b70a76e438..3e26e78ac08 100644 --- a/packages/plugin-coinbase/src/plugins/advancedTrade.ts +++ b/packages/plugin-coinbase/src/plugins/advancedTrade.ts @@ -34,6 +34,7 @@ const tradeCsvFilePath = path.join(baseDir, "advanced_trades.csv"); const tradeProvider: Provider = { get: async (runtime: IAgentRuntime, _message: Memory) => { + elizaLogger.debug("Starting tradeProvider function"); try { const client = new RESTClient( runtime.getSetting("COINBASE_API_KEY") ?? @@ -103,6 +104,7 @@ const tradeProvider: Provider = { }; export async function appendTradeToCsv(tradeResult: any) { + elizaLogger.debug("Starting appendTradeToCsv function"); try { const csvWriter = createArrayCsvWriter({ path: tradeCsvFilePath, @@ -139,6 +141,7 @@ async function hasEnoughBalance( amount: number, side: string ): Promise { + elizaLogger.debug("Starting hasEnoughBalance function"); try { const response = await client.listAccounts({}); const accounts = JSON.parse(response); @@ -216,6 +219,7 @@ export const executeAdvancedTradeAction: Action = { let client: RESTClient; // Initialize client + elizaLogger.debug("Starting advanced trade client initialization"); try { client = new RESTClient( runtime.getSetting("COINBASE_API_KEY") ?? @@ -237,6 +241,7 @@ export const executeAdvancedTradeAction: Action = { // Generate trade details let tradeDetails; + elizaLogger.debug("Starting trade details generation"); try { tradeDetails = await generateObject({ runtime, @@ -276,6 +281,7 @@ export const executeAdvancedTradeAction: Action = { // Configure order let orderConfiguration: OrderConfiguration; + elizaLogger.debug("Starting order configuration"); try { if (orderType === "MARKET") { orderConfiguration = @@ -323,6 +329,7 @@ export const executeAdvancedTradeAction: Action = { // Execute trade let order: CreateOrderResponse; try { + elizaLogger.debug("Executing the trade"); if ( !(await hasEnoughBalance( client, diff --git a/packages/plugin-coinbase/src/plugins/commerce.ts b/packages/plugin-coinbase/src/plugins/commerce.ts index 411aea6015c..7dacdc0fcb6 100644 --- a/packages/plugin-coinbase/src/plugins/commerce.ts +++ b/packages/plugin-coinbase/src/plugins/commerce.ts @@ -30,6 +30,7 @@ interface ChargeRequest { } export async function createCharge(apiKey: string, params: ChargeRequest) { + elizaLogger.debug("Starting createCharge function"); try { const response = await fetch(url, { method: "POST", @@ -47,13 +48,14 @@ export async function createCharge(apiKey: string, params: ChargeRequest) { const data = await response.json(); return data.data; } catch (error) { - console.error("Error creating charge:", error); + elizaLogger.error("Error creating charge:", error); throw error; } } // Function to fetch all charges export async function getAllCharges(apiKey: string) { + elizaLogger.debug("Starting getAllCharges function"); try { const response = await fetch(url, { method: "GET", @@ -72,13 +74,14 @@ export async function getAllCharges(apiKey: string) { const data = await response.json(); return data.data; } catch (error) { - console.error("Error fetching charges:", error); + elizaLogger.error("Error fetching charges:", error); throw error; } } // Function to fetch details of a specific charge export async function getChargeDetails(apiKey: string, chargeId: string) { + elizaLogger.debug("Starting getChargeDetails function"); const getUrl = `${url}${chargeId}`; try { @@ -99,7 +102,7 @@ export async function getChargeDetails(apiKey: string, chargeId: string) { const data = await response.json(); return data; } catch (error) { - console.error( + elizaLogger.error( `Error fetching charge details for ID ${chargeId}:`, error ); @@ -140,7 +143,7 @@ export const createCoinbaseChargeAction: Action = { _options: any, callback: HandlerCallback ) => { - elizaLogger.log("Composing state for message:", message); + elizaLogger.info("Composing state for message:", message); if (!state) { state = (await runtime.composeState(message)) as State; } else { @@ -172,10 +175,10 @@ export const createCoinbaseChargeAction: Action = { return; } - elizaLogger.log("Charge details received:", chargeDetails); + elizaLogger.info("Charge details received:", chargeDetails); // Initialize Coinbase Commerce client - + elizaLogger.debug("Starting Coinbase Commerce client initialization"); try { // Create a charge const chargeResponse = await createCharge( @@ -191,7 +194,7 @@ export const createCoinbaseChargeAction: Action = { } ); - elizaLogger.log( + elizaLogger.info( "Coinbase Commerce charge created:", chargeResponse ); @@ -333,7 +336,7 @@ export const getAllChargesAction: Action = { callback: HandlerCallback ) => { try { - elizaLogger.log("Composing state for message:", message); + elizaLogger.info("Composing state for message:", message); if (!state) { state = (await runtime.composeState(message)) as State; } else { @@ -343,7 +346,7 @@ export const getAllChargesAction: Action = { runtime.getSetting("COINBASE_COMMERCE_KEY") ); - elizaLogger.log("Fetched all charges:", charges); + elizaLogger.info("Fetched all charges:", charges); callback( { @@ -397,7 +400,7 @@ export const getChargeDetailsAction: Action = { _options: any, callback: HandlerCallback ) => { - elizaLogger.log("Composing state for message:", message); + elizaLogger.info("Composing state for message:", message); if (!state) { state = (await runtime.composeState(message)) as State; } else { @@ -434,7 +437,7 @@ export const getChargeDetailsAction: Action = { charge.id ); - elizaLogger.log("Fetched charge details:", chargeDetails); + elizaLogger.info("Fetched charge details:", chargeDetails); callback( { @@ -486,6 +489,7 @@ export const getChargeDetailsAction: Action = { export const chargeProvider: Provider = { get: async (runtime: IAgentRuntime, _message: Memory) => { + elizaLogger.debug("Starting chargeProvider.get function"); const charges = await getAllCharges( runtime.getSetting("COINBASE_COMMERCE_KEY") ); @@ -504,8 +508,8 @@ export const chargeProvider: Provider = { privateKey: coinbasePrivateKey, }); const { balances, transactions } = await getWalletDetails(runtime); - elizaLogger.log("Current Balances:", balances); - elizaLogger.log("Last Transactions:", transactions); + elizaLogger.info("Current Balances:", balances); + elizaLogger.info("Last Transactions:", transactions); } const formattedCharges = charges.map((charge) => ({ id: charge.id, @@ -513,7 +517,7 @@ export const chargeProvider: Provider = { description: charge.description, pricing: charge.pricing, })); - elizaLogger.log("Charges:", formattedCharges); + elizaLogger.info("Charges:", formattedCharges); return { charges: formattedCharges, balances, transactions }; }, }; diff --git a/packages/plugin-coinbase/src/plugins/massPayments.ts b/packages/plugin-coinbase/src/plugins/massPayments.ts index 6eca0849679..70e65d17fc8 100644 --- a/packages/plugin-coinbase/src/plugins/massPayments.ts +++ b/packages/plugin-coinbase/src/plugins/massPayments.ts @@ -41,6 +41,7 @@ const csvFilePath = path.join(baseDir, "transactions.csv"); export const massPayoutProvider: Provider = { get: async (runtime: IAgentRuntime, _message: Memory) => { + elizaLogger.debug("Starting massPayoutProvider.get function"); try { Coinbase.configure({ apiKeyName: @@ -50,7 +51,7 @@ export const massPayoutProvider: Provider = { runtime.getSetting("COINBASE_PRIVATE_KEY") ?? process.env.COINBASE_PRIVATE_KEY, }); - elizaLogger.log("Reading CSV file from:", csvFilePath); + elizaLogger.info("Reading CSV file from:", csvFilePath); // Ensure the CSV file exists if (!fs.existsSync(csvFilePath)) { @@ -66,7 +67,7 @@ export const massPayoutProvider: Provider = { ], }); await csvWriter.writeRecords([]); // Create an empty file with headers - elizaLogger.log("New CSV file created with headers."); + elizaLogger.info("New CSV file created with headers."); } // Read and parse the CSV file @@ -78,9 +79,9 @@ export const massPayoutProvider: Provider = { const { balances, transactions } = await getWalletDetails(runtime); - elizaLogger.log("Parsed CSV records:", records); - elizaLogger.log("Current Balances:", balances); - elizaLogger.log("Last Transactions:", transactions); + elizaLogger.info("Parsed CSV records:", records); + elizaLogger.info("Current Balances:", balances); + elizaLogger.info("Last Transactions:", transactions); return { currentTransactions: records.map((record: any) => ({ @@ -107,17 +108,19 @@ async function executeMassPayout( transferAmount: number, assetId: string ): Promise { + elizaLogger.debug("Starting executeMassPayout function"); const transactions: Transaction[] = []; const assetIdLowercase = assetId.toLowerCase(); let sendingWallet: Wallet; try { + elizaLogger.debug("Initializing sending wallet"); sendingWallet = await initializeWallet(runtime, networkId); } catch (error) { elizaLogger.error("Error initializing sending wallet:", error); throw error; } for (const address of receivingAddresses) { - elizaLogger.log("Processing payout for address:", address); + elizaLogger.info("Processing payout for address:", address); if (address) { try { // Check balance before initiating transfer @@ -125,7 +128,7 @@ async function executeMassPayout( const walletBalance = await sendingWallet.getBalance(assetIdLowercase); - elizaLogger.log("Wallet balance for asset:", { + elizaLogger.info("Wallet balance for asset:", { assetId, walletBalance, }); @@ -174,7 +177,7 @@ async function executeMassPayout( }); } } else { - elizaLogger.log("Skipping invalid or empty address."); + elizaLogger.info("Skipping invalid or empty address."); transactions.push({ address: "Invalid or Empty", amount: transferAmount, @@ -188,6 +191,7 @@ async function executeMassPayout( const charityAddress = getCharityAddress(networkId); try { + elizaLogger.debug("Sending 1% to charity:", charityAddress); const charityTransfer = await executeTransfer( sendingWallet, transferAmount * 0.01, @@ -213,7 +217,7 @@ async function executeMassPayout( }); } await appendTransactionsToCsv(transactions); - elizaLogger.log("Finished processing mass payouts."); + elizaLogger.info("Finished processing mass payouts."); return transactions; } @@ -224,7 +228,7 @@ export const sendMassPayoutAction: Action = { description: "Sends mass payouts to a list of receiving addresses using a predefined sending wallet and logs all transactions to a CSV file.", validate: async (runtime: IAgentRuntime, _message: Memory) => { - elizaLogger.log("Validating runtime and message..."); + elizaLogger.info("Validating runtime and message..."); return ( !!( runtime.character.settings.secrets?.COINBASE_API_KEY || @@ -243,7 +247,7 @@ export const sendMassPayoutAction: Action = { _options: any, callback: HandlerCallback ) => { - elizaLogger.log("Starting SEND_MASS_PAYOUT handler..."); + elizaLogger.debug("Starting SEND_MASS_PAYOUT handler..."); try { Coinbase.configure({ apiKeyName: @@ -273,7 +277,7 @@ export const sendMassPayoutAction: Action = { schema: TransferSchema, }); - elizaLogger.log( + elizaLogger.info( "Transfer details generated:", transferDetails.object ); @@ -319,7 +323,7 @@ export const sendMassPayoutAction: Action = { return; } - elizaLogger.log("◎ Starting mass payout..."); + elizaLogger.info("◎ Starting mass payout..."); const transactions = await executeMassPayout( runtime, network, diff --git a/packages/plugin-coinbase/src/plugins/tokenContract.ts b/packages/plugin-coinbase/src/plugins/tokenContract.ts index 5a268f4b1a3..861f67ba235 100644 --- a/packages/plugin-coinbase/src/plugins/tokenContract.ts +++ b/packages/plugin-coinbase/src/plugins/tokenContract.ts @@ -58,7 +58,7 @@ export const deployTokenContractAction: Action = { description: "Deploy an ERC20, ERC721, or ERC1155 token contract using the Coinbase SDK", validate: async (runtime: IAgentRuntime, _message: Memory) => { - elizaLogger.log("Validating runtime for DEPLOY_TOKEN_CONTRACT..."); + elizaLogger.info("Validating runtime for DEPLOY_TOKEN_CONTRACT..."); return ( !!( runtime.character.settings.secrets?.COINBASE_API_KEY || @@ -77,7 +77,7 @@ export const deployTokenContractAction: Action = { _options: any, callback: HandlerCallback ) => { - elizaLogger.log("Starting DEPLOY_TOKEN_CONTRACT handler..."); + elizaLogger.debug("Starting DEPLOY_TOKEN_CONTRACT handler..."); try { Coinbase.configure({ @@ -118,7 +118,7 @@ export const deployTokenContractAction: Action = { modelClass: ModelClass.SMALL, schema: TokenContractSchema, }); - elizaLogger.log("Contract details:", contractDetails.object); + elizaLogger.info("Contract details:", contractDetails.object); if (!isTokenContractContent(contractDetails.object)) { callback( @@ -138,7 +138,7 @@ export const deployTokenContractAction: Action = { baseURI, totalSupply, } = contractDetails.object; - elizaLogger.log("Contract details:", contractDetails.object); + elizaLogger.info("Contract details:", contractDetails.object); const wallet = await initializeWallet(runtime, network); let contract: SmartContract; let deploymentDetails; @@ -177,8 +177,8 @@ export const deployTokenContractAction: Action = { // Wait for deployment to complete await contract.wait(); - elizaLogger.log("Deployment details:", deploymentDetails); - elizaLogger.log("Contract deployed successfully:", contract); + elizaLogger.info("Deployment details:", deploymentDetails); + elizaLogger.info("Contract deployed successfully:", contract); // Log deployment to CSV const csvWriter = createArrayCsvWriter({ path: contractsCsvFilePath, @@ -287,7 +287,7 @@ export const invokeContractAction: Action = { description: "Invoke a method on a deployed smart contract using the Coinbase SDK", validate: async (runtime: IAgentRuntime, _message: Memory) => { - elizaLogger.log("Validating runtime for INVOKE_CONTRACT..."); + elizaLogger.info("Validating runtime for INVOKE_CONTRACT..."); return ( !!( runtime.character.settings.secrets?.COINBASE_API_KEY || @@ -306,7 +306,7 @@ export const invokeContractAction: Action = { _options: any, callback: HandlerCallback ) => { - elizaLogger.log("Starting INVOKE_CONTRACT handler..."); + elizaLogger.debug("Starting INVOKE_CONTRACT handler..."); try { Coinbase.configure({ @@ -329,7 +329,7 @@ export const invokeContractAction: Action = { modelClass: ModelClass.LARGE, schema: ContractInvocationSchema, }); - elizaLogger.log("Invocation details:", invocationDetails.object); + elizaLogger.info("Invocation details:", invocationDetails.object); if (!isContractInvocationContent(invocationDetails.object)) { callback( { @@ -362,7 +362,7 @@ export const invokeContractAction: Action = { networkId, assetId, }; - elizaLogger.log("Invocation options:", invocationOptions); + elizaLogger.info("Invocation options:", invocationOptions); // Invoke the contract const invocation = await wallet.invokeContract(invocationOptions); @@ -454,7 +454,7 @@ export const readContractAction: Action = { description: "Read data from a deployed smart contract using the Coinbase SDK", validate: async (runtime: IAgentRuntime, _message: Memory) => { - elizaLogger.log("Validating runtime for READ_CONTRACT..."); + elizaLogger.info("Validating runtime for READ_CONTRACT..."); return ( !!( runtime.character.settings.secrets?.COINBASE_API_KEY || @@ -473,7 +473,7 @@ export const readContractAction: Action = { _options: any, callback: HandlerCallback ) => { - elizaLogger.log("Starting READ_CONTRACT handler..."); + elizaLogger.debug("Starting READ_CONTRACT handler..."); try { Coinbase.configure({ @@ -509,7 +509,7 @@ export const readContractAction: Action = { const { contractAddress, method, args, networkId, abi } = readDetails.object; - elizaLogger.log("Reading contract:", { + elizaLogger.info("Reading contract:", { contractAddress, method, args, diff --git a/packages/plugin-coinbase/src/plugins/trade.ts b/packages/plugin-coinbase/src/plugins/trade.ts index e26a9d20cb2..5858d70f1ad 100644 --- a/packages/plugin-coinbase/src/plugins/trade.ts +++ b/packages/plugin-coinbase/src/plugins/trade.ts @@ -30,6 +30,7 @@ const tradeCsvFilePath = path.join(baseDir, "trades.csv"); export const tradeProvider: Provider = { get: async (runtime: IAgentRuntime, _message: Memory) => { + elizaLogger.debug("Starting tradeProvider.get function"); try { Coinbase.configure({ apiKeyName: @@ -39,7 +40,7 @@ export const tradeProvider: Provider = { runtime.getSetting("COINBASE_PRIVATE_KEY") ?? process.env.COINBASE_PRIVATE_KEY, }); - elizaLogger.log("Reading CSV file from:", tradeCsvFilePath); + elizaLogger.info("Reading CSV file from:", tradeCsvFilePath); // Check if the file exists; if not, create it with headers if (!fs.existsSync(tradeCsvFilePath)) { @@ -57,7 +58,7 @@ export const tradeProvider: Provider = { ], }); await csvWriter.writeRecords([]); // Create an empty file with headers - elizaLogger.log("New CSV file created with headers."); + elizaLogger.info("New CSV file created with headers."); } // Read and parse the CSV file @@ -67,10 +68,10 @@ export const tradeProvider: Provider = { skip_empty_lines: true, }); - elizaLogger.log("Parsed CSV records:", records); + elizaLogger.info("Parsed CSV records:", records); const { balances, transactions } = await getWalletDetails(runtime); - elizaLogger.log("Current Balances:", balances); - elizaLogger.log("Last Transactions:", transactions); + elizaLogger.info("Current Balances:", balances); + elizaLogger.info("Last Transactions:", transactions); return { currentTrades: records.map((record: any) => ({ network: record["Network"] || undefined, @@ -96,7 +97,7 @@ export const executeTradeAction: Action = { description: "Execute a trade between two assets using the Coinbase SDK and log the result.", validate: async (runtime: IAgentRuntime, _message: Memory) => { - elizaLogger.log("Validating runtime for EXECUTE_TRADE..."); + elizaLogger.info("Validating runtime for EXECUTE_TRADE..."); return ( !!( runtime.character.settings.secrets?.COINBASE_API_KEY || @@ -115,7 +116,7 @@ export const executeTradeAction: Action = { _options: any, callback: HandlerCallback ) => { - elizaLogger.log("Starting EXECUTE_TRADE handler..."); + elizaLogger.debug("Starting EXECUTE_TRADE handler..."); try { Coinbase.configure({ diff --git a/packages/plugin-coinbase/src/plugins/webhooks.ts b/packages/plugin-coinbase/src/plugins/webhooks.ts index 742dca2ccb1..62dd40de223 100644 --- a/packages/plugin-coinbase/src/plugins/webhooks.ts +++ b/packages/plugin-coinbase/src/plugins/webhooks.ts @@ -18,6 +18,7 @@ import { appendWebhooksToCsv } from "../utils"; export const webhookProvider: Provider = { get: async (runtime: IAgentRuntime, _message: Memory) => { + elizaLogger.debug("Starting webhookProvider.get function"); try { Coinbase.configure({ apiKeyName: @@ -30,7 +31,7 @@ export const webhookProvider: Provider = { // List all webhooks const resp = await Webhook.list(); - elizaLogger.log("Listing all webhooks:", resp.data); + elizaLogger.info("Listing all webhooks:", resp.data); return { webhooks: resp.data.map((webhook: Webhook) => ({ @@ -53,7 +54,7 @@ export const createWebhookAction: Action = { name: "CREATE_WEBHOOK", description: "Create a new webhook using the Coinbase SDK.", validate: async (runtime: IAgentRuntime, _message: Memory) => { - elizaLogger.log("Validating runtime for CREATE_WEBHOOK..."); + elizaLogger.info("Validating runtime for CREATE_WEBHOOK..."); return ( !!( runtime.character.settings.secrets?.COINBASE_API_KEY || @@ -76,7 +77,7 @@ export const createWebhookAction: Action = { _options: any, callback: HandlerCallback ) => { - elizaLogger.log("Starting CREATE_WEBHOOK handler..."); + elizaLogger.debug("Starting CREATE_WEBHOOK handler..."); try { Coinbase.configure({ @@ -125,7 +126,7 @@ export const createWebhookAction: Action = { ); return; } - elizaLogger.log("Creating webhook with details:", { + elizaLogger.info("Creating webhook with details:", { networkId, notificationUri, eventType, @@ -138,7 +139,7 @@ export const createWebhookAction: Action = { eventType, eventFilters, }); - elizaLogger.log( + elizaLogger.info( "Webhook created successfully:", webhook.toString() ); @@ -149,7 +150,7 @@ export const createWebhookAction: Action = { [] ); await appendWebhooksToCsv([webhook]); - elizaLogger.log("Webhook appended to CSV successfully"); + elizaLogger.info("Webhook appended to CSV successfully"); } catch (error) { elizaLogger.error("Error during webhook creation:", error); callback(