Skip to content

Commit

Permalink
Merge pull request #3075 from AIFlowML/fix-plugin-cronoszkevm
Browse files Browse the repository at this point in the history
fix: plugin-cronoszkevm lint
  • Loading branch information
odilitime authored Jan 31, 2025
2 parents 9f57259 + 25658a6 commit 97704e3
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 15 deletions.
41 changes: 41 additions & 0 deletions packages/plugin-cronoszkevm/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "error"
},
"suspicious": {
"noExplicitAny": "error"
},
"style": {
"useConst": "error",
"useImportType": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "es5"
}
},
"files": {
"ignore": [
"dist/**/*",
"extra/**/*",
"node_modules/**/*"
]
}
}
3 changes: 0 additions & 3 deletions packages/plugin-cronoszkevm/eslint.config.mjs

This file was deleted.

9 changes: 8 additions & 1 deletion packages/plugin-cronoszkevm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@
"tsup": "^8.3.5",
"viem": "2.22.2"
},
"devDependencies": {
"@biomejs/biome": "1.9.4"
},
"scripts": {
"build": "tsup --format esm --dts",
"lint": "eslint --fix --cache ."
"clean": "rm -rf dist",
"lint": "biome lint .",
"lint:fix": "biome check --apply .",
"format": "biome format .",
"format:fix": "biome format --write ."
},
"peerDependencies": {
"whatwg-url": "7.1.0"
Expand Down
17 changes: 8 additions & 9 deletions packages/plugin-cronoszkevm/src/actions/transferAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ export const TransferAction: Action = {
elizaLogger.log("Starting Cronos zkEVM SEND_TOKEN handler...");

// Initialize or update state
if (!state) {
state = (await runtime.composeState(message)) as State;
let currentState = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
currentState = await runtime.updateRecentMessageState(currentState);
}

// Compose transfer context
const transferContext = composeContext({
state,
state: currentState,
template: transferTemplate,
});

Expand Down Expand Up @@ -153,7 +154,7 @@ export const TransferAction: Action = {
const account = useGetAccount(runtime);
const walletClient = useGetWalletClient();

let hash;
let hash: `0x${string}`;

// Check if the token is native
if (
Expand Down Expand Up @@ -189,13 +190,11 @@ export const TransferAction: Action = {
}

elizaLogger.success(
"Transfer completed successfully! Transaction hash: " + hash
`Transfer completed successfully! Transaction hash: ${hash}`
);
if (callback) {
callback({
text:
"Transfer completed successfully! Transaction hash: " +
hash,
text: `Transfer completed successfully! Transaction hash: ${hash}`,
content: {},
});
}
Expand Down
7 changes: 5 additions & 2 deletions packages/plugin-cronoszkevm/src/hooks/useGetAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import type { PrivateKeyAccount } from "viem/accounts";
import { privateKeyToAccount } from "viem/accounts";

export const useGetAccount = (runtime: IAgentRuntime): PrivateKeyAccount => {
const PRIVATE_KEY = runtime.getSetting("CRONOSZKEVM_PRIVATE_KEY")!;
return privateKeyToAccount(`0x${PRIVATE_KEY}`);
const privateKey = runtime.getSetting("CRONOSZKEVM_PRIVATE_KEY");
if (!privateKey) {
throw new Error("CRONOSZKEVM_PRIVATE_KEY not set");
}
return privateKeyToAccount(`0x${privateKey}`);
};

0 comments on commit 97704e3

Please sign in to comment.