Skip to content

Commit

Permalink
feat(near/wallet): replace console.log to elizaLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
sinecose committed Jan 3, 2025
1 parent 1ff97b4 commit 953bc3d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/plugin-near/src/providers/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
import {
IAgentRuntime,
Memory,
Provider,
State,
elizaLogger,
} from "@elizaos/core";
import { KeyPair, keyStores, connect, Account, utils } from "near-api-js";
import BigNumber from "bignumber.js";
import { KeyPairString } from "near-api-js/lib/utils";
Expand Down Expand Up @@ -51,7 +57,7 @@ export class WalletProvider implements Provider {
try {
return await this.getFormattedPortfolio(runtime);
} catch (error) {
console.error("Error in wallet provider:", error);
elizaLogger.error("Error in wallet provider:", error);
return null;
}
}
Expand Down Expand Up @@ -102,7 +108,7 @@ export class WalletProvider implements Provider {
}
return await response.json();
} catch (error) {
console.error(`Attempt ${i + 1} failed:`, error);
elizaLogger.error(`Attempt ${i + 1} failed:`, error);
lastError = error as Error;
if (i < PROVIDER_CONFIG.MAX_RETRIES - 1) {
await new Promise((resolve) =>
Expand All @@ -125,7 +131,7 @@ export class WalletProvider implements Provider {
const cachedValue = this.cache.get<WalletPortfolio>(cacheKey);

if (cachedValue) {
console.log("Cache hit for fetchPortfolioValue");
elizaLogger.log("Cache hit for fetchPortfolioValue");
return cachedValue;
}

Expand Down Expand Up @@ -160,7 +166,7 @@ export class WalletProvider implements Provider {
this.cache.set(cacheKey, portfolio);
return portfolio;
} catch (error) {
console.error("Error fetching portfolio:", error);
elizaLogger.error("Error fetching portfolio:", error);
throw error;
}
}
Expand All @@ -181,7 +187,7 @@ export class WalletProvider implements Provider {
this.cache.set(cacheKey, price);
return price;
} catch (error) {
console.error("Error fetching NEAR price:", error);
elizaLogger.error("Error fetching NEAR price:", error);
return 0;
}
}
Expand Down Expand Up @@ -214,7 +220,7 @@ export class WalletProvider implements Provider {
const portfolio = await this.fetchPortfolioValue(runtime);
return this.formatPortfolio(runtime, portfolio);
} catch (error) {
console.error("Error generating portfolio report:", error);
elizaLogger.error("Error generating portfolio report:", error);
return "Unable to fetch wallet information. Please try again later.";
}
}
Expand All @@ -234,7 +240,7 @@ const walletProvider: Provider = {
const provider = new WalletProvider(accountId);
return await provider.getFormattedPortfolio(runtime);
} catch (error) {
console.error("Error in wallet provider:", error);
elizaLogger.error("Error in wallet provider:", error);
return null;
}
},
Expand Down

0 comments on commit 953bc3d

Please sign in to comment.