diff --git a/packages/plugin-conflux/src/actions/confiPump.ts b/packages/plugin-conflux/src/actions/confiPump.ts index c5d143787d..ada3c50f8c 100644 --- a/packages/plugin-conflux/src/actions/confiPump.ts +++ b/packages/plugin-conflux/src/actions/confiPump.ts @@ -4,6 +4,7 @@ import { Memory, State, HandlerCallback, + elizaLogger, } from "@elizaos/core"; import { generateObject, composeContext, ModelClass } from "@elizaos/core"; import { @@ -38,7 +39,7 @@ async function ensureAllowance( memeAddress: `0x${string}`, amount: bigint ) { - console.log( + elizaLogger.log( `Checking allowance: token: ${tokenAddress} meme: ${memeAddress} amount: ${amount}` ); @@ -54,10 +55,10 @@ async function ensureAllowance( args: [account.address, memeAddress], }); - console.log("allowance:", allowance); + elizaLogger.log("allowance:", allowance); if (allowance < amount) { - console.log( + elizaLogger.log( `allowance(${allowance}) is less than amount(${amount}), approving...` ); @@ -73,11 +74,11 @@ async function ensureAllowance( kzg: null, }); - console.log(`Approving hash: ${hash}`); + elizaLogger.log(`Approving hash: ${hash}`); await publicClient.waitForTransactionReceipt({ hash }); - console.log(`Approving success: ${hash}`); + elizaLogger.log(`Approving success: ${hash}`); } else { - console.log(`No need to approve`); + elizaLogger.log(`No need to approve`); } } @@ -213,9 +214,13 @@ export const confiPump: Action = { switch (contentObject.action) { case "CREATE_TOKEN": if (!isPumpCreateContent(contentObject)) { - throw new Error("Invalid content"); + elizaLogger.error( + "Invalid PumpCreateContent: ", + contentObject + ); + throw new Error("Invalid PumpCreateContent"); } - console.log( + elizaLogger.log( "creating: ", contentObject.params.name, contentObject.params.symbol, @@ -235,13 +240,17 @@ export const confiPump: Action = { case "BUY_TOKEN": if (!isPumpBuyContent(contentObject)) { - throw new Error("Invalid content"); + elizaLogger.error( + "Invalid PumpBuyContent: ", + contentObject + ); + throw new Error("Invalid PumpBuyContent"); } value = parseUnits( contentObject.params.value.toString(), 18 ); - console.log( + elizaLogger.log( "buying: ", contentObject.params.tokenAddress, value @@ -260,12 +269,16 @@ export const confiPump: Action = { case "SELL_TOKEN": if (!isPumpSellContent(contentObject)) { - throw new Error("Invalid content"); + elizaLogger.error( + "Invalid PumpSellContent: ", + contentObject + ); + throw new Error("Invalid PumpSellContent"); } const tokenAddress = getAddress( contentObject.params.tokenAddress as `0x${string}` ); - console.log( + elizaLogger.log( "selling: ", tokenAddress, account.address, @@ -312,7 +325,7 @@ export const confiPump: Action = { value, account, }); - console.log("simulate: ", simulate); + elizaLogger.log("simulate: ", simulate); const hash = await walletClient.sendTransaction({ account, @@ -332,7 +345,7 @@ export const confiPump: Action = { }); } } catch (error) { - console.error(`Error performing the action: ${error}`); + elizaLogger.error(`Error performing the action: ${error}`); if (callback) { callback({ text: `Failed to perform the action: ${content.object.action}: ${error}`, diff --git a/packages/plugin-conflux/src/types.ts b/packages/plugin-conflux/src/types.ts index a605b5a714..9764386437 100644 --- a/packages/plugin-conflux/src/types.ts +++ b/packages/plugin-conflux/src/types.ts @@ -64,25 +64,13 @@ export function isPumpContent(object: any): object is PumpContent { } export function isPumpCreateContent(object: any): object is PumpCreateContent { - if (PumpCreateSchema.safeParse(object).success) { - return true; - } - console.error("Invalid content: ", object); - return false; + return PumpCreateSchema.safeParse(object).success; } export function isPumpBuyContent(object: any): object is PumpBuyContent { - if (PumpBuySchema.safeParse(object).success) { - return true; - } - console.error("Invalid content: ", object); - return false; + return PumpBuySchema.safeParse(object).success; } export function isPumpSellContent(object: any): object is PumpSellContent { - if (PumpSellSchema.safeParse(object).success) { - return true; - } - console.error("Invalid content: ", object); - return false; + return PumpSellSchema.safeParse(object).success; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24a75803b8..d21bab63e0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1923,10 +1923,10 @@ importers: version: 8.16.0(eslint@9.16.0(jiti@2.4.2))(typescript@5.6.3) jest: specifier: 29.7.0 - version: 29.7.0(@types/node@20.17.9) + version: 29.7.0(@types/node@20.17.9)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) ts-jest: specifier: 29.2.5 - version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.9))(typescript@5.6.3) + version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(esbuild@0.24.2)(jest@29.7.0(@types/node@20.17.9)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)))(typescript@5.6.3) typescript: specifier: 5.6.3 version: 5.6.3 @@ -31422,21 +31422,6 @@ snapshots: - supports-color - ts-node - create-jest@29.7.0(@types/node@20.17.9): - dependencies: - '@jest/types': 29.6.3 - chalk: 4.1.2 - exit: 0.1.2 - graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.17.9)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@22.8.4)(typescript@5.6.3)) - jest-util: 29.7.0 - prompts: 2.4.2 - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - create-jest@29.7.0(@types/node@20.17.9)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)): dependencies: '@jest/types': 29.6.3 @@ -35310,25 +35295,6 @@ snapshots: - supports-color - ts-node - jest-cli@29.7.0(@types/node@20.17.9): - dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@22.8.4)(typescript@5.6.3)) - '@jest/test-result': 29.7.0 - '@jest/types': 29.6.3 - chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.17.9) - exit: 0.1.2 - import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.17.9)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@22.8.4)(typescript@5.6.3)) - jest-util: 29.7.0 - jest-validate: 29.7.0 - yargs: 17.7.2 - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - jest-cli@29.7.0(@types/node@20.17.9)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)): dependencies: '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) @@ -35350,7 +35316,7 @@ snapshots: jest-cli@29.7.0(@types/node@22.10.2): dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@22.8.4)(typescript@5.6.3)) + '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 @@ -35804,18 +35770,6 @@ snapshots: - supports-color - ts-node - jest@29.7.0(@types/node@20.17.9): - dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@22.8.4)(typescript@5.6.3)) - '@jest/types': 29.6.3 - import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.17.9) - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - jest@29.7.0(@types/node@20.17.9)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)): dependencies: '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) @@ -35830,7 +35784,7 @@ snapshots: jest@29.7.0(@types/node@22.10.2): dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@22.8.4)(typescript@5.6.3)) + '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) '@jest/types': 29.6.3 import-local: 3.2.0 jest-cli: 29.7.0(@types/node@22.10.2) @@ -41881,25 +41835,6 @@ snapshots: '@jest/types': 29.6.3 babel-jest: 29.7.0(@babel/core@7.26.0) - ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.9))(typescript@5.6.3): - dependencies: - bs-logger: 0.2.6 - ejs: 3.1.10 - fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@20.17.9) - jest-util: 29.7.0 - json5: 2.2.3 - lodash.memoize: 4.1.2 - make-error: 1.3.6 - semver: 7.6.3 - typescript: 5.6.3 - yargs-parser: 21.1.1 - optionalDependencies: - '@babel/core': 7.26.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.26.0) - ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@22.8.4)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@22.8.4)(typescript@5.6.3)))(typescript@5.6.3): dependencies: bs-logger: 0.2.6