diff --git a/docs/docs/packages/adapters.md b/docs/docs/packages/adapters.md index 82be60af69e..5b9f7a34549 100644 --- a/docs/docs/packages/adapters.md +++ b/docs/docs/packages/adapters.md @@ -753,5 +753,5 @@ class CustomDatabaseAdapter extends DatabaseAdapter { ## Related Resources -- [Database Schema Reference](/api) -- [Error Handling](../../packages/core) +- [Database Schema Reference](/api/classes/DatabaseAdapter/) +- [Error Handling](../../packages/core/#error-handling) diff --git a/docs/docs/packages/clients.md b/docs/docs/packages/clients.md index 869999de5d3..5b6fd0e7462 100644 --- a/docs/docs/packages/clients.md +++ b/docs/docs/packages/clients.md @@ -603,4 +603,4 @@ async processMessage(message) { ## Related Resources -- [Error Handling](../../packages/core) +- [Error Handling](../../packages/core/#error-handling) diff --git a/docs/docs/packages/plugins.md b/docs/docs/packages/plugins.md index a1ccb668380..d23a4f928ed 100644 --- a/docs/docs/packages/plugins.md +++ b/docs/docs/packages/plugins.md @@ -773,7 +773,7 @@ Agent: "I'll get the inference now..." Agent: "Inference provided by Allora Network on topic ETH 5min Prediction (ID: 13): 3393.364326646801085508" ``` -For detailed information and additional implementation examples, please refer to the [Allora-Eliza integration docs](https://docs.allora.network/marketplace/integrations/eliza-os). +For detailed information and additional implementation examples, please refer to the [Allora-Eliza integration docs](https://docs.allora.network/marketplace/integrations/eliza-os/implementation). ### 13. Form Plugin (`@elizaos/plugin-form`) diff --git a/packages/plugin-avail/biome.json b/packages/plugin-avail/biome.json new file mode 100644 index 00000000000..818716a6219 --- /dev/null +++ b/packages/plugin-avail/biome.json @@ -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/**/*" + ] + } +} \ No newline at end of file diff --git a/packages/plugin-avail/package.json b/packages/plugin-avail/package.json index fceecab229e..5c4fb44aafb 100644 --- a/packages/plugin-avail/package.json +++ b/packages/plugin-avail/package.json @@ -14,13 +14,18 @@ "tsup": "8.3.5", "@polkadot/types": "^10.11.3", "vitest": "^2.1.8", - "@vitest/coverage-v8": "^2.1.8" + "@vitest/coverage-v8": "^2.1.8", + "@biomejs/biome": "1.9.4" }, "scripts": { "build": "tsup --format esm --dts", "dev": "tsup --format esm --dts --watch", "test": "vitest run", "test:watch": "vitest watch", - "test:coverage": "vitest run --coverage" + "test:coverage": "vitest run --coverage", + "lint": "biome lint .", + "lint:fix": "biome check --apply .", + "format": "biome format .", + "format:fix": "biome format --write ." } } diff --git a/packages/plugin-avail/src/actions/submitData.ts b/packages/plugin-avail/src/actions/submitData.ts index 2eead848c16..afde061c88a 100644 --- a/packages/plugin-avail/src/actions/submitData.ts +++ b/packages/plugin-avail/src/actions/submitData.ts @@ -18,7 +18,7 @@ import { getKeyringFromSeed, } from "avail-js-sdk"; import type { H256 } from "@polkadot/types/interfaces/runtime"; -import { ISubmittableResult } from "@polkadot/types/types"; +import type { ISubmittableResult } from "@polkadot/types/types"; export interface DataContent extends Content { data: string; @@ -79,15 +79,16 @@ export default { elizaLogger.log("Starting SUBMIT_DATA 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 submitDataContext = composeContext({ - state, + state: currentState, template: submitDataTemplate, }); @@ -112,7 +113,8 @@ export default { // } if (content.data != null) { try { - const SEED = runtime.getSetting("AVAIL_SEED")!; + const SEED = runtime.getSetting("AVAIL_SEED"); + if (!SEED) throw new Error("AVAIL_SEED not set"); //const ACCOUNT = runtime.getSetting("AVAIL_ADDRESS")!; const ENDPOINT = runtime.getSetting("AVAIL_RPC_URL"); const APP_ID = runtime.getSetting("AVAIL_APP_ID"); @@ -134,7 +136,7 @@ export default { `); //submit data - const txResult:ISubmittableResult = await new Promise( + const txResult:ISubmittableResult = await new Promise( (res) => { api.tx.dataAvailability .submitData(data) @@ -146,7 +148,7 @@ export default { `Tx status: ${result.status}` ); if (result.isFinalized || result.isError) { - res(result as any); + res(result); } } ); @@ -155,12 +157,12 @@ export default { // Rejected Transaction handling if (txResult.isError) { - console.log(`Transaction was not executed`); + console.log('Transaction was not executed'); } // Failed Transaction handling const error = txResult.dispatchError; - if (error != undefined) { + if (error !== undefined) { if (error.isModule) { const decoded = api.registry.findMetaError( error.asModule @@ -173,8 +175,7 @@ export default { } elizaLogger.success( - "Data submitted successfully! tx: \n " + - `Tx Hash: ${txResult.txHash as H256}, Block Hash: ${txResult.status.asFinalized as H256}` + `Data submitted successfully! tx: \nTx Hash: ${txResult.txHash as H256}, Block Hash: ${txResult.status.asFinalized as H256}` ); if (callback) { callback({ diff --git a/packages/plugin-avail/src/actions/transfer.ts b/packages/plugin-avail/src/actions/transfer.ts index d5deeb4491d..85e66280ed2 100644 --- a/packages/plugin-avail/src/actions/transfer.ts +++ b/packages/plugin-avail/src/actions/transfer.ts @@ -92,15 +92,16 @@ export default { elizaLogger.log("Starting 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, }); @@ -126,7 +127,8 @@ export default { if (content.amount != null && content.recipient != null) { try { - const SEED = runtime.getSetting("AVAIL_SEED")!; + const SEED = runtime.getSetting("AVAIL_SEED"); + if (!SEED) throw new Error("AVAIL_SEED not set"); //const PUBLIC_KEY = runtime.getSetting("AVAIL_ADDRESS")!; const ENDPOINT = runtime.getSetting("AVAIL_RPC_URL"); @@ -136,15 +138,13 @@ export default { const decimals = getDecimals(api); const amount = formatNumberToBalance(content.amount, decimals); - const oldBalance: any = await api.query.system.account( - content.recipient - ); + const oldBalance = await api.query.system.account(content.recipient); elizaLogger.log( - `Balance before the transfer call: ${oldBalance["data"]["free"].toHuman()}` + `Balance before the transfer call: ${oldBalance.toString()}` ); // Transaction call - const txResult:ISubmittableResult = await new Promise( + const txResult:ISubmittableResult = await new Promise( (res) => { api.tx.balances .transferKeepAlive(content.recipient, amount) @@ -156,7 +156,7 @@ export default { `Tx status: ${result.status}` ); if (result.isFinalized || result.isError) { - res(result as any); + res(result); } } ); @@ -166,8 +166,8 @@ export default { // Error handling const error = txResult.dispatchError; if (txResult.isError) { - elizaLogger.log(`Transaction was not executed`); - } else if (error != undefined) { + elizaLogger.log("Transaction was not executed"); + } else if (error !== undefined) { if (error.isModule) { const decoded = api.registry.findMetaError( error.asModule @@ -181,16 +181,13 @@ export default { } } - const newBalance: any = await api.query.system.account( - content.recipient - ); + const newBalance = await api.query.system.account(content.recipient); elizaLogger.log( - `Balance after the transfer call: ${newBalance["data"]["free"].toHuman()}` + `Balance after the transfer call: ${newBalance.toString()}` ); elizaLogger.success( - "Transfer completed successfully! tx: \n " + - `Tx Hash: ${txResult.txHash as H256}, Block Hash: ${txResult.status.asFinalized as H256}` + `Transfer completed successfully! tx: \nTx Hash: ${txResult.txHash as H256}, Block Hash: ${txResult.status.asFinalized as H256}` ); if (callback) { callback({ diff --git a/packages/plugin-email-automation/src/services/emailAutomationService.ts b/packages/plugin-email-automation/src/services/emailAutomationService.ts index b16ef9cd7a5..7211a2d466a 100644 --- a/packages/plugin-email-automation/src/services/emailAutomationService.ts +++ b/packages/plugin-email-automation/src/services/emailAutomationService.ts @@ -84,7 +84,7 @@ export class EmailAutomationService extends Service { return { memory, state, - metadata: state?.metadata || {}, + metadata: state?.metadata as Record, timestamp: new Date(), conversationId: memory.id || '' }; @@ -390,4 +390,4 @@ export class EmailAutomationService extends Service { // Default platform return 'unknown'; } -} \ No newline at end of file +}