From dd25f6c0af7a9f23310d0fe033c7e18e75965b6b Mon Sep 17 00:00:00 2001 From: Richard Watts Date: Fri, 17 Jan 2025 16:25:05 +0000 Subject: [PATCH 1/7] (feat) A plugin for the Zilliqa blockchain --- .env.example | 4 + agent/package.json | 7 +- agent/src/index.ts | 12 +- packages/plugin-zilliqa/README.md | 49 ++++ packages/plugin-zilliqa/package.json | 26 ++ packages/plugin-zilliqa/src/actions.ts | 320 +++++++++++++++++++++++++ packages/plugin-zilliqa/src/index.ts | 22 ++ packages/plugin-zilliqa/src/wallet.ts | 84 +++++++ packages/plugin-zilliqa/tsconfig.json | 9 + packages/plugin-zilliqa/tsup.config.ts | 22 ++ 10 files changed, 551 insertions(+), 4 deletions(-) create mode 100644 packages/plugin-zilliqa/README.md create mode 100644 packages/plugin-zilliqa/package.json create mode 100644 packages/plugin-zilliqa/src/actions.ts create mode 100644 packages/plugin-zilliqa/src/index.ts create mode 100644 packages/plugin-zilliqa/src/wallet.ts create mode 100644 packages/plugin-zilliqa/tsconfig.json create mode 100644 packages/plugin-zilliqa/tsup.config.ts diff --git a/.env.example b/.env.example index aa702a32ce2..67ac7897864 100644 --- a/.env.example +++ b/.env.example @@ -357,6 +357,10 @@ MORALIS_API_KEY= EVM_PRIVATE_KEY= EVM_PROVIDER_URL= +# Zilliqa +ZILLIQA_PRIVATE_KEY= +ZILLIQA_PROVIDER_URL= + # Avalanche AVALANCHE_PRIVATE_KEY= AVALANCHE_PUBLIC_KEY= diff --git a/agent/package.json b/agent/package.json index ee414cfd10e..4e3ad17ddfa 100644 --- a/agent/package.json +++ b/agent/package.json @@ -144,9 +144,10 @@ "@elizaos/plugin-dcap": "workspace:*", "@elizaos/plugin-form": "workspace:*", "@elizaos/plugin-ankr": "workspace:*", - "@elizaos/client-xmtp": "workspace:*", + "@elizaos/client-xmtp": "workspace:*", "@elizaos/plugin-btcfun": "workspace:*", - "@elizaos/plugin-trikon": "workspace:*", + "@elizaos/plugin-trikon": "workspace:*", + "@elizaos/plugin-zilliqa": "workspace:*", "readline": "1.3.0", "ws": "8.18.0", "yargs": "17.7.2" @@ -158,4 +159,4 @@ "ts-node": "10.9.2", "tsup": "8.3.5" } -} \ No newline at end of file +} diff --git a/agent/src/index.ts b/agent/src/index.ts index 2305f1d9db7..e05513765f7 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -52,6 +52,8 @@ import { footballPlugin } from "@elizaos/plugin-football" import { bootstrapPlugin } from "@elizaos/plugin-bootstrap" import { normalizeCharacter } from "@elizaos/plugin-di" import createGoatPlugin from "@elizaos/plugin-goat" +import createZilliqaPlugin from "@elizaos/plugin-zilliqa"; + // import { intifacePlugin } from "@elizaos/plugin-intiface"; import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation" import { abstractPlugin } from "@elizaos/plugin-abstract" @@ -750,6 +752,13 @@ export async function createAgent(character: Character, db: IDatabaseAdapter, ca goatPlugin = await createGoatPlugin((secret) => getSecret(character, secret)) } + let zilliqaPlugin: any | undefined; + if (getSecret(character, "ZILLIQA_PRIVATE_KEY")) { + zilliqaPlugin = await createZilliqaPlugin((secret) => + getSecret(character, secret) + ); + } + // Initialize Reclaim adapter if environment variables are present // let verifiableInferenceAdapter; // if ( @@ -846,7 +855,8 @@ export async function createAgent(character: Character, db: IDatabaseAdapter, ca getSecret(character, "ENABLE_TEE_LOG") && ((teeMode !== TEEMode.OFF && walletSecretSalt) || getSecret(character, "SGX")) ? teeLogPlugin : null, getSecret(character, "OMNIFLIX_API_URL") && getSecret(character, "OMNIFLIX_MNEMONIC") ? OmniflixPlugin : null, getSecret(character, "COINBASE_API_KEY") && getSecret(character, "COINBASE_PRIVATE_KEY") && getSecret(character, "COINBASE_NOTIFICATION_URI") ? webhookPlugin : null, - goatPlugin, + goatPlugin, + zilliqaPlugin, getSecret(character, "COINGECKO_API_KEY") || getSecret(character, "COINGECKO_PRO_API_KEY") ? coingeckoPlugin : null, getSecret(character, "MORALIS_API_KEY") ? moralisPlugin : null, getSecret(character, "EVM_PROVIDER_URL") ? goatPlugin : null, diff --git a/packages/plugin-zilliqa/README.md b/packages/plugin-zilliqa/README.md new file mode 100644 index 00000000000..fca7197727f --- /dev/null +++ b/packages/plugin-zilliqa/README.md @@ -0,0 +1,49 @@ +# @elizaos/plugin-zilliqa + +A plugin for integrating Zilliqa blockchain capabilities through the GOAT (Great Onchain Agent Toolkit) framework within the ElizaOS ecosystem. + +## Description + +[GOAT](https://ohmygoat.dev/) 🐐 (Great Onchain Agent Toolkit) is an open-source framework for adding blockchain tools such as wallets, being able to hold or trade tokens, or interacting with blockchain smart contracts, to your AI agent. + +- [Chains supported](https://ohmygoat.dev/chains-wallets-plugins) +- [Plugins supported](https://ohmygoat.dev/chains-wallets-plugins) + +This plugin integrates the GOAT Zilliqa plugin and wallet with Eliza. + +## Installation + +```bash +pnpm install @elizaos/plugin-goat +``` + +## Configuration + +### Environment Variables + +```typescript +EVM_PRIVATE_KEY= +EVM_PROVIDER_URL= +``` + +## Common Issues & Troubleshooting + +1. **Agent not executing an action**: + + - If you are also using the EVM Plugin, sometimes the agent might confuse the action name with an EVM Plugin action name instead of the GOAT Plugin action. Removing the EVM Plugin should fix this issue. There is no need for you to use both plugins at the same time. + - If you are using Trump as a character it might be tricky to get them to perform any action since the character is full of prompts that aim to change the topic of the conversation. To fix this try using a different character or create your own with prompts that are more suitable to what the agent is supposed to do. + +2. **Wallet Connection Issues** + + - Verify private key is correctly formatted + - Check RPC endpoint availability + - Ensure sufficient network balance + +3. **Transaction Issues** + - Verify gas availability + - Check network congestion + - Confirm transaction parameters + +## License + +This plugin is part of the Eliza project. See the main project repository for license information. diff --git a/packages/plugin-zilliqa/package.json b/packages/plugin-zilliqa/package.json new file mode 100644 index 00000000000..c8286ce4736 --- /dev/null +++ b/packages/plugin-zilliqa/package.json @@ -0,0 +1,26 @@ +{ + "name": "@elizaos/plugin-zilliqa", + "version": "0.1.7-alpha.2", + "main": "dist/index.js", + "type": "module", + "types": "dist/index.d.ts", + "dependencies": { + "@elizaos/core": "workspace:*", + "@goat-sdk/adapter-vercel-ai": "0.2.7", + "@goat-sdk/core": "0.4.6", + "@goat-sdk/plugin-zilliqa": "0.1.2", + "@goat-sdk/wallet-evm": "0.2.6", + "@goat-sdk/wallet-viem": "0.2.6", + "@goat-sdk/wallet-zilliqa": "0.2.5", + "@zilliqa-js/account": "^3.5.0", + "@zilliqa-js/zilliqa": "^3.5.0", + "tsup": "8.3.5" + }, + "scripts": { + "build": "tsup --format esm --dts", + "dev": "tsup --format esm --dts --watch" + }, + "peerDependencies": { + "whatwg-url": "7.1.0" + } +} diff --git a/packages/plugin-zilliqa/src/actions.ts b/packages/plugin-zilliqa/src/actions.ts new file mode 100644 index 00000000000..45aadfa633e --- /dev/null +++ b/packages/plugin-zilliqa/src/actions.ts @@ -0,0 +1,320 @@ +import { getOnChainTools } from "@goat-sdk/adapter-vercel-ai"; +import { MODE, USDC, erc20 } from "@goat-sdk/plugin-erc20"; +import { kim } from "@goat-sdk/plugin-kim"; +import { sendETH } from "@goat-sdk/wallet-evm"; +import { WalletClientBase } from "@goat-sdk/core"; +import { zilliqa } from "@goat-sdk/plugin-zilliqa"; + +import { + generateText, + type HandlerCallback, + type IAgentRuntime, + type Memory, + ModelClass, + type State, + composeContext, + elizaLogger, +} from "@elizaos/core"; +import { Zilliqa } from "@zilliqa-js/zilliqa"; + +export async function getOnChainActions( + evmWallet: WalletClientBase, + zilliqaWallet: WalletClientBase +) { + const actionsWithoutHandler = [ + { + name: "GET_BALANCE", + description: + "Retrieve the balance of a zilliqa account using the GET_ZILLIQA_ADDRESS_BALANCE tool or an evm account using the GET_BALANCE tool. Addresses may be expressed as a hex or bech32 address", + similes: [], + validate: async () => true, + examples: [ + [ + { + user: "{{user1}}", + content: { + text: "Tell me the balance of account 0xf0cb24ac66ba7375bf9b9c4fa91e208d9eaabd2e", + }, + }, + { + user: "{{agentName}}", + content: { + text: "The balance of account 0xf0cb24ac66ba7375bf9b9c4fa91e208d9eaabd2e is 2.01 zil", + action: "GET_BALANCE", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Tell me the balance of the account zil17r9jftrxhfeht0umn386j83q3k0240fwn7g70g", + }, + }, + { + user: "{{agentName}}", + content: { + text: "The balance of account zil17r9jftrxhfeht0umn386j83q3k0240fwn7g70g is 18.05 zil", + action: "GET_BALANCE", + }, + }, + ], + ], + }, + { + name: "CONVERT", + description: + "Convert address formats from bech32 to hex using the CONVERT_FROM_BECH32 tool or from hex to bech32 using the CONVERT_TO_BECH32 tool. The addresses to be converted may be either evm or zilliqa", + similes: [], + validate: async () => true, + examples: [ + [ + { + user: "{{user1}}", + content: { + text: "Convert 0xf0cb24ac66ba7375bf9b9c4fa91e208d9eaabd2e to bech32", + }, + }, + { + user: "{{agentName}}", + content: { + text: "The bech32 address for 0xf0cb24ac66ba7375bf9b9c4fa91e208d9eaabd2e is zil17r9jftrxhfeht0umn386j83q3k0240fwn7g70g", + action: "CONVERT", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Convert zil17r9jftrxhfeht0umn386j83q3k0240fwn7g70g to hex", + }, + }, + { + user: "{{agentName}}", + content: { + text: "The hex address for zil17r9jftrxhfeht0umn386j83q3k0240fwn7g70g is 0xf0cb24ac66ba7375bf9b9c4fa91e208d9eaabd2e", + action: "CONVERT", + }, + }, + ], + ], + }, + { + name: "TRANSFER", + description: + "Transfer funds from a Zilliqa address using TRANSFER_FROM_ZILLIQA_ADDRESS or from an EVM address using TRANSFER_FROM_EVM_ADDRESS. Addresses may be in either bech32 or hex format. Both kinds of transfer return the transaction id in hex.", + similes: [], + validate: async () => true, + examples: [ + [ + { + user: "{{user1}}", + content: { + text: "Transfer 2 ZIL from the EVM address zil17r9jftrxhfeht0umn386j83q3k0240fwn7g70g to 0xf0cb24ac66ba7375bf9b9c4fa91e208d9eaabd2e", + action: "TRANSFER", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Transfer 2 ZIL from the Zilliqa address zil17r9jftrxhfeht0umn386j83q3k0240fwn7g70g to 0xf0cb24ac66ba7375bf9b9c4fa91e208d9eaabd2e", + action: "TRANSFER", + }, + }, + ], + ], + }, + // 1. Add your actions here + ]; + + const tools = await getOnChainTools({ + wallet: evmWallet, + // 2. Configure the plugins you need to perform those actions + plugins: [sendETH()], + }); + + const zilTools = await getOnChainTools({ + wallet: zilliqaWallet, + plugins: [zilliqa()], + }); + + const allTools = { ...zilTools, ...tools }; + elizaLogger.info(`allTools = ${JSON.stringify(allTools)}`); + // 3. Let GOAT handle all the actions + return actionsWithoutHandler.map((action) => ({ + ...action, + handler: getActionHandler(action.name, action.description, allTools), + })); +} + +function getActionHandler( + actionName: string, + actionDescription: string, + tools +) { + return async ( + runtime: IAgentRuntime, + message: Memory, + state: State | undefined, + options?: Record, + callback?: HandlerCallback + ): Promise => { + let currentState = state ?? (await runtime.composeState(message)); + currentState = await runtime.updateRecentMessageState(currentState); + + try { + // 1. Call the tools needed + const context = composeActionContext( + actionName, + actionDescription, + currentState + ); + const result = await generateText({ + runtime, + context, + tools, + maxSteps: 10, + // Uncomment to see the log each tool call when debugging + onStepFinish: (step) => { + console.log(step.toolResults); + }, + modelClass: ModelClass.LARGE, + }); + + // 2. Compose the response + const response = composeResponseContext(result, currentState); + const responseText = await generateResponse(runtime, response); + + callback?.({ + text: responseText, + content: {}, + }); + return true; + } catch (error) { + const errorMessage = + error instanceof Error ? error.message : String(error); + + // 3. Compose the error response + const errorResponse = composeErrorResponseContext( + errorMessage, + currentState + ); + const errorResponseText = await generateResponse( + runtime, + errorResponse + ); + + callback?.({ + text: errorResponseText, + content: { error: errorMessage }, + }); + return false; + } + }; +} + +function composeActionContext( + actionName: string, + actionDescription: string, + state: State +): string { + const actionTemplate = ` +# Knowledge +{{knowledge}} + +About {{agentName}}: +{{bio}} +{{lore}} + +{{providers}} + +{{attachments}} + + +# Action: ${actionName} +${actionDescription} + +{{recentMessages}} + +Based on the action chosen and the previous messages, execute the action and respond to the user using the tools you were given. +`; + return composeContext({ state, template: actionTemplate }); +} + +function composeResponseContext(result: unknown, state: State): string { + const responseTemplate = ` + # Action Examples +{{actionExamples}} +(Action examples are for reference only. Do not use the information from them in your response.) + +# Knowledge +{{knowledge}} + +# Task: Generate dialog and actions for the character {{agentName}}. +About {{agentName}}: +{{bio}} +{{lore}} + +{{providers}} + +{{attachments}} + +# Capabilities +Note that {{agentName}} is capable of reading/seeing/hearing various forms of media, including images, videos, audio, plaintext and PDFs. Recent attachments have been included above under the "Attachments" section. + +Here is the result: +${JSON.stringify(result)} + +{{actions}} + +Respond to the message knowing that the action was successful and these were the previous messages: +{{recentMessages}} + `; + return composeContext({ state, template: responseTemplate }); +} + +function composeErrorResponseContext( + errorMessage: string, + state: State +): string { + const errorResponseTemplate = ` +# Knowledge +{{knowledge}} + +# Task: Generate dialog and actions for the character {{agentName}}. +About {{agentName}}: +{{bio}} +{{lore}} + +{{providers}} + +{{attachments}} + +# Capabilities +Note that {{agentName}} is capable of reading/seeing/hearing various forms of media, including images, videos, audio, plaintext and PDFs. Recent attachments have been included above under the "Attachments" section. + +{{actions}} + +Respond to the message knowing that the action failed. +The error was: +${errorMessage} + +These were the previous messages: +{{recentMessages}} + `; + return composeContext({ state, template: errorResponseTemplate }); +} + +async function generateResponse( + runtime: IAgentRuntime, + context: string +): Promise { + return generateText({ + runtime, + context, + modelClass: ModelClass.SMALL, + }); +} diff --git a/packages/plugin-zilliqa/src/index.ts b/packages/plugin-zilliqa/src/index.ts new file mode 100644 index 00000000000..646f0ca84ef --- /dev/null +++ b/packages/plugin-zilliqa/src/index.ts @@ -0,0 +1,22 @@ +import type { Plugin } from "@elizaos/core"; +import { getOnChainActions } from "./actions"; +import { getZilliqaWalletClient, getWalletProviders } from "./wallet"; + +export async function zilliqaPlugin( + getSetting: (key: string) => string | undefined +): Promise { + const zilliqaWalletClient = await getZilliqaWalletClient(getSetting); + const walletClient = zilliqaWalletClient!.getEVM(); + const actions = await getOnChainActions(walletClient, zilliqaWalletClient!); + + return { + name: "[ZILLIQA] Onchain Actions", + description: "Zilliqa integration plugin", + providers: getWalletProviders(walletClient, zilliqaWalletClient), + evaluators: [], + services: [], + actions: actions, + }; +} + +export default zilliqaPlugin; diff --git a/packages/plugin-zilliqa/src/wallet.ts b/packages/plugin-zilliqa/src/wallet.ts new file mode 100644 index 00000000000..89b2631b88b --- /dev/null +++ b/packages/plugin-zilliqa/src/wallet.ts @@ -0,0 +1,84 @@ +import { WalletClientBase } from "@goat-sdk/core"; +import { viem } from "@goat-sdk/wallet-viem"; +import { createWalletClient, http } from "viem"; +import { privateKeyToAccount } from "viem/accounts"; +import { mode } from "viem/chains"; +import { + zilliqaChainId, + zilliqaJSViemWalletClient, +} from "@goat-sdk/wallet-zilliqa"; +import { Account } from "@zilliqa-js/zilliqa"; + +// Add the chain you want to use, remember to update also +// the ZILLIQA_PROVIDER_URL to the correct one for the chain +export const chain = mode; + +function getViemChain(provider, id, decimals): Chain { + return { + id: id | 0x8000, + name: "zilliqa", + nativeCurrency: { + decimals: decimals, + name: "Zil", + symbol: "ZIL", + }, + rpcUrls: { + default: { + https: [provider], + }, + }, + }; +} + +export async function getZilliqaWalletClient( + getSetting: (key: string) => string | undefined +) { + const privateKey = getSetting("ZILLIQA_PRIVATE_KEY"); + if (!privateKey) return null; + + const provider = getSetting("ZILLIQA_PROVIDER_URL"); + if (!provider) throw new Error("ZILLIQA_PROVIDER_URL not configured"); + + const chainId = await zilliqaChainId(provider); + const account = new Account(privateKey); + const viemChain = getViemChain(provider, chainId, 18); + const viemWallet = createWalletClient({ + account: privateKeyToAccount(privateKey as `0x${string}`), + chain: viemChain, + transport: http(provider), + }); + + return zilliqaJSViemWalletClient(viemWallet, provider, account, chainId); +} + +export function getWalletProviders( + walletClient: WalletClientBase, + zilliqa: ZilliqaWalletClient +) { + return [ + { + async get(): Promise { + try { + const address = walletClient.getAddress(); + const balance = await walletClient.balanceOf(address); + return `EVM Wallet Address: ${address}\nBalance: ${balance} ZIL`; + } catch (error) { + console.error("Error in EVM wallet provider:", error); + return null; + } + }, + }, + { + async get(): Promise { + try { + const address = + zilliqa.getZilliqa().wallet.defaultAccount?.address; + return `Zilliqa wallet address: ${address}\n`; + } catch (error) { + console.error("Error in zilliqa wallet provider:", error); + return null; + } + }, + }, + ]; +} diff --git a/packages/plugin-zilliqa/tsconfig.json b/packages/plugin-zilliqa/tsconfig.json new file mode 100644 index 00000000000..f642a90aee1 --- /dev/null +++ b/packages/plugin-zilliqa/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../core/tsconfig.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "./src", + "declaration": true + }, + "include": ["src"] +} diff --git a/packages/plugin-zilliqa/tsup.config.ts b/packages/plugin-zilliqa/tsup.config.ts new file mode 100644 index 00000000000..5385e92cf89 --- /dev/null +++ b/packages/plugin-zilliqa/tsup.config.ts @@ -0,0 +1,22 @@ +import { defineConfig } from "tsup"; + +export default defineConfig({ + entry: ["src/index.ts"], + outDir: "dist", + sourcemap: true, + clean: true, + format: ["esm"], // Ensure you're targeting CommonJS + external: [ + "dotenv", // Externalize dotenv to prevent bundling + "crypto", // Externalize crypto to use Node.js built-in module + "fs", // Externalize fs to use Node.js built-in module + "path", // Externalize other built-ins if necessary + "@reflink/reflink", + "@node-llama-cpp", + "https", + "http", + "agentkeepalive", + "viem", + "@lifi/sdk", + ], +}); From 1fab59cefd63bf95b463929cc5f8ba747de90652 Mon Sep 17 00:00:00 2001 From: Richard Watts Date: Fri, 17 Jan 2025 18:41:55 +0000 Subject: [PATCH 2/7] (feat) Conditionalise zilliqa plugin (fix) Add action to example (feat) Document zilliqa enable secret --- packages/plugin-zilliqa/README.md | 1 + packages/plugin-zilliqa/src/actions.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/plugin-zilliqa/README.md b/packages/plugin-zilliqa/README.md index fca7197727f..05cb80011a2 100644 --- a/packages/plugin-zilliqa/README.md +++ b/packages/plugin-zilliqa/README.md @@ -24,6 +24,7 @@ pnpm install @elizaos/plugin-goat ```typescript EVM_PRIVATE_KEY= EVM_PROVIDER_URL= +ENABLE_ZILLIQA=1 ``` ## Common Issues & Troubleshooting diff --git a/packages/plugin-zilliqa/src/actions.ts b/packages/plugin-zilliqa/src/actions.ts index 45aadfa633e..5bad958970a 100644 --- a/packages/plugin-zilliqa/src/actions.ts +++ b/packages/plugin-zilliqa/src/actions.ts @@ -34,6 +34,7 @@ export async function getOnChainActions( user: "{{user1}}", content: { text: "Tell me the balance of account 0xf0cb24ac66ba7375bf9b9c4fa91e208d9eaabd2e", + action: "GET_BALANCE", }, }, { From d16b467730f6678f6df6a84bf8869a1c6b3bd6cc Mon Sep 17 00:00:00 2001 From: Richard Watts Date: Tue, 21 Jan 2025 13:15:47 +0000 Subject: [PATCH 3/7] (fix) Harmonise versions of @goat-sdk/core to ensure that subtype tests work --- packages/plugin-goat/package.json | 2 +- packages/plugin-zilliqa/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-goat/package.json b/packages/plugin-goat/package.json index a868b64ed55..718881a0f53 100644 --- a/packages/plugin-goat/package.json +++ b/packages/plugin-goat/package.json @@ -21,7 +21,7 @@ "dependencies": { "@elizaos/core": "workspace:*", "@goat-sdk/adapter-vercel-ai": "0.2.0", - "@goat-sdk/core": "0.4.0", + "@goat-sdk/core": "0.4.6", "@goat-sdk/plugin-erc20": "0.2.2", "@goat-sdk/plugin-kim": "0.1.2", "@goat-sdk/wallet-evm": "0.2.0", diff --git a/packages/plugin-zilliqa/package.json b/packages/plugin-zilliqa/package.json index c8286ce4736..54fa403ff53 100644 --- a/packages/plugin-zilliqa/package.json +++ b/packages/plugin-zilliqa/package.json @@ -8,10 +8,10 @@ "@elizaos/core": "workspace:*", "@goat-sdk/adapter-vercel-ai": "0.2.7", "@goat-sdk/core": "0.4.6", - "@goat-sdk/plugin-zilliqa": "0.1.2", + "@goat-sdk/plugin-zilliqa": "0.1.3", "@goat-sdk/wallet-evm": "0.2.6", "@goat-sdk/wallet-viem": "0.2.6", - "@goat-sdk/wallet-zilliqa": "0.2.5", + "@goat-sdk/wallet-zilliqa": "0.2.6", "@zilliqa-js/account": "^3.5.0", "@zilliqa-js/zilliqa": "^3.5.0", "tsup": "8.3.5" From e271dc22e4e4817e6d6b0d4751afbdfc7368188a Mon Sep 17 00:00:00 2001 From: Richard Watts Date: Wed, 22 Jan 2025 11:19:39 +0000 Subject: [PATCH 4/7] (fix) address PR feedback --- packages/plugin-zilliqa/README.md | 2 +- packages/plugin-zilliqa/src/actions.ts | 1 - packages/plugin-zilliqa/src/index.ts | 3 +++ packages/plugin-zilliqa/src/wallet.ts | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/plugin-zilliqa/README.md b/packages/plugin-zilliqa/README.md index 05cb80011a2..cadde319a1c 100644 --- a/packages/plugin-zilliqa/README.md +++ b/packages/plugin-zilliqa/README.md @@ -14,7 +14,7 @@ This plugin integrates the GOAT Zilliqa plugin and wallet with Eliza. ## Installation ```bash -pnpm install @elizaos/plugin-goat +pnpm install @elizaos/plugin-zilliqa ``` ## Configuration diff --git a/packages/plugin-zilliqa/src/actions.ts b/packages/plugin-zilliqa/src/actions.ts index 5bad958970a..d77a9b230d9 100644 --- a/packages/plugin-zilliqa/src/actions.ts +++ b/packages/plugin-zilliqa/src/actions.ts @@ -143,7 +143,6 @@ export async function getOnChainActions( }); const allTools = { ...zilTools, ...tools }; - elizaLogger.info(`allTools = ${JSON.stringify(allTools)}`); // 3. Let GOAT handle all the actions return actionsWithoutHandler.map((action) => ({ ...action, diff --git a/packages/plugin-zilliqa/src/index.ts b/packages/plugin-zilliqa/src/index.ts index 646f0ca84ef..b7069873f23 100644 --- a/packages/plugin-zilliqa/src/index.ts +++ b/packages/plugin-zilliqa/src/index.ts @@ -6,6 +6,9 @@ export async function zilliqaPlugin( getSetting: (key: string) => string | undefined ): Promise { const zilliqaWalletClient = await getZilliqaWalletClient(getSetting); + if (!zilliqaWalletClient) { + throw new Error("Zilliqa wallet client initialization failed. Ensure that EVM_PRIVATE_KEY and EVM_PROVIDER_URL are configured."); + } const walletClient = zilliqaWalletClient!.getEVM(); const actions = await getOnChainActions(walletClient, zilliqaWalletClient!); diff --git a/packages/plugin-zilliqa/src/wallet.ts b/packages/plugin-zilliqa/src/wallet.ts index 89b2631b88b..6444cb9b4b9 100644 --- a/packages/plugin-zilliqa/src/wallet.ts +++ b/packages/plugin-zilliqa/src/wallet.ts @@ -13,7 +13,7 @@ import { Account } from "@zilliqa-js/zilliqa"; // the ZILLIQA_PROVIDER_URL to the correct one for the chain export const chain = mode; -function getViemChain(provider, id, decimals): Chain { +function getViemChain(provider: string, id: number, decimals: number): Chain { return { id: id | 0x8000, name: "zilliqa", From 9457e0ad28343370fbc110c9e59b51476911289f Mon Sep 17 00:00:00 2001 From: Richard Watts Date: Wed, 22 Jan 2025 11:21:05 +0000 Subject: [PATCH 5/7] (fix) Fix import --- packages/plugin-zilliqa/src/wallet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-zilliqa/src/wallet.ts b/packages/plugin-zilliqa/src/wallet.ts index 6444cb9b4b9..2e8cac2a588 100644 --- a/packages/plugin-zilliqa/src/wallet.ts +++ b/packages/plugin-zilliqa/src/wallet.ts @@ -1,5 +1,5 @@ import { WalletClientBase } from "@goat-sdk/core"; -import { viem } from "@goat-sdk/wallet-viem"; +import { viem, type Chain } from "@goat-sdk/wallet-viem"; import { createWalletClient, http } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { mode } from "viem/chains"; From 990985663e7eb0b1034858ddd8e69f2955730058 Mon Sep 17 00:00:00 2001 From: Richard Watts Date: Mon, 27 Jan 2025 10:12:56 +0000 Subject: [PATCH 6/7] (fix) Fix error message names --- packages/plugin-zilliqa/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-zilliqa/src/index.ts b/packages/plugin-zilliqa/src/index.ts index b7069873f23..84e72c90f08 100644 --- a/packages/plugin-zilliqa/src/index.ts +++ b/packages/plugin-zilliqa/src/index.ts @@ -7,7 +7,7 @@ export async function zilliqaPlugin( ): Promise { const zilliqaWalletClient = await getZilliqaWalletClient(getSetting); if (!zilliqaWalletClient) { - throw new Error("Zilliqa wallet client initialization failed. Ensure that EVM_PRIVATE_KEY and EVM_PROVIDER_URL are configured."); + throw new Error("Zilliqa wallet client initialization failed. Ensure that ZILLIQA_PRIVATE_KEY and ZILLIQA_PROVIDER_URL are configured."); } const walletClient = zilliqaWalletClient!.getEVM(); const actions = await getOnChainActions(walletClient, zilliqaWalletClient!); From 50d33d9f03450abf599a447877a3f49715fda925 Mon Sep 17 00:00:00 2001 From: Richard Watts Date: Mon, 27 Jan 2025 10:20:09 +0000 Subject: [PATCH 7/7] (fix) Fix missing import --- packages/plugin-zilliqa/src/wallet.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugin-zilliqa/src/wallet.ts b/packages/plugin-zilliqa/src/wallet.ts index 2e8cac2a588..47fcf7b6941 100644 --- a/packages/plugin-zilliqa/src/wallet.ts +++ b/packages/plugin-zilliqa/src/wallet.ts @@ -6,6 +6,7 @@ import { mode } from "viem/chains"; import { zilliqaChainId, zilliqaJSViemWalletClient, + ZilliqaWalletClient } from "@goat-sdk/wallet-zilliqa"; import { Account } from "@zilliqa-js/zilliqa";