Skip to content

Commit 0ee9e07

Browse files
committed
chore: console -> elizaLogger
1 parent cd1413d commit 0ee9e07

File tree

9 files changed

+58
-39
lines changed

9 files changed

+58
-39
lines changed

packages/plugin-avalanche/src/actions/tokenMillCreate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function isTokenMillCreateContent(
2323
runtime: IAgentRuntime,
2424
content: any
2525
): content is TokenMillCreateContent {
26-
console.log("Content for create", content);
26+
elizaLogger.debug("Content for create", content);
2727
return (
2828
typeof content.name === "string" && typeof content.symbol === "string"
2929
);
@@ -98,7 +98,7 @@ export default {
9898

9999
// Validate transfer content
100100
if (!isTokenMillCreateContent(runtime, content)) {
101-
console.error("Invalid content for CREATE_TOKEN action.");
101+
elizaLogger.error("Invalid content for CREATE_TOKEN action.");
102102
callback?.({
103103
text: "Unable to process transfer request. Invalid content provided.",
104104
content: { error: "Invalid content" },

packages/plugin-avalanche/src/actions/transfer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function isTransferContent(
2626
runtime: IAgentRuntime,
2727
content: any
2828
): content is TransferContent {
29-
console.log("Content for transfer", content);
29+
elizaLogger.debug("Content for transfer", content);
3030
return (
3131
typeof content.tokenAddress === "string" &&
3232
typeof content.recipient === "string" &&
@@ -133,7 +133,7 @@ export default {
133133

134134
// Validate transfer content
135135
if (!isTransferContent(runtime, content)) {
136-
console.error("Invalid content for TRANSFER_TOKEN action.");
136+
elizaLogger.error("Invalid content for TRANSFER_TOKEN action.");
137137
callback?.({
138138
text: "Unable to process transfer request. Invalid content provided.",
139139
content: { error: "Invalid transfer content" },

packages/plugin-avalanche/src/actions/yakStrategy.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function isStrategyContent(
2626
runtime: IAgentRuntime,
2727
content: any
2828
): content is StrategyContent {
29-
console.log("Content for strategy", content);
29+
elizaLogger.debug("Content for strategy", content);
3030
return (
3131
typeof content.depositTokenAddress === "string" &&
3232
typeof content.strategyAddress === "string" &&
@@ -120,7 +120,9 @@ export default {
120120

121121
// Validate content
122122
if (!isStrategyContent(runtime, content)) {
123-
console.error("Invalid content for DEPOSIT_TO_STRATEGY action.");
123+
elizaLogger.error(
124+
"Invalid content for DEPOSIT_TO_STRATEGY action."
125+
);
124126
callback?.({
125127
text: "Unable to process deposit request. Invalid content provided.",
126128
content: { error: "Invalid deposit content" },
@@ -129,14 +131,14 @@ export default {
129131
}
130132

131133
// Log the swap content
132-
console.log("Deposit content:", content);
134+
elizaLogger.debug("Deposit content:", content);
133135

134136
if (
135137
content.depositTokenAddress ===
136138
"0x0000000000000000000000000000000000000000"
137139
) {
138140
// todo: deposit from native
139-
console.log("Swapping from native AVAX");
141+
elizaLogger.log("Swapping from native AVAX");
140142
} else {
141143
const tx = await approve(
142144
runtime,

packages/plugin-avalanche/src/actions/yakSwap.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function isSwapContent(
2727
runtime: IAgentRuntime,
2828
content: any
2929
): content is SwapContent {
30-
console.log("Content for swap", content);
30+
elizaLogger.debug("Content for swap", content);
3131
return (
3232
typeof content.fromTokenAddress === "string" &&
3333
typeof content.toTokenAddress === "string" &&
@@ -140,7 +140,7 @@ export default {
140140

141141
// Validate swap content
142142
if (!isSwapContent(runtime, content)) {
143-
console.error("Invalid content for SWAP_TOKEN action.");
143+
elizaLogger.error("Invalid content for SWAP_TOKEN action.");
144144
callback?.({
145145
text: "Unable to process swap request. Invalid content provided.",
146146
content: { error: "Invalid swap content" },
@@ -149,7 +149,7 @@ export default {
149149
}
150150

151151
// Log the swap content
152-
console.log("Swap content:", content);
152+
elizaLogger.debug("Swap content:", content);
153153
const quote = await getQuote(
154154
runtime,
155155
content.fromTokenAddress as Address,
@@ -163,13 +163,13 @@ export default {
163163
"0x0000000000000000000000000000000000000000"
164164
) {
165165
// todo: swap from native
166-
console.log("Swapping from native AVAX");
166+
elizaLogger.log("Swapping from native AVAX");
167167
} else if (
168168
content.toTokenAddress ===
169169
"0x0000000000000000000000000000000000000000"
170170
) {
171171
// todo: swap to native
172-
console.log("Swapping to native AVAX");
172+
elizaLogger.log("Swapping to native AVAX");
173173
} else {
174174
const yakRouterAddress = YAK_SWAP_CONFIG.router as Address;
175175
const tx = await approve(
@@ -195,21 +195,21 @@ export default {
195195
if (swapTx) {
196196
receipt = await getTxReceipt(runtime, swapTx);
197197
if (receipt.status === "success") {
198-
console.log("Swap successful");
198+
elizaLogger.log("Swap successful");
199199
callback?.({
200200
text: "swap successful",
201201
content: { success: true, txHash: swapTx },
202202
});
203203
} else {
204-
console.error("Swap failed");
204+
elizaLogger.error("Swap failed");
205205
callback?.({
206206
text: "swap failed",
207207
content: { error: "Swap failed" },
208208
});
209209
}
210210
}
211211
} else {
212-
console.error("Approve failed");
212+
elizaLogger.error("Approve failed");
213213
callback?.({
214214
text: "approve failed",
215215
content: { error: "Approve failed" },

packages/plugin-avalanche/src/providers/strategies.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
1+
import {
2+
IAgentRuntime,
3+
Memory,
4+
Provider,
5+
State,
6+
elizaLogger,
7+
} from "@elizaos/core";
28
import { STRATEGY_ADDRESSES } from "../utils/constants";
39

410
const strategiesProvider: Provider = {
511
get: async (_runtime: IAgentRuntime, _message: Memory, _state?: State) => {
6-
console.log("strategiesProvider::get");
12+
elizaLogger.debug("strategiesProvider::get");
713
const strategies = Object.entries(STRATEGY_ADDRESSES)
814
.map(([key, value]) => `${key}: ${value}`)
915
.join("\n");

packages/plugin-avalanche/src/providers/tokens.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
1+
import {
2+
IAgentRuntime,
3+
Memory,
4+
Provider,
5+
State,
6+
elizaLogger,
7+
} from "@elizaos/core";
28
import { TOKEN_ADDRESSES } from "../utils/constants";
39

410
const tokensProvider: Provider = {
511
get: async (_runtime: IAgentRuntime, _message: Memory, _state?: State) => {
6-
console.log("tokensProvider::get");
12+
elizaLogger.debug("tokensProvider::get");
713
const tokens = Object.entries(TOKEN_ADDRESSES)
814
.map(([key, value]) => `${key}: ${value}`)
915
.join("\n");

packages/plugin-avalanche/src/providers/wallet.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
1+
import {
2+
IAgentRuntime,
3+
Memory,
4+
Provider,
5+
State,
6+
elizaLogger,
7+
} from "@elizaos/core";
28
import { formatUnits } from "viem";
39
import { getAccount, getDecimals, getTokenBalance } from "../utils";
410
import { STRATEGY_ADDRESSES, TOKEN_ADDRESSES } from "../utils/constants";
511

612
const walletProvider: Provider = {
713
get: async (runtime: IAgentRuntime, _message: Memory, _state?: State) => {
8-
console.log("walletProvider::get");
14+
elizaLogger.debug("walletProvider::get");
915
const privateKey = runtime.getSetting("AVALANCHE_PRIVATE_KEY");
1016
if (!privateKey) {
1117
throw new Error(
@@ -42,7 +48,7 @@ const walletProvider: Provider = {
4248
}
4349
output += `Note: These balances must be withdrawn from the strategy before they can be used.\n\n`;
4450

45-
console.log("walletProvider::get output:", output);
51+
elizaLogger.debug("walletProvider::get output:", output);
4652
return output;
4753
},
4854
};

packages/plugin-avalanche/src/utils/index.ts

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IAgentRuntime } from "@elizaos/core";
1+
import { IAgentRuntime, elizaLogger } from "@elizaos/core";
22
import {
33
createPublicClient,
44
createWalletClient,
@@ -11,7 +11,6 @@ import { privateKeyToAccount } from "viem/accounts";
1111
import { avalanche } from "viem/chains";
1212
import { YakSwapQuote } from "../types";
1313
import { YAK_SWAP_CONFIG } from "./constants";
14-
import { elizaLogger } from "@elizaos/core";
1514

1615
export const getAccount = (runtime: IAgentRuntime) => {
1716
const privateKey =
@@ -196,7 +195,7 @@ export const getQuote = async (
196195
gasPrice,
197196
],
198197
});
199-
console.log("Quote:", quote);
198+
elizaLogger.log("Quote:", quote);
200199
return quote as YakSwapQuote;
201200
};
202201

@@ -264,11 +263,11 @@ export const sendToken = async (
264263
throw new Error("Transfer failed");
265264
}
266265

267-
console.log("Request:", request);
266+
elizaLogger.debug("Request:", request);
268267

269268
const walletClient = getWalletClient(runtime);
270269
const tx = await walletClient.writeContract(request);
271-
console.log("Transaction:", tx);
270+
elizaLogger.log("Transaction:", tx);
272271
return tx as Hash;
273272
} catch (error) {
274273
elizaLogger.error("Error simulating contract:", error);
@@ -322,11 +321,11 @@ export const approve = async (
322321
throw new Error("Approve failed");
323322
}
324323

325-
console.log("Request:", request);
324+
elizaLogger.debug("Request:", request);
326325

327326
const walletClient = getWalletClient(runtime);
328327
const tx = await walletClient.writeContract(request);
329-
console.log("Transaction:", tx);
328+
elizaLogger.log("Transaction:", tx);
330329
return tx;
331330
} catch (error) {
332331
elizaLogger.error("Error approving:", error);
@@ -405,11 +404,11 @@ export const swap = async (
405404
args: [trade, recipient || account.address, 0n],
406405
});
407406

408-
console.log("Request:", request);
407+
elizaLogger.debug("Request:", request);
409408

410409
const walletClient = getWalletClient(runtime);
411410
const tx = await walletClient.writeContract(request);
412-
console.log("Transaction:", tx);
411+
elizaLogger.log("Transaction:", tx);
413412
return tx;
414413
} catch (error) {
415414
elizaLogger.error("Error simulating contract:", error);
@@ -452,11 +451,11 @@ export const deposit = async (
452451
// throw new Error('Deposit failed')
453452
// }
454453

455-
console.log("Request:", request);
454+
elizaLogger.debug("Request:", request);
456455

457456
const walletClient = getWalletClient(runtime);
458457
const tx = await walletClient.writeContract(request);
459-
console.log("Transaction:", tx);
458+
elizaLogger.log("Transaction:", tx);
460459
return tx;
461460
} catch (error) {
462461
elizaLogger.error("Error depositing:", error);

packages/plugin-avalanche/src/utils/tokenMill.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getAccount, getWalletClient, getPublicClient } from "./index";
22
import { TOKEN_ADDRESSES, TOKEN_MILL_CONFIG } from "./constants";
3-
import { IAgentRuntime } from "@elizaos/core";
3+
import { IAgentRuntime, elizaLogger } from "@elizaos/core";
44
import { TokenMillMarketCreationParameters } from "../types";
55
import { Address, encodeAbiParameters, parseUnits } from "viem";
66

@@ -140,14 +140,14 @@ export const createMarketAndToken = async (
140140
throw new Error("Create failed");
141141
}
142142

143-
console.log("request", request);
144-
console.log("result", result);
143+
elizaLogger.debug("request", request);
144+
elizaLogger.debug("result", result);
145145

146-
console.log("Request:", request);
146+
elizaLogger.debug("Request:", request);
147147

148148
const walletClient = getWalletClient(runtime);
149149
const tx = await walletClient.writeContract(request);
150-
console.log("Transaction:", tx);
150+
elizaLogger.log("Transaction:", tx);
151151

152152
return {
153153
tx: tx,

0 commit comments

Comments
 (0)