Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
monilpat committed Feb 8, 2025
1 parent 21dd10c commit 1813166
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion packages/client-coinbase/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class CoinbaseClient implements Client {
async initialize(): Promise<void> {
elizaLogger.info("Initializing Coinbase client");
try {
elizaLogger.info("Coinbase client initialized successfully");
// await this.initializeWallets();
elizaLogger.info("Wallets initialized successfully");
await this.setupWebhookEndpoint();
Expand Down Expand Up @@ -517,6 +516,10 @@ export async function getTotalBalanceUSD(
"USDC",
"base"
);
if (priceInquiry == null) {
elizaLogger.error("priceInquiry is null");
return 0;
}
// get latest quote
const quote = await getQuoteObj(runtime, priceInquiry, publicKey);
const ethBalanceUSD = Number(quote.buyAmount) / 1e6;
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-0x/src/actions/getIndicativePrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export const getPriceInquiry = async (
if (!price) return null;

// Handle token approvals
const approved = await handleTokenApprovals(client, price, sellTokenMetadata.address);
const approved = await handleTokenApprovals(client, price, sellTokenMetadata.address as `0x${string}`);
if (!approved) return null;

// Format response
Expand Down Expand Up @@ -409,7 +409,7 @@ const getPrice = async (zxClient: any, params: any): Promise<GetIndicativePriceR
}
};

const handleTokenApprovals = async (client: any, price: GetIndicativePriceResponse, sellTokenAddress: string = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'): Promise<boolean> => {
const handleTokenApprovals = async (client: any, price: GetIndicativePriceResponse, sellTokenAddress: `0x${string}` = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'): Promise<boolean> => {
try {
const sellTokenContract = getContract({
address: sellTokenAddress,
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-coinbase/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ export async function initializeWallet(
elizaLogger.error("Invalid wallet type provided.");
throw new Error("Invalid wallet type");
}
elizaLogger.log("Importing existing wallet using stored seed and wallet ID:", {
elizaLogger.info("Importing existing wallet using stored seed and wallet ID:", {
seed,
walletId,
walletType,
networkId,
});
if (!seed || seed === '') {
// No stored seed or wallet ID, creating a new wallet
wallet = await Wallet.create({ networkId: "ethereum-mainnet" });
wallet = await Wallet.create({ networkId: networkId});
elizaLogger.log("Created new wallet:", wallet.getId());
// Export wallet data directly
const walletData: WalletData = wallet.export();
Expand Down Expand Up @@ -126,6 +126,7 @@ export async function initializeWallet(
} else {
// Importing existing wallet using stored seed and wallet ID
// Always defaults to base-mainnet we can't select the network here

wallet = await Wallet.import(
seed as unknown as MnemonicSeedPhrase,
networkId,
Expand Down

0 comments on commit 1813166

Please sign in to comment.