From 6fd5aece1978e81dc89f17aeae78088dc85fb73f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 19 Jan 2025 21:02:51 +0100 Subject: [PATCH 1/3] Start on adding more actions to abstract plugin --- packages/plugin-abstract/package.json | 5 +- .../src/actions/deployTokenAction.ts | 254 +++++++++++++ .../src/actions/getBalanceAction.ts | 287 +++++++++++++++ packages/plugin-abstract/src/actions/index.ts | 2 + .../src/actions/transferAction.ts | 230 ++++++------ .../src/constants/basicToken.ts | 333 ++++++++++++++++++ .../plugin-abstract/src/constants/index.ts | 6 - packages/plugin-abstract/src/index.ts | 4 +- packages/plugin-abstract/src/utils/index.ts | 2 +- .../src/utils/validateContext.ts | 25 -- .../plugin-abstract/src/utils/viemHelpers.ts | 71 ++++ 11 files changed, 1082 insertions(+), 137 deletions(-) create mode 100644 packages/plugin-abstract/src/actions/deployTokenAction.ts create mode 100644 packages/plugin-abstract/src/actions/getBalanceAction.ts create mode 100644 packages/plugin-abstract/src/constants/basicToken.ts delete mode 100644 packages/plugin-abstract/src/utils/validateContext.ts create mode 100644 packages/plugin-abstract/src/utils/viemHelpers.ts diff --git a/packages/plugin-abstract/package.json b/packages/plugin-abstract/package.json index 22b3dd61f08..8bbf9e043b7 100644 --- a/packages/plugin-abstract/package.json +++ b/packages/plugin-abstract/package.json @@ -25,9 +25,10 @@ "viem": "2.22.2" }, "scripts": { - "build": "tsup --format esm --dts" + "build": "tsup --format esm --dts", + "dev": "tsup --format esm --dts --watch" }, "peerDependencies": { "whatwg-url": "7.1.0" } -} +} \ No newline at end of file diff --git a/packages/plugin-abstract/src/actions/deployTokenAction.ts b/packages/plugin-abstract/src/actions/deployTokenAction.ts new file mode 100644 index 00000000000..daaf56af846 --- /dev/null +++ b/packages/plugin-abstract/src/actions/deployTokenAction.ts @@ -0,0 +1,254 @@ +import type { Action } from "@elizaos/core"; +import { + type ActionExample, + type Content, + type HandlerCallback, + type IAgentRuntime, + type Memory, + ModelClass, + type State, + elizaLogger, + composeContext, + generateObject, + stringToUuid, +} from "@elizaos/core"; +import { validateAbstractConfig } from "../environment"; +import { parseEther, type Hash } from "viem"; +import { abstractTestnet } from "viem/chains"; +import { type AbstractClient, createAbstractClient } from "@abstract-foundation/agw-client"; +import { z } from "zod"; +import { useGetAccount, useGetWalletClient } from "../hooks"; +import { abi as basicTokenAbi, bytecode } from "../constants/basicToken"; +import { abstractPublicClient } from "../utils/viemHelpers"; + +const DeploySchema = z.object({ + name: z.string(), + symbol: z.string(), + initialSupply: z.string(), + useAGW: z.boolean(), +}); + +const validatedSchema = z.object({ + name: z.string().min(1, "Name is required"), + symbol: z.string().min(1, "Symbol is required").max(5, "Symbol must be 5 characters or less"), + initialSupply: z.string().refine( + (val) => !Number.isNaN(Number(val)) && Number(val) > 0, + { message: "Initial supply must be a positive number" } + ), + useAGW: z.boolean(), +}); + +export interface DeployContent extends Content { + name: string; + symbol: string; + initialSupply: string; + useAGW: boolean; +} + +const deployTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined. + +Example response: +\`\`\`json +{ + "name": "My Token", + "symbol": "MTK", + "initialSupply": "1000000", + "useAGW": true +} +\`\`\` + +User message: +"{{currentMessage}}" + +Given the message, extract the following information about the requested token deployment: +- Token name +- Token symbol (usually 3-4 characters) +- Initial supply amount +- Whether to use Abstract Global Wallet aka AGW + +If the user did not specify "global wallet", "AGW", "agw", or "abstract global wallet" in their message, set useAGW to false, otherwise set it to true. + +Respond with a JSON markdown block containing only the extracted values.`; + +export const deployTokenAction: Action = { + name: "DEPLOY_TOKEN", + similes: [ + "CREATE_TOKEN", + "DEPLOY_NEW_TOKEN", + "CREATE_NEW_TOKEN", + "LAUNCH_TOKEN", + ], + validate: async (runtime: IAgentRuntime, message: Memory) => { + await validateAbstractConfig(runtime); + return true; + }, + description: "Deploy a new ERC20 token contract", + handler: async ( + runtime: IAgentRuntime, + message: Memory, + state: State, + _options: { [key: string]: unknown }, + callback?: HandlerCallback + ): Promise => { + elizaLogger.log("Starting Abstract DEPLOY_TOKEN handler..."); + + if (!state) { + state = (await runtime.composeState(message)) as State; + } else { + state = await runtime.updateRecentMessageState(state); + } + + state.currentMessage = `${state.recentMessagesData[1].content.text}`; + const deployContext = composeContext({ + state, + template: deployTemplate, + }); + + const content = ( + await generateObject({ + runtime, + context: deployContext, + modelClass: ModelClass.SMALL, + schema: DeploySchema, + }) + ).object as DeployContent; + + // Validate deployment content + const result = validatedSchema.safeParse(content); + if (!result.success) { + elizaLogger.error("Invalid content for DEPLOY_TOKEN action.", { + errors: result.error.errors + }); + if (callback) { + callback({ + text: "Unable to process token deployment request. Invalid parameters provided.", + content: { error: "Invalid deployment parameters" }, + }); + } + return false; + } + + + try { + const account = useGetAccount(runtime); + const supply = parseEther(content.initialSupply); + let hash: Hash; + + if (content.useAGW) { + const abstractClient = await createAbstractClient({ + chain: abstractTestnet, + signer: account, + }) as AbstractClient; + + hash = await abstractClient.deployContract({ + abi: basicTokenAbi, + bytecode, + args: [result.data.name, result.data.symbol, supply], + }); + } else { + const walletClient = useGetWalletClient(); + + hash = await walletClient.deployContract({ + account, + abi: basicTokenAbi, + bytecode, + args: [result.data.name, result.data.symbol, supply], + }); + } + + // Wait for transaction receipt + const receipt = await abstractPublicClient.waitForTransactionReceipt({ hash }); + const contractAddress = receipt.contractAddress; + + + + + elizaLogger.success(`Token deployment completed! Contract address: ${contractAddress}. Transaction hash: ${hash}`); + if (callback) { + callback({ + text: `Token "${result.data.name}" (${result.data.symbol}) deployed successfully! Contract address: ${contractAddress} and transaction hash: ${hash}`, + content: { hash, tokenName: result.data.name, tokenSymbol: result.data.symbol, contractAddress, transactionHash: hash }, + }); + } + + + const metadata = { + tokenAddress: contractAddress, + name: result.data.name, + symbol: result.data.symbol, + initialSupply: String(result.data.initialSupply), + } + + await runtime.messageManager.createMemory({ + id: stringToUuid(`${result.data.symbol}-${runtime.agentId}`), + userId: runtime.agentId, + content: { + text: `Token deployed: ${result.data.name}, symbol: ${result.data.symbol} and contract address: ${contractAddress}`, + ...metadata, + source: "abstract_token_deployment" + }, + agentId: runtime.agentId, + roomId: stringToUuid(`tokens-${runtime.agentId}`), + createdAt: Date.now() + }); + elizaLogger.success("memory saved for token deployment", metadata) + + + return true; + } catch (error) { + elizaLogger.error("Error during token deployment:", error); + if (callback) { + callback({ + text: `Error deploying token: ${error.message}`, + content: { error: error.message }, + }); + } + return false; + } + }, + + examples: [ + [ + { + user: "{{user1}}", + content: { + text: "Deploy a new token called MyToken with symbol MTK and initial supply of 1000000", + }, + }, + { + user: "{{agent}}", + content: { + text: "I'll deploy your new token now.", + action: "DEPLOY_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully deployed MyToken (MTK) with 1000000 initial supply.\nContract address: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b\nTransaction hash: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Create a new token using AGW with name TestCoin, symbol TEST, and 5000 supply", + }, + }, + { + user: "{{agent}}", + content: { + text: "I'll deploy your token using the Abstract Global Wallet.", + action: "DEPLOY_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully deployed TestCoin (TEST) with 5000 initial supply using AGW.\nContract address: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b\nTransaction: 0x4fed598033f0added272c3ddefd4d83a521634a738474400b27378db462a76ec", + }, + }, + ], + ] as ActionExample[][], +}; diff --git a/packages/plugin-abstract/src/actions/getBalanceAction.ts b/packages/plugin-abstract/src/actions/getBalanceAction.ts new file mode 100644 index 00000000000..15b50c8fb49 --- /dev/null +++ b/packages/plugin-abstract/src/actions/getBalanceAction.ts @@ -0,0 +1,287 @@ +import type { Action } from "@elizaos/core"; +import { + type ActionExample, + type Content, + type HandlerCallback, + type IAgentRuntime, + type Memory, + ModelClass, + type State, + elizaLogger, + composeContext, + generateObject, + stringToUuid, +} from "@elizaos/core"; +import { validateAbstractConfig } from "../environment"; + +import { + + erc20Abi, + formatUnits, + isAddress, +} from "viem"; +import { z } from "zod"; + import { ETH_ADDRESS, } from "../constants"; +import { useGetAccount, } from "../hooks"; +import { resolveAddress, getTokenByName, abstractPublicClient } from "../utils/viemHelpers"; + + + + +const BalanceSchema = z.object({ + tokenAddress: z.string().optional().nullable(), + walletAddress: z.string().optional().nullable(), + tokenSymbol: z.string().optional().nullable(), +}); + +export interface BalanceContent extends Content { + tokenAddress?: string; + walletAddress?: string; + tokenSymbol?: string; +} + + + + + +const validatedSchema = z.object({ + tokenAddress: z.string().refine(isAddress, { message: "Invalid token address" }), + walletAddress: z.string().refine(isAddress, { message: "Invalid token address" }), +}); + +const balanceTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined. + + +Example response: +\`\`\`json +{ + "tokenAddress": "0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E", + "walletAddress": "0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", + "tokenSymbol": "USDC" +} +\`\`\` + +User message: +"{{currentMessage}}" + +Given the message, extract the following information about the requested balance check: +- Token contract address (optional, if not specified set to null) +- Wallet address to check (optional, if not specified set to null) +- The symbol of the token to check (optional, if not specified set to null). Between 1 to 6 characters usually. + +Respond with a JSON markdown block containing only the extracted values.`; + +export const getBalanceAction: Action = { + name: "GET_BALANCE", + similes: [ + "CHECK_BALANCE", + "VIEW_BALANCE", + "SHOW_BALANCE", + "BALANCE_CHECK", + "TOKEN_BALANCE", + ], + validate: async (runtime: IAgentRuntime, message: Memory) => { + await validateAbstractConfig(runtime); + return true; + }, + description: "Check token balance for a given address", + handler: async ( + runtime: IAgentRuntime, + message: Memory, + state: State, + _options: { [key: string]: unknown }, + callback?: HandlerCallback + ): Promise => { + elizaLogger.log("Starting Abstract GET_BALANCE handler..."); + + // Initialize or update state + if (!state) { + state = (await runtime.composeState(message)) as State; + } else { + state = await runtime.updateRecentMessageState(state); + } + + // Compose balance context + state.currentMessage = `${state.recentMessagesData[1].content.text}`; + const balanceContext = composeContext({ + state, + template: balanceTemplate, + }); + + // Generate balance content + const content = ( + await generateObject({ + runtime, + context: balanceContext, + modelClass: ModelClass.SMALL, + schema: BalanceSchema, + }) + ).object as BalanceContent; + + + try { + const account = useGetAccount(runtime); + const addressToCheck = content.walletAddress || account.address; + + // Resolve address + const resolvedAddress = await resolveAddress(addressToCheck); + if (!resolvedAddress) { + throw new Error("Invalid address or ENS name"); + } + + let tokenAddress = content.tokenAddress; + + if(content.tokenSymbol) { + const tokenMemory = await runtime.messageManager.getMemoryById( + stringToUuid(`${content.tokenSymbol}-${runtime.agentId}`) + ); + + if(typeof tokenMemory?.content?.tokenAddress === "string") { + tokenAddress = tokenMemory.content.tokenAddress; + } + + if(!tokenAddress) { + tokenAddress = getTokenByName(content.tokenSymbol)?.address; + } + } + + const result = validatedSchema.safeParse({ + tokenAddress: tokenAddress || ETH_ADDRESS, + walletAddress: resolvedAddress, + }); + + + // Validate transfer content + if (!result.success) { + elizaLogger.error("Invalid content for GET_BALANCE action."); + if (callback) { + callback({ + text: "Unable to process balance request. Invalid content provided.", + content: { error: "Invalid balance content" }, + }); + } + return false; + } + + let balance: bigint; + let symbol: string; + let decimals: number; + + // Query balance based on token type + if (result.data.tokenAddress === ETH_ADDRESS) { + balance = await abstractPublicClient.getBalance({ + address: resolvedAddress, + }); + symbol = "ETH"; + decimals = 18; + } else { + [balance, decimals, symbol] = await Promise.all([ + abstractPublicClient.readContract({ + address: result.data.tokenAddress, + abi: erc20Abi, + functionName: "balanceOf", + args: [resolvedAddress], + }), + abstractPublicClient.readContract({ + address: result.data.tokenAddress, + abi: erc20Abi, + functionName: "decimals", + }), + abstractPublicClient.readContract({ + address: result.data.tokenAddress, + abi: erc20Abi, + functionName: "symbol", + }), + ]); + + } + + const formattedBalance = formatUnits(balance, decimals); + + elizaLogger.success(`Balance check completed for ${resolvedAddress}`); + if (callback) { + callback({ + text: `Balance for ${resolvedAddress}: ${formattedBalance} ${symbol}`, + content: { balance: formattedBalance, symbol: symbol }, + }); + } + + return true; + } catch (error) { + elizaLogger.error("Error checking balance:", error); + if (callback) { + callback({ + text: `Error checking balance: ${error.message}`, + content: { error: error.message }, + }); + } + return false; + } + }, + + examples: [ + [ + { + user: "{{user1}}", + content: { + text: "What's my ETH balance?", + }, + }, + { + user: "{{agent}}", + content: { + text: "Let me check your ETH balance.", + action: "GET_BALANCE", + }, + }, + { + user: "{{agent}}", + content: { + text: "Your ETH balance is 1.5 ETH", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Check USDC balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", + }, + }, + { + user: "{{agent}}", + content: { + text: "I'll check the USDC balance for that address.", + action: "GET_BALANCE", + }, + }, + { + user: "{{agent}}", + content: { + text: "The USDC balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 is 100 USDC", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Check balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 with token 0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc", + }, + }, + { + user: "{{agent}}", + content: { + text: "Let me check the balance for that address.", + action: "GET_BALANCE", + }, + }, + { + user: "{{agent}}", + content: { + text: "The balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 with token 0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc is 100", + }, + }, + ], + ] as ActionExample[][], +}; diff --git a/packages/plugin-abstract/src/actions/index.ts b/packages/plugin-abstract/src/actions/index.ts index bd666517841..90317a57850 100644 --- a/packages/plugin-abstract/src/actions/index.ts +++ b/packages/plugin-abstract/src/actions/index.ts @@ -1 +1,3 @@ export * from "./transferAction"; +export * from "./getBalanceAction"; +export * from "./deployTokenAction"; diff --git a/packages/plugin-abstract/src/actions/transferAction.ts b/packages/plugin-abstract/src/actions/transferAction.ts index 95228f298fb..7fa20660c4f 100644 --- a/packages/plugin-abstract/src/actions/transferAction.ts +++ b/packages/plugin-abstract/src/actions/transferAction.ts @@ -10,36 +10,38 @@ import { elizaLogger, composeContext, generateObject, + stringToUuid, } from "@elizaos/core"; import { validateAbstractConfig } from "../environment"; import { - type Address, erc20Abi, - http, - parseEther, + formatUnits, isAddress, parseUnits, - createPublicClient, + type Hash, } from "viem"; -import { abstractTestnet, mainnet } from "viem/chains"; -import { normalize } from "viem/ens"; -import { createAbstractClient } from "@abstract-foundation/agw-client"; +import { abstractTestnet, } from "viem/chains"; +import { type AbstractClient, createAbstractClient } from "@abstract-foundation/agw-client"; import { z } from "zod"; -import { ValidateContext } from "../utils"; -import { ETH_ADDRESS, ERC20_OVERRIDE_INFO } from "../constants"; + import { ETH_ADDRESS, } from "../constants"; import { useGetAccount, useGetWalletClient } from "../hooks"; +import { resolveAddress, abstractPublicClient, getTokenByName } from "../utils/viemHelpers"; -const ethereumClient = createPublicClient({ - chain: mainnet, - transport: http(), -}); const TransferSchema = z.object({ - tokenAddress: z.string(), + tokenAddress: z.string().optional().nullable(), recipient: z.string(), amount: z.string(), useAGW: z.boolean(), + tokenSymbol: z.string().optional().nullable(), +}); + +const validatedTransferSchema = z.object({ + tokenAddress: z.string().refine(isAddress, { message: "Invalid token address" }), + recipient: z.string().refine(isAddress, { message: "Invalid recipient address" }), + amount: z.string(), + useAGW: z.boolean(), }); export interface TransferContent extends Content { @@ -47,21 +49,19 @@ export interface TransferContent extends Content { recipient: string; amount: string | number; useAGW: boolean; + tokenSymbol?: string; } const transferTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined. -Here are several frequently used addresses. Use these for the corresponding tokens: -- ETH/eth: 0x000000000000000000000000000000000000800A -- USDC/usdc: 0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc - Example response: \`\`\`json { "tokenAddress": "0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E", "recipient": "0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", "amount": "1000", - "useAGW": true + "useAGW": true, + "tokenSymbol": "USDC" } \`\`\` @@ -73,9 +73,10 @@ Given the message, extract the following information about the requested token t - Recipient wallet address - Amount to transfer - Whether to use Abstract Global Wallet aka AGW +- The symbol of the token that wants to be transferred. Between 1 to 6 characters usually. If the user did not specify "global wallet", "AGW", "agw", or "abstract global wallet" in their message, set useAGW to false, otherwise set it to true. - +s Respond with a JSON markdown block containing only the extracted values.`; export const transferAction: Action = { @@ -125,120 +126,126 @@ export const transferAction: Action = { modelClass: ModelClass.SMALL, schema: TransferSchema, }) - ).object as unknown as TransferContent; - - if (!isAddress(content.recipient, { strict: false })) { - elizaLogger.log("Resolving ENS name..."); - try { - const name = normalize(content.recipient.trim()); - const resolvedAddress = await ethereumClient.getEnsAddress({ - name, - }); + ).object as TransferContent; - if (isAddress(resolvedAddress, { strict: false })) { - elizaLogger.log(`${name} resolved to ${resolvedAddress}`); - content.recipient = resolvedAddress; - } - } catch (error) { - elizaLogger.error("Error resolving ENS name:", error); + let tokenAddress = content.tokenAddress + + + console.log("content:::", content) + + if(content.tokenSymbol) { + const tokenMemory = await runtime.messageManager.getMemoryById(stringToUuid(`${content.tokenSymbol}-${runtime.agentId}`)) + + if(typeof tokenMemory?.content?.tokenAddress === "string") { + tokenAddress = tokenMemory.content.tokenAddress + } + + if(!tokenAddress) { + tokenAddress = getTokenByName(content.tokenSymbol)?.address } } - // Validate transfer content - if (!ValidateContext.transferAction(content)) { - elizaLogger.error("Invalid content for TRANSFER_TOKEN action."); + + const resolvedRecipient = await resolveAddress(content.recipient); + + const input = { + tokenAddress: tokenAddress, + recipient: resolvedRecipient, + amount: content.amount.toString(), + useAGW: content.useAGW, + } + const result = validatedTransferSchema.safeParse(input); + + + if (!result.success) { + elizaLogger.error("Invalid content for TRANSFER_TOKEN action.", result.error.message); if (callback) { callback({ - text: "Unable to process transfer request. Invalid content provided.", - content: { error: "Invalid transfer content" }, + text: "Unable to process transfer request. Did not extract valid parameters.", + content: { error: result.error.message, ...input }, }); } return false; } + if (!resolvedRecipient) { + throw new Error("Invalid recipient address or ENS name"); + } + try { const account = useGetAccount(runtime); - let hash; - if (content.useAGW) { + + let symbol ="ETH" + let decimals = 18 + const isEthTransfer = result.data.tokenAddress === ETH_ADDRESS + const { tokenAddress, recipient, amount, useAGW } = result.data + + + if(!isEthTransfer) { +[ symbol, decimals ] = await Promise.all([ + abstractPublicClient.readContract({ + address: tokenAddress, + abi: erc20Abi, + functionName: "symbol", + }), + abstractPublicClient.readContract({ + address: tokenAddress, + abi: erc20Abi, + functionName: "decimals", + }), + ]); } + let hash: Hash + const tokenAmount = parseUnits(amount.toString(), decimals); + + if (useAGW) { const abstractClient = await createAbstractClient({ chain: abstractTestnet, signer: account, - }); + }) as AbstractClient; - // Handle AGW transfer based on token type - if ( - content.tokenAddress.toLowerCase() !== - ETH_ADDRESS.toLowerCase() - ) { - const tokenInfo = - ERC20_OVERRIDE_INFO[content.tokenAddress.toLowerCase()]; - const decimals = tokenInfo?.decimals ?? 18; - const tokenAmount = parseUnits( - content.amount.toString(), - decimals - ); - - // @ts-ignore - will fix later + if(isEthTransfer) { + hash = await abstractClient.sendTransaction({ + chain: abstractTestnet, + to: recipient, + value: tokenAmount, + kzg: undefined, + }) + } else { hash = await abstractClient.writeContract({ chain: abstractTestnet, - address: content.tokenAddress as Address, + address: tokenAddress, abi: erc20Abi, functionName: "transfer", - args: [content.recipient as Address, tokenAmount], - }); - } else { - // @ts-ignore - hash = await abstractClient.sendTransaction({ - chain: abstractTestnet, - to: content.recipient as Address, - value: parseEther(content.amount.toString()), - kzg: undefined, - }); + args: [recipient, tokenAmount], + }) } } else { const walletClient = useGetWalletClient(); - - // Handle regular wallet transfer based on token type - if ( - content.tokenAddress.toLowerCase() !== - ETH_ADDRESS.toLowerCase() - ) { - const tokenInfo = - ERC20_OVERRIDE_INFO[content.tokenAddress.toLowerCase()]; - const decimals = tokenInfo?.decimals ?? 18; - const tokenAmount = parseUnits( - content.amount.toString(), - decimals - ); - - hash = await walletClient.writeContract({ - account, - chain: abstractTestnet, - address: content.tokenAddress as Address, - abi: erc20Abi, - functionName: "transfer", - args: [content.recipient as Address, tokenAmount], - }); - } else { + if(isEthTransfer) { hash = await walletClient.sendTransaction({ account, chain: abstractTestnet, - to: content.recipient as Address, - value: parseEther(content.amount.toString()), + to: recipient, + value: tokenAmount, kzg: undefined, - }); + }) + } else { + hash = await walletClient.writeContract({ + account, + chain: abstractTestnet, + address: tokenAddress, + abi: erc20Abi, + functionName: "transfer", + args: [recipient, tokenAmount], + }) } } - elizaLogger.success( - "Transfer completed successfully! Transaction hash: " + hash - ); + elizaLogger.success(`Transfer completed successfully! Transaction hash: ${hash}`); if (callback) { callback({ - text: - "Transfer completed successfully! Transaction hash: " + - hash, - content: {}, + text: `Transfer completed successfully! Succesfully sent ${formatUnits(tokenAmount, decimals)} ${symbol} to ${recipient} using ${useAGW ? "AGW" : "wallet client"}. Transaction hash: ${hash}`, + content: { hash, tokenAmount: formatUnits(tokenAmount, decimals), symbol, recipient, useAGW }, }); } @@ -361,5 +368,26 @@ export const transferAction: Action = { }, }, ], + [ + { + user: "{{user1}}", + content: { + text: "Please send 1 MyToken to 0xbD8679cf79137042214fA4239b02F4022208EE82", + }, + }, + { + user: "{{agent}}", + content: { + text: "Of course. Sending 1 MyToken right away.", + action: "SEND_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully sent 1 MyToken to 0xbD8679cf79137042214fA4239b02F4022208EE82\nTransaction: 0x0b9f23e69ea91ba98926744472717960cc7018d35bc3165bdba6ae41670da0f0", + }, + }, + ], ] as ActionExample[][], }; diff --git a/packages/plugin-abstract/src/constants/basicToken.ts b/packages/plugin-abstract/src/constants/basicToken.ts new file mode 100644 index 00000000000..63d2645fb90 --- /dev/null +++ b/packages/plugin-abstract/src/constants/basicToken.ts @@ -0,0 +1,333 @@ +export const abi = [ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "initialSupply", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ] as const + +export const bytecode = "0x00070000000000020000008004000039000000400040043f0000006003100270000000fb0330019700000001002001900000002f0000c13d000000040030008c0000004e0000413d000000000201043b000000e002200270000001070020009c000000690000a13d000001080020009c000000b80000a13d000001090020009c0000018c0000613d0000010a0020009c000001a80000613d0000010b0020009c0000004e0000c13d000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000202043b000001130020009c0000004e0000213d0000002401100370000000000101043b000001130010009c0000004e0000213d000000000020043f000700000001001d0000000101000039000000200010043f0000004002000039000000000100001903e803c90000040f0000000702000029000000000020043f000000200010043f00000000010000190000004002000039000000c90000013d0000000002000416000000000002004b0000004e0000c13d0000001f02300039000000fc022001970000008002200039000000400020043f0000001f0530018f000000fd0630019800000080026000390000003f0000613d000000000701034f000000007807043c0000000004840436000000000024004b0000003b0000c13d000000000005004b0000004c0000613d000000000161034f0000000304500210000000000502043300000000054501cf000000000545022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000151019f0000000000120435000000600030008c000000500000813d0000000001000019000003ea00010430000000800400043d000000fe0040009c0000004e0000213d0000001f01400039000000000031004b0000000002000019000000ff02008041000000ff01100197000000000001004b0000000005000019000000ff05004041000000ff0010009c000000000502c019000000000005004b0000004e0000c13d00000080014000390000000002010433000000fe0020009c000000cb0000a13d0000010401000041000000000010043f0000004101000039000000040010043f0000010501000041000003ea000104300000010e0020009c0000007f0000213d000001110020009c000001640000613d000001120020009c0000004e0000c13d000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000302043b000001130030009c0000004e0000213d0000002401100370000000000201043b0000000001000411000000000001004b000001c60000c13d0000011901000041000001c90000013d0000010f0020009c000001840000613d000001100020009c0000004e0000c13d000000640030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000302043b000001130030009c0000004e0000213d0000002402100370000000000202043b000700000002001d000001130020009c0000004e0000213d0000004401100370000000000101043b000500000001001d000000000030043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c70000801002000039000600000003001d03e803e30000040f00000001002001900000004e0000613d000000000101043b0000000002000411000000000020043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000060500002900000001002001900000004e0000613d000000000101043b000000000301041a0000011e0030009c000002290000c13d00000000010500190000000702000029000000050300002903e8035e0000040f000002030000013d0000010c0020009c000001a10000613d0000010d0020009c0000004e0000c13d000000240030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000401100370000000000101043b000001130010009c0000004e0000213d000000000010043f000000200000043f0000004002000039000000000100001903e803c90000040f000001880000013d0000001f012000390000011f011001970000003f011000390000011f01100197000000400900043d0000000005190019000000000095004b00000000010000390000000101004039000000fe0050009c000000630000213d0000000100100190000000630000c13d0000008001300039000000400050043f000000000a290436000000a0044000390000000005420019000000000015004b0000004e0000213d000000000002004b000000e90000613d000000000500001900000000065a00190000000007450019000000000707043300000000007604350000002005500039000000000025004b000000e20000413d000000000292001900000020022000390000000000020435000000a00400043d000000fe0040009c0000004e0000213d0000001f02400039000000000032004b0000000003000019000000ff03008041000000ff02200197000000000002004b0000000005000019000000ff05004041000000ff0020009c000000000503c019000000000005004b0000004e0000c13d00000080024000390000000002020433000000fe0020009c000000630000213d0000001f032000390000011f033001970000003f033000390000011f03300197000000400600043d0000000003360019000000000063004b00000000050000390000000105004039000000fe0030009c000000630000213d0000000100500190000000630000c13d000000400030043f0000000007260436000000a0034000390000000004320019000000000014004b0000004e0000213d000000000002004b0000011c0000613d000000000100001900000000041700190000000005310019000000000505043300000000005404350000002001100039000000000021004b000001150000413d0000000001620019000000200110003900000000000104350000000004090433000000fe0040009c000000630000213d0000000303000039000000000103041a000000010210019000000001051002700000007f0550618f0000001f0050008c00000000010000390000000101002039000000000012004b0000019b0000c13d00030000000a001d000400000009001d000100000007001d000600000006001d000000c00100043d000200000001001d000500000005001d000000200050008c000700000004001d000001520000413d000000000030043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d00000007040000290000001f024000390000000502200270000000200040008c0000000002004019000000000301043b00000005010000290000001f01100039000000050110027000000000011300190000000002230019000000000012004b0000000303000039000001520000813d000000000002041b0000000102200039000000000012004b0000014e0000413d0000001f0040008c0000026e0000a13d000000000030043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f0000000100200190000000200200008a0000004e0000613d0000000702200180000000000101043b0000027b0000c13d0000002003000039000002880000013d0000000001000416000000000001004b0000004e0000c13d0000000303000039000000000203041a000000010520019000000001012002700000007f0410018f00000000010460190000001f0010008c00000000060000390000000106002039000000000662013f00000001006001900000019b0000c13d000000800010043f000000000005004b000001c00000613d000000000030043f000000020020008c000001d00000413d0000011d0200004100000000040000190000000003040019000000000402041a000000a005300039000000000045043500000001022000390000002004300039000000000014004b0000017b0000413d000002150000013d0000000001000416000000000001004b0000004e0000c13d0000000201000039000000000101041a000000800010043f0000011401000041000003e90001042e0000000001000416000000000001004b0000004e0000c13d0000000403000039000000000203041a000000010520019000000001012002700000007f0410018f00000000010460190000001f0010008c00000000060000390000000106002039000000000662013f0000000100600190000001bd0000613d0000010401000041000000000010043f0000002201000039000000040010043f0000010501000041000003ea000104300000000001000416000000000001004b0000004e0000c13d0000001201000039000000800010043f0000011401000041000003e90001042e000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000202043b000001130020009c0000004e0000213d0000002401100370000000000301043b000000000100041103e8035e0000040f0000000101000039000000400200043d0000000000120435000000fb0020009c000000fb02008041000000400120021000000115011001c7000003e90001042e000000800010043f000000000005004b000001cd0000c13d0000012001200197000000a00010043f000000000004004b000000c001000039000000a001006039000002160000013d000000000003004b000001d20000c13d0000011801000041000000800010043f000000840000043f0000011c01000041000003ea00010430000000000030043f000000020020008c0000020b0000813d00000020010000390000021a0000013d000600000002001d000000000010043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c70000801002000039000700000003001d03e803e30000040f000000070300002900000001002001900000004e0000613d000000000101043b000000000030043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000070600002900000001002001900000004e0000613d000000000101043b0000000602000029000000000021041b000000400100043d0000000000210435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000100011001c70000800d0200003900000003030000390000011b04000041000000000500041103e803de0000040f00000001002001900000004e0000613d000000400100043d00000001020000390000000000210435000000fb0010009c000000fb01008041000000400110021000000115011001c7000003e90001042e000001160200004100000000040000190000000003040019000000000402041a000000a005300039000000000045043500000001022000390000002004300039000000000014004b0000020d0000413d000000c001300039000000610110008a0000011f01100197000001170010009c000000630000213d0000008001100039000700000001001d000000400010043f000000800200003903e803410000040f00000007020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003e90001042e0000000504000029000000000143004b0000023d0000813d000000400200043d000700000002001d0000011a0100004100000000001204350000000401200039000000000200041103e803560000040f00000007020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003ea00010430000000000005004b000002420000c13d000000400100043d0000011902000041000002480000013d000400000001001d0000000001000411000000000001004b000002500000c13d000000400100043d0000011802000041000000000021043500000004021000390000000000020435000000fb0010009c000000fb01008041000000400110021000000105011001c7000003ea00010430000000000050043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d000000000101043b0000000002000411000000000020043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000060500002900000001002001900000004e0000613d000000000101043b0000000402000029000000000021041b000000b30000013d000000070000006b0000000001000019000002730000613d00000003010000290000000001010433000000070400002900000003024002100000011e0220027f0000011e02200167000000000121016f0000000102400210000000000121019f000002960000013d000000010320008a0000000503300270000000000431001900000020030000390000000104400039000000040600002900000000056300190000000005050433000000000051041b00000020033000390000000101100039000000000041004b000002810000c13d000000070020006c000002930000813d00000007020000290000000302200210000000f80220018f0000011e0220027f0000011e0220016700000004033000290000000003030433000000000223016f000000000021041b0000000701000029000000010110021000000001011001bf0000000302000039000000000012041b00000006010000290000000001010433000700000001001d000000fe0010009c000000630000213d0000000401000039000000000101041a000000010010019000000001021002700000007f0220618f000500000002001d0000001f0020008c00000000020000390000000102002039000000000121013f00000001001001900000019b0000c13d0000000501000029000000200010008c000002c80000413d0000000401000039000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d00000007030000290000001f023000390000000502200270000000200030008c0000000002004019000000000301043b00000005010000290000001f01100039000000050110027000000000011300190000000002230019000000000012004b000002c80000813d000000000002041b0000000102200039000000000012004b000002c40000413d00000007010000290000001f0010008c000002dc0000a13d0000000401000039000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f0000000100200190000000200200008a0000004e0000613d0000000702200180000000000101043b000002e90000c13d0000002003000039000002f60000013d000000070000006b0000000001000019000002e10000613d00000001010000290000000001010433000000070400002900000003024002100000011e0220027f0000011e02200167000000000121016f0000000102400210000000000121019f000003040000013d000000010320008a0000000503300270000000000431001900000020030000390000000104400039000000060600002900000000056300190000000005050433000000000051041b00000020033000390000000101100039000000000041004b000002ef0000c13d000000070020006c000003010000813d00000007020000290000000302200210000000f80220018f0000011e0220027f0000011e0220016700000006033000290000000003030433000000000223016f000000000021041b0000000701000029000000010110021000000001011001bf0000000402000039000000000012041b0000000001000411000000000001004b0000030c0000c13d000000400100043d0000010602000041000002480000013d0000000201000039000000000201041a000000020020002a0000033b0000413d0000000202200029000000000021041b0000000001000411000000000010043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d000000000101043b000000000201041a00000002030000290000000002320019000000000021041b000000400100043d0000000000310435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000121019f00000100011001c70000800d02000039000000030300003900000102040000410000000005000019000000000600041103e803de0000040f00000001002001900000004e0000613d0000002001000039000001000010044300000120000004430000010301000041000003e90001042e0000010401000041000000000010043f0000001101000039000000040010043f0000010501000041000003ea0001043000000020030000390000000004310436000000003202043400000000002404350000004001100039000000000002004b000003500000613d000000000400001900000000054100190000000006430019000000000606043300000000006504350000002004400039000000000024004b000003490000413d000000000321001900000000000304350000001f022000390000011f022001970000000001210019000000000001042d0000004005100039000000000045043500000020041000390000000000340435000001130220019700000000002104350000006001100039000000000001042d0005000000000002000500000003001d0000011303100198000003aa0000613d000100000001001d000301130020019c000003ad0000613d000400000003001d000000000030043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b000000000301041a0002000500300074000003b70000413d0000000401000029000000000010043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b0000000202000029000000000021041b0000000301000029000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b000000000201041a00000005030000290000000002320019000000000021041b000000400100043d0000000000310435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000100011001c70000800d02000039000000030300003900000102040000410000000405000029000000030600002903e803de0000040f0000000100200190000003a80000613d000000000001042d0000000001000019000003ea00010430000000400100043d0000012202000041000003af0000013d000000400100043d0000010602000041000000000021043500000004021000390000000000020435000000fb0010009c000000fb01008041000000400110021000000105011001c7000003ea00010430000000400200043d000400000002001d0000012101000041000000000012043500000004012000390000000102000029000000050400002903e803560000040f00000004020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003ea00010430000000fb0010009c000000fb010080410000004001100210000000fb0020009c000000fb020080410000006002200210000000000112019f0000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000123011001c7000080100200003903e803e30000040f0000000100200190000003dc0000613d000000000101043b000000000001042d0000000001000019000003ea00010430000003e1002104210000000102000039000000000001042d0000000002000019000000000001042d000003e6002104230000000102000039000000000001042d0000000002000019000000000001042d000003e800000432000003e90001042e000003ea00010430000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000001ffffffe000000000000000000000000000000000000000000000000000000000ffffffe0000000000000000000000000000000000000000000000000ffffffffffffffff800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000200000000000000000000000000200000000000000000000000000000000000040000000000000000000000000ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef00000002000000000000000000000000000000400000010000000000000000004e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000ec442f050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000313ce5660000000000000000000000000000000000000000000000000000000095d89b400000000000000000000000000000000000000000000000000000000095d89b4100000000000000000000000000000000000000000000000000000000a9059cbb00000000000000000000000000000000000000000000000000000000dd62ed3e00000000000000000000000000000000000000000000000000000000313ce5670000000000000000000000000000000000000000000000000000000070a082310000000000000000000000000000000000000000000000000000000018160ddc0000000000000000000000000000000000000000000000000000000018160ddd0000000000000000000000000000000000000000000000000000000023b872dd0000000000000000000000000000000000000000000000000000000006fdde0300000000000000000000000000000000000000000000000000000000095ea7b3000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000002000000080000000000000000000000000000000000000000000000000000000200000000000000000000000008a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b000000000000000000000000000000000000000000000000ffffffffffffff7f94280d6200000000000000000000000000000000000000000000000000000000e602df0500000000000000000000000000000000000000000000000000000000fb8f41b2000000000000000000000000000000000000000000000000000000008c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9250000000000000000000000000000000000000024000000800000000000000000c2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85bffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00e450d38c0000000000000000000000000000000000000000000000000000000096c6fd1e0000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001dbc83e97c797e3233d0240e131aa65294eb9b53fd276d14db99f1ca12c7fd24" diff --git a/packages/plugin-abstract/src/constants/index.ts b/packages/plugin-abstract/src/constants/index.ts index 2262889aabe..cd3b1267dc2 100644 --- a/packages/plugin-abstract/src/constants/index.ts +++ b/packages/plugin-abstract/src/constants/index.ts @@ -1,7 +1 @@ export const ETH_ADDRESS = "0x000000000000000000000000000000000000800A"; -export const ERC20_OVERRIDE_INFO = { - "0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc": { - name: "USDC", - decimals: 6, - }, -}; diff --git a/packages/plugin-abstract/src/index.ts b/packages/plugin-abstract/src/index.ts index b58043d3abe..a995b617649 100644 --- a/packages/plugin-abstract/src/index.ts +++ b/packages/plugin-abstract/src/index.ts @@ -1,11 +1,11 @@ import type { Plugin } from "@elizaos/core"; -import { transferAction } from "./actions"; +import { transferAction, getBalanceAction, deployTokenAction } from "./actions"; export const abstractPlugin: Plugin = { name: "abstract", description: "Abstract Plugin for Eliza", - actions: [transferAction], + actions: [transferAction, getBalanceAction, deployTokenAction], evaluators: [], providers: [], }; diff --git a/packages/plugin-abstract/src/utils/index.ts b/packages/plugin-abstract/src/utils/index.ts index ad34a4003af..70b70856047 100644 --- a/packages/plugin-abstract/src/utils/index.ts +++ b/packages/plugin-abstract/src/utils/index.ts @@ -1 +1 @@ -export * from "./validateContext"; +export * from "./viemHelpers"; diff --git a/packages/plugin-abstract/src/utils/validateContext.ts b/packages/plugin-abstract/src/utils/validateContext.ts deleted file mode 100644 index b024a2a0498..00000000000 --- a/packages/plugin-abstract/src/utils/validateContext.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { TransferContent } from "../actions"; -import { isAddress } from "viem"; - -export class ValidateContext { - static transferAction( - content: TransferContent - ): content is TransferContent { - const { tokenAddress, recipient, amount } = content; - - // Validate types - const areTypesValid = - typeof tokenAddress === "string" && - typeof recipient === "string" && - (typeof amount === "string" || typeof amount === "number"); - - if (!areTypesValid) { - return false; - } - - // Validate addresses - return [tokenAddress, recipient].every((address) => - isAddress(address, { strict: false }) - ); - } -} diff --git a/packages/plugin-abstract/src/utils/viemHelpers.ts b/packages/plugin-abstract/src/utils/viemHelpers.ts new file mode 100644 index 00000000000..b1d1e2c513a --- /dev/null +++ b/packages/plugin-abstract/src/utils/viemHelpers.ts @@ -0,0 +1,71 @@ +import { + type Address, + createPublicClient, + getAddress, + http, + isAddress, + type PublicClient, +} from "viem"; +import { abstractTestnet, mainnet } from "viem/chains"; +import { normalize } from "viem/ens"; +import { elizaLogger } from "@elizaos/core"; +import { ETH_ADDRESS, } from "../constants"; + +// Shared clients +export const ethereumClient = createPublicClient({ + chain: mainnet, + transport: http(), +}); + +export const abstractPublicClient = createPublicClient({ + chain: abstractTestnet, + transport: http(), +}); + + + +// Helper to resolve ENS names +export async function resolveAddress(addressOrEns: string): Promise
{ + if (isAddress(addressOrEns)) { + return getAddress(addressOrEns); + } + + let address:string + try { + const name = normalize(addressOrEns.trim()); + const resolved = await ethereumClient.getEnsAddress({ name }); + if (resolved) { + address = resolved; + elizaLogger.log(`Resolved ${name} to ${resolved}`); + + } + } catch (error) { + elizaLogger.error("Error resolving ENS name:", error); + } + + + return getAddress(address); + +} + +const tokens = [ + { + address: ETH_ADDRESS, + symbol: "ETH", + decimals: 18, + }, + { + address: "0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc", + symbol: "USDC", + decimals: 6, + } +] + + export function getTokenByName(name: string) { + + const token = tokens.find(token => token.symbol.toLowerCase() === name.toLowerCase()) + + return token +} + + From 2d1595cd5cfc976c5bfd4d19986d44f9d96ca1a9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 19 Jan 2025 21:37:10 +0100 Subject: [PATCH 2/3] format and lint code --- packages/plugin-abstract/package.json | 2 +- .../src/actions/deployTokenAction.ts | 425 ++++++----- .../src/actions/getBalanceAction.ts | 487 ++++++------ .../src/actions/transferAction.ts | 703 +++++++++--------- .../src/constants/basicToken.ts | 663 ++++++++--------- packages/plugin-abstract/src/environment.ts | 62 +- .../src/hooks/useGetAccount.ts | 7 +- .../src/hooks/useGetWalletClient.ts | 10 +- packages/plugin-abstract/src/index.ts | 10 +- .../plugin-abstract/src/utils/viemHelpers.ts | 118 +-- pnpm-lock.yaml | 311 ++------ 11 files changed, 1309 insertions(+), 1489 deletions(-) diff --git a/packages/plugin-abstract/package.json b/packages/plugin-abstract/package.json index 8bbf9e043b7..42c5f7c1bae 100644 --- a/packages/plugin-abstract/package.json +++ b/packages/plugin-abstract/package.json @@ -19,7 +19,7 @@ "dist" ], "dependencies": { - "@abstract-foundation/agw-client": "^0.1.7", + "@abstract-foundation/agw-client": "1.0.1", "@elizaos/core": "workspace:*", "tsup": "^8.3.5", "viem": "2.22.2" diff --git a/packages/plugin-abstract/src/actions/deployTokenAction.ts b/packages/plugin-abstract/src/actions/deployTokenAction.ts index daaf56af846..fc58b0dfc5d 100644 --- a/packages/plugin-abstract/src/actions/deployTokenAction.ts +++ b/packages/plugin-abstract/src/actions/deployTokenAction.ts @@ -1,48 +1,55 @@ import type { Action } from "@elizaos/core"; import { - type ActionExample, - type Content, - type HandlerCallback, - type IAgentRuntime, - type Memory, - ModelClass, - type State, - elizaLogger, - composeContext, - generateObject, - stringToUuid, + type ActionExample, + type Content, + type HandlerCallback, + type IAgentRuntime, + type Memory, + ModelClass, + type State, + elizaLogger, + composeContext, + generateObject, + stringToUuid, } from "@elizaos/core"; import { validateAbstractConfig } from "../environment"; import { parseEther, type Hash } from "viem"; import { abstractTestnet } from "viem/chains"; -import { type AbstractClient, createAbstractClient } from "@abstract-foundation/agw-client"; +import { + type AbstractClient, + createAbstractClient, +} from "@abstract-foundation/agw-client"; import { z } from "zod"; import { useGetAccount, useGetWalletClient } from "../hooks"; import { abi as basicTokenAbi, bytecode } from "../constants/basicToken"; import { abstractPublicClient } from "../utils/viemHelpers"; const DeploySchema = z.object({ - name: z.string(), - symbol: z.string(), - initialSupply: z.string(), - useAGW: z.boolean(), + name: z.string(), + symbol: z.string(), + initialSupply: z.string(), + useAGW: z.boolean(), }); const validatedSchema = z.object({ - name: z.string().min(1, "Name is required"), - symbol: z.string().min(1, "Symbol is required").max(5, "Symbol must be 5 characters or less"), - initialSupply: z.string().refine( - (val) => !Number.isNaN(Number(val)) && Number(val) > 0, - { message: "Initial supply must be a positive number" } - ), - useAGW: z.boolean(), + name: z.string().min(1, "Name is required"), + symbol: z + .string() + .min(1, "Symbol is required") + .max(5, "Symbol must be 5 characters or less"), + initialSupply: z + .string() + .refine((val) => !Number.isNaN(Number(val)) && Number(val) > 0, { + message: "Initial supply must be a positive number", + }), + useAGW: z.boolean(), }); export interface DeployContent extends Content { - name: string; - symbol: string; - initialSupply: string; - useAGW: boolean; + name: string; + symbol: string; + initialSupply: string; + useAGW: boolean; } const deployTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined. @@ -71,184 +78,190 @@ If the user did not specify "global wallet", "AGW", "agw", or "abstract global w Respond with a JSON markdown block containing only the extracted values.`; export const deployTokenAction: Action = { - name: "DEPLOY_TOKEN", - similes: [ - "CREATE_TOKEN", - "DEPLOY_NEW_TOKEN", - "CREATE_NEW_TOKEN", - "LAUNCH_TOKEN", - ], - validate: async (runtime: IAgentRuntime, message: Memory) => { - await validateAbstractConfig(runtime); - return true; - }, - description: "Deploy a new ERC20 token contract", - handler: async ( - runtime: IAgentRuntime, - message: Memory, - state: State, - _options: { [key: string]: unknown }, - callback?: HandlerCallback - ): Promise => { - elizaLogger.log("Starting Abstract DEPLOY_TOKEN handler..."); - - if (!state) { - state = (await runtime.composeState(message)) as State; - } else { - state = await runtime.updateRecentMessageState(state); - } - - state.currentMessage = `${state.recentMessagesData[1].content.text}`; - const deployContext = composeContext({ - state, - template: deployTemplate, - }); - - const content = ( - await generateObject({ - runtime, - context: deployContext, - modelClass: ModelClass.SMALL, - schema: DeploySchema, - }) - ).object as DeployContent; - - // Validate deployment content - const result = validatedSchema.safeParse(content); - if (!result.success) { - elizaLogger.error("Invalid content for DEPLOY_TOKEN action.", { - errors: result.error.errors - }); - if (callback) { - callback({ - text: "Unable to process token deployment request. Invalid parameters provided.", - content: { error: "Invalid deployment parameters" }, - }); - } - return false; - } - - - try { - const account = useGetAccount(runtime); - const supply = parseEther(content.initialSupply); - let hash: Hash; - - if (content.useAGW) { - const abstractClient = await createAbstractClient({ + name: "DEPLOY_TOKEN", + similes: [ + "CREATE_TOKEN", + "DEPLOY_NEW_TOKEN", + "CREATE_NEW_TOKEN", + "LAUNCH_TOKEN", + ], + validate: async (runtime: IAgentRuntime) => { + await validateAbstractConfig(runtime); + return true; + }, + description: "Deploy a new ERC20 token contract", + handler: async ( + runtime: IAgentRuntime, + message: Memory, + state: State, + _options: { [key: string]: unknown }, + callback?: HandlerCallback, + ): Promise => { + elizaLogger.log("Starting Abstract DEPLOY_TOKEN handler..."); + + if (!state) { + state = (await runtime.composeState(message)) as State; + } else { + state = await runtime.updateRecentMessageState(state); + } + + state.currentMessage = `${state.recentMessagesData[1].content.text}`; + const deployContext = composeContext({ + state, + template: deployTemplate, + }); + + const content = ( + await generateObject({ + runtime, + context: deployContext, + modelClass: ModelClass.SMALL, + schema: DeploySchema, + }) + ).object as DeployContent; + + // Validate deployment content + const result = validatedSchema.safeParse(content); + if (!result.success) { + elizaLogger.error("Invalid content for DEPLOY_TOKEN action.", { + errors: result.error.errors, + }); + if (callback) { + callback({ + text: "Unable to process token deployment request. Invalid parameters provided.", + content: { error: "Invalid deployment parameters" }, + }); + } + return false; + } + + try { + const account = useGetAccount(runtime); + const supply = parseEther(content.initialSupply); + let hash: Hash; + + if (content.useAGW) { + const abstractClient = (await createAbstractClient({ + chain: abstractTestnet, + signer: account, + })) as any; // type being exported as never + + hash = await abstractClient.deployContract({ + abi: basicTokenAbi, + bytecode, + args: [result.data.name, result.data.symbol, supply], + }); + } else { + const walletClient = useGetWalletClient(); + + hash = await walletClient.deployContract({ chain: abstractTestnet, - signer: account, - }) as AbstractClient; - - hash = await abstractClient.deployContract({ - abi: basicTokenAbi, - bytecode, - args: [result.data.name, result.data.symbol, supply], - }); - } else { - const walletClient = useGetWalletClient(); - - hash = await walletClient.deployContract({ - account, - abi: basicTokenAbi, - bytecode, - args: [result.data.name, result.data.symbol, supply], - }); - } - - // Wait for transaction receipt - const receipt = await abstractPublicClient.waitForTransactionReceipt({ hash }); - const contractAddress = receipt.contractAddress; - - - - - elizaLogger.success(`Token deployment completed! Contract address: ${contractAddress}. Transaction hash: ${hash}`); - if (callback) { - callback({ - text: `Token "${result.data.name}" (${result.data.symbol}) deployed successfully! Contract address: ${contractAddress} and transaction hash: ${hash}`, - content: { hash, tokenName: result.data.name, tokenSymbol: result.data.symbol, contractAddress, transactionHash: hash }, - }); - } - - - const metadata = { - tokenAddress: contractAddress, - name: result.data.name, - symbol: result.data.symbol, - initialSupply: String(result.data.initialSupply), - } - - await runtime.messageManager.createMemory({ - id: stringToUuid(`${result.data.symbol}-${runtime.agentId}`), - userId: runtime.agentId, - content: { - text: `Token deployed: ${result.data.name}, symbol: ${result.data.symbol} and contract address: ${contractAddress}`, - ...metadata, - source: "abstract_token_deployment" - }, - agentId: runtime.agentId, - roomId: stringToUuid(`tokens-${runtime.agentId}`), - createdAt: Date.now() - }); - elizaLogger.success("memory saved for token deployment", metadata) - - - return true; - } catch (error) { - elizaLogger.error("Error during token deployment:", error); - if (callback) { - callback({ - text: `Error deploying token: ${error.message}`, - content: { error: error.message }, - }); - } - return false; - } - }, - - examples: [ - [ - { - user: "{{user1}}", - content: { - text: "Deploy a new token called MyToken with symbol MTK and initial supply of 1000000", - }, - }, - { - user: "{{agent}}", - content: { - text: "I'll deploy your new token now.", - action: "DEPLOY_TOKEN", - }, - }, - { - user: "{{agent}}", - content: { - text: "Successfully deployed MyToken (MTK) with 1000000 initial supply.\nContract address: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b\nTransaction hash: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b", - }, - }, - ], - [ - { - user: "{{user1}}", - content: { - text: "Create a new token using AGW with name TestCoin, symbol TEST, and 5000 supply", - }, - }, - { - user: "{{agent}}", - content: { - text: "I'll deploy your token using the Abstract Global Wallet.", - action: "DEPLOY_TOKEN", - }, - }, - { - user: "{{agent}}", - content: { - text: "Successfully deployed TestCoin (TEST) with 5000 initial supply using AGW.\nContract address: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b\nTransaction: 0x4fed598033f0added272c3ddefd4d83a521634a738474400b27378db462a76ec", - }, - }, - ], - ] as ActionExample[][], + account, + abi: basicTokenAbi, + bytecode, + args: [result.data.name, result.data.symbol, supply], + kzg: undefined + }); + } + + // Wait for transaction receipt + const receipt = await abstractPublicClient.waitForTransactionReceipt({ + hash, + }); + const contractAddress = receipt.contractAddress; + + elizaLogger.success( + `Token deployment completed! Contract address: ${contractAddress}. Transaction hash: ${hash}`, + ); + if (callback) { + callback({ + text: `Token "${result.data.name}" (${result.data.symbol}) deployed successfully! Contract address: ${contractAddress} and transaction hash: ${hash}`, + content: { + hash, + tokenName: result.data.name, + tokenSymbol: result.data.symbol, + contractAddress, + transactionHash: hash, + }, + }); + } + + const metadata = { + tokenAddress: contractAddress, + name: result.data.name, + symbol: result.data.symbol, + initialSupply: String(result.data.initialSupply), + }; + + await runtime.messageManager.createMemory({ + id: stringToUuid(`${result.data.symbol}-${runtime.agentId}`), + userId: runtime.agentId, + content: { + text: `Token deployed: ${result.data.name}, symbol: ${result.data.symbol} and contract address: ${contractAddress}`, + ...metadata, + source: "abstract_token_deployment", + }, + agentId: runtime.agentId, + roomId: stringToUuid(`tokens-${runtime.agentId}`), + createdAt: Date.now(), + }); + elizaLogger.success("memory saved for token deployment", metadata); + + return true; + } catch (error) { + elizaLogger.error("Error during token deployment:", error); + if (callback) { + callback({ + text: `Error deploying token: ${error.message}`, + content: { error: error.message }, + }); + } + return false; + } + }, + + examples: [ + [ + { + user: "{{user1}}", + content: { + text: "Deploy a new token called MyToken with symbol MTK and initial supply of 1000000", + }, + }, + { + user: "{{agent}}", + content: { + text: "I'll deploy your new token now.", + action: "DEPLOY_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully deployed MyToken (MTK) with 1000000 initial supply.\nContract address: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b\nTransaction hash: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Create a new token using AGW with name TestCoin, symbol TEST, and 5000 supply", + }, + }, + { + user: "{{agent}}", + content: { + text: "I'll deploy your token using the Abstract Global Wallet.", + action: "DEPLOY_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully deployed TestCoin (TEST) with 5000 initial supply using AGW.\nContract address: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b\nTransaction: 0x4fed598033f0added272c3ddefd4d83a521634a738474400b27378db462a76ec", + }, + }, + ], + ] as ActionExample[][], }; diff --git a/packages/plugin-abstract/src/actions/getBalanceAction.ts b/packages/plugin-abstract/src/actions/getBalanceAction.ts index 15b50c8fb49..fe750d49f8b 100644 --- a/packages/plugin-abstract/src/actions/getBalanceAction.ts +++ b/packages/plugin-abstract/src/actions/getBalanceAction.ts @@ -1,52 +1,48 @@ import type { Action } from "@elizaos/core"; import { - type ActionExample, - type Content, - type HandlerCallback, - type IAgentRuntime, - type Memory, - ModelClass, - type State, - elizaLogger, - composeContext, - generateObject, - stringToUuid, + type ActionExample, + type Content, + type HandlerCallback, + type IAgentRuntime, + type Memory, + ModelClass, + type State, + elizaLogger, + composeContext, + generateObject, + stringToUuid, } from "@elizaos/core"; import { validateAbstractConfig } from "../environment"; -import { - - erc20Abi, - formatUnits, - isAddress, -} from "viem"; +import { erc20Abi, formatUnits, isAddress } from "viem"; import { z } from "zod"; - import { ETH_ADDRESS, } from "../constants"; -import { useGetAccount, } from "../hooks"; -import { resolveAddress, getTokenByName, abstractPublicClient } from "../utils/viemHelpers"; - - - +import { ETH_ADDRESS } from "../constants"; +import { useGetAccount } from "../hooks"; +import { + resolveAddress, + getTokenByName, + abstractPublicClient, +} from "../utils/viemHelpers"; const BalanceSchema = z.object({ - tokenAddress: z.string().optional().nullable(), - walletAddress: z.string().optional().nullable(), - tokenSymbol: z.string().optional().nullable(), + tokenAddress: z.string().optional().nullable(), + walletAddress: z.string().optional().nullable(), + tokenSymbol: z.string().optional().nullable(), }); export interface BalanceContent extends Content { - tokenAddress?: string; - walletAddress?: string; - tokenSymbol?: string; + tokenAddress?: string; + walletAddress?: string; + tokenSymbol?: string; } - - - - const validatedSchema = z.object({ - tokenAddress: z.string().refine(isAddress, { message: "Invalid token address" }), - walletAddress: z.string().refine(isAddress, { message: "Invalid token address" }), + tokenAddress: z + .string() + .refine(isAddress, { message: "Invalid token address" }), + walletAddress: z + .string() + .refine(isAddress, { message: "Invalid token address" }), }); const balanceTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined. @@ -72,216 +68,213 @@ Given the message, extract the following information about the requested balance Respond with a JSON markdown block containing only the extracted values.`; export const getBalanceAction: Action = { - name: "GET_BALANCE", - similes: [ - "CHECK_BALANCE", - "VIEW_BALANCE", - "SHOW_BALANCE", - "BALANCE_CHECK", - "TOKEN_BALANCE", - ], - validate: async (runtime: IAgentRuntime, message: Memory) => { - await validateAbstractConfig(runtime); - return true; - }, - description: "Check token balance for a given address", - handler: async ( - runtime: IAgentRuntime, - message: Memory, - state: State, - _options: { [key: string]: unknown }, - callback?: HandlerCallback - ): Promise => { - elizaLogger.log("Starting Abstract GET_BALANCE handler..."); - - // Initialize or update state - if (!state) { - state = (await runtime.composeState(message)) as State; - } else { - state = await runtime.updateRecentMessageState(state); - } - - // Compose balance context - state.currentMessage = `${state.recentMessagesData[1].content.text}`; - const balanceContext = composeContext({ - state, - template: balanceTemplate, - }); - - // Generate balance content - const content = ( - await generateObject({ - runtime, - context: balanceContext, - modelClass: ModelClass.SMALL, - schema: BalanceSchema, - }) - ).object as BalanceContent; - - - try { - const account = useGetAccount(runtime); - const addressToCheck = content.walletAddress || account.address; - - // Resolve address - const resolvedAddress = await resolveAddress(addressToCheck); - if (!resolvedAddress) { - throw new Error("Invalid address or ENS name"); - } - - let tokenAddress = content.tokenAddress; - - if(content.tokenSymbol) { - const tokenMemory = await runtime.messageManager.getMemoryById( - stringToUuid(`${content.tokenSymbol}-${runtime.agentId}`) - ); - - if(typeof tokenMemory?.content?.tokenAddress === "string") { - tokenAddress = tokenMemory.content.tokenAddress; - } - - if(!tokenAddress) { - tokenAddress = getTokenByName(content.tokenSymbol)?.address; - } - } - - const result = validatedSchema.safeParse({ - tokenAddress: tokenAddress || ETH_ADDRESS, - walletAddress: resolvedAddress, - }); - - - // Validate transfer content - if (!result.success) { - elizaLogger.error("Invalid content for GET_BALANCE action."); - if (callback) { - callback({ - text: "Unable to process balance request. Invalid content provided.", - content: { error: "Invalid balance content" }, - }); - } - return false; - } - - let balance: bigint; - let symbol: string; - let decimals: number; - - // Query balance based on token type - if (result.data.tokenAddress === ETH_ADDRESS) { - balance = await abstractPublicClient.getBalance({ - address: resolvedAddress, - }); - symbol = "ETH"; - decimals = 18; - } else { - [balance, decimals, symbol] = await Promise.all([ - abstractPublicClient.readContract({ - address: result.data.tokenAddress, - abi: erc20Abi, - functionName: "balanceOf", - args: [resolvedAddress], - }), - abstractPublicClient.readContract({ - address: result.data.tokenAddress, - abi: erc20Abi, - functionName: "decimals", - }), - abstractPublicClient.readContract({ - address: result.data.tokenAddress, - abi: erc20Abi, - functionName: "symbol", - }), - ]); - - } - - const formattedBalance = formatUnits(balance, decimals); - - elizaLogger.success(`Balance check completed for ${resolvedAddress}`); - if (callback) { - callback({ - text: `Balance for ${resolvedAddress}: ${formattedBalance} ${symbol}`, - content: { balance: formattedBalance, symbol: symbol }, - }); - } - - return true; - } catch (error) { - elizaLogger.error("Error checking balance:", error); - if (callback) { - callback({ - text: `Error checking balance: ${error.message}`, - content: { error: error.message }, - }); - } - return false; - } - }, - - examples: [ - [ - { - user: "{{user1}}", - content: { - text: "What's my ETH balance?", - }, - }, - { - user: "{{agent}}", - content: { - text: "Let me check your ETH balance.", - action: "GET_BALANCE", - }, - }, - { - user: "{{agent}}", - content: { - text: "Your ETH balance is 1.5 ETH", - }, - }, - ], - [ - { - user: "{{user1}}", - content: { - text: "Check USDC balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", - }, - }, - { - user: "{{agent}}", - content: { - text: "I'll check the USDC balance for that address.", - action: "GET_BALANCE", - }, - }, - { - user: "{{agent}}", - content: { - text: "The USDC balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 is 100 USDC", - }, - }, - ], - [ - { - user: "{{user1}}", - content: { - text: "Check balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 with token 0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc", - }, - }, - { - user: "{{agent}}", - content: { - text: "Let me check the balance for that address.", - action: "GET_BALANCE", - }, - }, - { - user: "{{agent}}", - content: { - text: "The balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 with token 0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc is 100", - }, - }, - ], - ] as ActionExample[][], + name: "GET_BALANCE", + similes: [ + "CHECK_BALANCE", + "VIEW_BALANCE", + "SHOW_BALANCE", + "BALANCE_CHECK", + "TOKEN_BALANCE", + ], + validate: async (runtime: IAgentRuntime, message: Memory) => { + await validateAbstractConfig(runtime); + return true; + }, + description: "Check token balance for a given address", + handler: async ( + runtime: IAgentRuntime, + message: Memory, + state: State, + _options: { [key: string]: unknown }, + callback?: HandlerCallback, + ): Promise => { + elizaLogger.log("Starting Abstract GET_BALANCE handler..."); + + // Initialize or update state + if (!state) { + state = (await runtime.composeState(message)) as State; + } else { + state = await runtime.updateRecentMessageState(state); + } + + // Compose balance context + state.currentMessage = `${state.recentMessagesData[1].content.text}`; + const balanceContext = composeContext({ + state, + template: balanceTemplate, + }); + + // Generate balance content + const content = ( + await generateObject({ + runtime, + context: balanceContext, + modelClass: ModelClass.SMALL, + schema: BalanceSchema, + }) + ).object as BalanceContent; + + try { + const account = useGetAccount(runtime); + const addressToCheck = content.walletAddress || account.address; + + // Resolve address + const resolvedAddress = await resolveAddress(addressToCheck); + if (!resolvedAddress) { + throw new Error("Invalid address or ENS name"); + } + + let tokenAddress = content.tokenAddress; + + if (content.tokenSymbol) { + const tokenMemory = await runtime.messageManager.getMemoryById( + stringToUuid(`${content.tokenSymbol}-${runtime.agentId}`), + ); + + if (typeof tokenMemory?.content?.tokenAddress === "string") { + tokenAddress = tokenMemory.content.tokenAddress; + } + + if (!tokenAddress) { + tokenAddress = getTokenByName(content.tokenSymbol)?.address; + } + } + + const result = validatedSchema.safeParse({ + tokenAddress: tokenAddress || ETH_ADDRESS, + walletAddress: resolvedAddress, + }); + + // Validate transfer content + if (!result.success) { + elizaLogger.error("Invalid content for GET_BALANCE action."); + if (callback) { + callback({ + text: "Unable to process balance request. Invalid content provided.", + content: { error: "Invalid balance content" }, + }); + } + return false; + } + + let balance: bigint; + let symbol: string; + let decimals: number; + + // Query balance based on token type + if (result.data.tokenAddress === ETH_ADDRESS) { + balance = await abstractPublicClient.getBalance({ + address: resolvedAddress, + }); + symbol = "ETH"; + decimals = 18; + } else { + [balance, decimals, symbol] = await Promise.all([ + abstractPublicClient.readContract({ + address: result.data.tokenAddress, + abi: erc20Abi, + functionName: "balanceOf", + args: [resolvedAddress], + }), + abstractPublicClient.readContract({ + address: result.data.tokenAddress, + abi: erc20Abi, + functionName: "decimals", + }), + abstractPublicClient.readContract({ + address: result.data.tokenAddress, + abi: erc20Abi, + functionName: "symbol", + }), + ]); + } + + const formattedBalance = formatUnits(balance, decimals); + + elizaLogger.success(`Balance check completed for ${resolvedAddress}`); + if (callback) { + callback({ + text: `Balance for ${resolvedAddress}: ${formattedBalance} ${symbol}`, + content: { balance: formattedBalance, symbol: symbol }, + }); + } + + return true; + } catch (error) { + elizaLogger.error("Error checking balance:", error); + if (callback) { + callback({ + text: `Error checking balance: ${error.message}`, + content: { error: error.message }, + }); + } + return false; + } + }, + + examples: [ + [ + { + user: "{{user1}}", + content: { + text: "What's my ETH balance?", + }, + }, + { + user: "{{agent}}", + content: { + text: "Let me check your ETH balance.", + action: "GET_BALANCE", + }, + }, + { + user: "{{agent}}", + content: { + text: "Your ETH balance is 1.5 ETH", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Check USDC balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", + }, + }, + { + user: "{{agent}}", + content: { + text: "I'll check the USDC balance for that address.", + action: "GET_BALANCE", + }, + }, + { + user: "{{agent}}", + content: { + text: "The USDC balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 is 100 USDC", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Check balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 with token 0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc", + }, + }, + { + user: "{{agent}}", + content: { + text: "Let me check the balance for that address.", + action: "GET_BALANCE", + }, + }, + { + user: "{{agent}}", + content: { + text: "The balance for 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62 with token 0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc is 100", + }, + }, + ], + ] as ActionExample[][], }; diff --git a/packages/plugin-abstract/src/actions/transferAction.ts b/packages/plugin-abstract/src/actions/transferAction.ts index 7fa20660c4f..94ef86ab131 100644 --- a/packages/plugin-abstract/src/actions/transferAction.ts +++ b/packages/plugin-abstract/src/actions/transferAction.ts @@ -1,55 +1,56 @@ import type { Action } from "@elizaos/core"; import { - type ActionExample, - type Content, - type HandlerCallback, - type IAgentRuntime, - type Memory, - ModelClass, - type State, - elizaLogger, - composeContext, - generateObject, - stringToUuid, + type ActionExample, + type Content, + type HandlerCallback, + type IAgentRuntime, + type Memory, + ModelClass, + type State, + elizaLogger, + composeContext, + generateObject, + stringToUuid, } from "@elizaos/core"; import { validateAbstractConfig } from "../environment"; -import { - erc20Abi, - formatUnits, - isAddress, - parseUnits, - type Hash, -} from "viem"; -import { abstractTestnet, } from "viem/chains"; -import { type AbstractClient, createAbstractClient } from "@abstract-foundation/agw-client"; +import { erc20Abi, formatUnits, isAddress, parseUnits, type Hash } from "viem"; +import { abstractTestnet } from "viem/chains"; +import { createAbstractClient } from "@abstract-foundation/agw-client"; import { z } from "zod"; - import { ETH_ADDRESS, } from "../constants"; +import { ETH_ADDRESS } from "../constants"; import { useGetAccount, useGetWalletClient } from "../hooks"; -import { resolveAddress, abstractPublicClient, getTokenByName } from "../utils/viemHelpers"; - +import { + resolveAddress, + abstractPublicClient, + getTokenByName, +} from "../utils/viemHelpers"; const TransferSchema = z.object({ - tokenAddress: z.string().optional().nullable(), - recipient: z.string(), - amount: z.string(), - useAGW: z.boolean(), - tokenSymbol: z.string().optional().nullable(), + tokenAddress: z.string().optional().nullable(), + recipient: z.string(), + amount: z.string(), + useAGW: z.boolean(), + tokenSymbol: z.string().optional().nullable(), }); const validatedTransferSchema = z.object({ - tokenAddress: z.string().refine(isAddress, { message: "Invalid token address" }), - recipient: z.string().refine(isAddress, { message: "Invalid recipient address" }), - amount: z.string(), - useAGW: z.boolean(), + tokenAddress: z + .string() + .refine(isAddress, { message: "Invalid token address" }), + recipient: z + .string() + .refine(isAddress, { message: "Invalid recipient address" }), + amount: z.string(), + useAGW: z.boolean(), }); export interface TransferContent extends Content { - tokenAddress: string; - recipient: string; - amount: string | number; - useAGW: boolean; - tokenSymbol?: string; + tokenAddress: string; + recipient: string; + amount: string | number; + useAGW: boolean; + tokenSymbol?: string; } const transferTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined. @@ -80,314 +81,322 @@ s Respond with a JSON markdown block containing only the extracted values.`; export const transferAction: Action = { - name: "SEND_TOKEN", - similes: [ - "TRANSFER_TOKEN_ON_ABSTRACT", - "TRANSFER_TOKENS_ON_ABSTRACT", - "SEND_TOKENS_ON_ABSTRACT", - "SEND_ETH_ON_ABSTRACT", - "PAY_ON_ABSTRACT", - "MOVE_TOKENS_ON_ABSTRACT", - "MOVE_ETH_ON_ABSTRACT", - ], - validate: async (runtime: IAgentRuntime, message: Memory) => { - await validateAbstractConfig(runtime); - return true; - }, - description: "Transfer tokens from the agent's wallet to another address", - handler: async ( - runtime: IAgentRuntime, - message: Memory, - state: State, - _options: { [key: string]: unknown }, - callback?: HandlerCallback - ): Promise => { - elizaLogger.log("Starting Abstract SEND_TOKEN handler..."); - - // Initialize or update state - if (!state) { - state = (await runtime.composeState(message)) as State; - } else { - state = await runtime.updateRecentMessageState(state); - } - - // Compose transfer context - state.currentMessage = `${state.recentMessagesData[1].content.text}`; - const transferContext = composeContext({ - state, - template: transferTemplate, - }); - - // Generate transfer content - const content = ( - await generateObject({ - runtime, - context: transferContext, - modelClass: ModelClass.SMALL, - schema: TransferSchema, - }) - ).object as TransferContent; - - let tokenAddress = content.tokenAddress - - - console.log("content:::", content) - - if(content.tokenSymbol) { - const tokenMemory = await runtime.messageManager.getMemoryById(stringToUuid(`${content.tokenSymbol}-${runtime.agentId}`)) - - if(typeof tokenMemory?.content?.tokenAddress === "string") { - tokenAddress = tokenMemory.content.tokenAddress - } - - if(!tokenAddress) { - tokenAddress = getTokenByName(content.tokenSymbol)?.address - } - } - - - const resolvedRecipient = await resolveAddress(content.recipient); - - const input = { - tokenAddress: tokenAddress, - recipient: resolvedRecipient, - amount: content.amount.toString(), - useAGW: content.useAGW, - } - const result = validatedTransferSchema.safeParse(input); - - - if (!result.success) { - elizaLogger.error("Invalid content for TRANSFER_TOKEN action.", result.error.message); - if (callback) { - callback({ - text: "Unable to process transfer request. Did not extract valid parameters.", - content: { error: result.error.message, ...input }, - }); - } - return false; - } - - if (!resolvedRecipient) { - throw new Error("Invalid recipient address or ENS name"); - } - - try { - const account = useGetAccount(runtime); - - let symbol ="ETH" - let decimals = 18 - const isEthTransfer = result.data.tokenAddress === ETH_ADDRESS - const { tokenAddress, recipient, amount, useAGW } = result.data - - - if(!isEthTransfer) { -[ symbol, decimals ] = await Promise.all([ - abstractPublicClient.readContract({ - address: tokenAddress, - abi: erc20Abi, - functionName: "symbol", - }), - abstractPublicClient.readContract({ - address: tokenAddress, - abi: erc20Abi, - functionName: "decimals", - }), - ]); } - let hash: Hash - const tokenAmount = parseUnits(amount.toString(), decimals); - - if (useAGW) { - const abstractClient = await createAbstractClient({ - chain: abstractTestnet, - signer: account, - }) as AbstractClient; - - if(isEthTransfer) { - hash = await abstractClient.sendTransaction({ - chain: abstractTestnet, - to: recipient, - value: tokenAmount, - kzg: undefined, - }) - } else { - hash = await abstractClient.writeContract({ - chain: abstractTestnet, - address: tokenAddress, - abi: erc20Abi, - functionName: "transfer", - args: [recipient, tokenAmount], - }) - } - } else { - const walletClient = useGetWalletClient(); - if(isEthTransfer) { - hash = await walletClient.sendTransaction({ - account, - chain: abstractTestnet, - to: recipient, - value: tokenAmount, - kzg: undefined, - }) - } else { - hash = await walletClient.writeContract({ - account, - chain: abstractTestnet, - address: tokenAddress, - abi: erc20Abi, - functionName: "transfer", - args: [recipient, tokenAmount], - }) - } - } - - elizaLogger.success(`Transfer completed successfully! Transaction hash: ${hash}`); - if (callback) { - callback({ - text: `Transfer completed successfully! Succesfully sent ${formatUnits(tokenAmount, decimals)} ${symbol} to ${recipient} using ${useAGW ? "AGW" : "wallet client"}. Transaction hash: ${hash}`, - content: { hash, tokenAmount: formatUnits(tokenAmount, decimals), symbol, recipient, useAGW }, - }); - } - - return true; - } catch (error) { - elizaLogger.error("Error during token transfer:", error); - if (callback) { - callback({ - text: `Error transferring tokens: ${error.message}`, - content: { error: error.message }, - }); - } - return false; - } - }, - - examples: [ - [ - { - user: "{{user1}}", - content: { - text: "Send 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4", - }, - }, - { - user: "{{agent}}", - content: { - text: "Sure, I'll send 0.01 ETH to that address now.", - action: "SEND_TOKEN", - }, - }, - { - user: "{{agent}}", - content: { - text: "Successfully sent 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4\nTransaction: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b", - }, - }, - ], - [ - { - user: "{{user1}}", - content: { - text: "Send 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4 using your abstract global wallet", - }, - }, - { - user: "{{agent}}", - content: { - text: "Sure, I'll send 0.01 ETH to that address now using my AGW.", - action: "SEND_TOKEN", - }, - }, - { - user: "{{agent}}", - content: { - text: "Successfully sent 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4\nTransaction: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b using my AGW", - }, - }, - ], - [ - { - user: "{{user1}}", - content: { - text: "Send 0.01 ETH to alim.getclave.eth", - }, - }, - { - user: "{{agent}}", - content: { - text: "Sure, I'll send 0.01 ETH to alim.getclave.eth now.", - action: "SEND_TOKEN", - }, - }, - { - user: "{{agent}}", - content: { - text: "Successfully sent 0.01 ETH to alim.getclave.eth\nTransaction: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b", - }, - }, - ], - [ - { - user: "{{user1}}", - content: { - text: "Send 100 USDC to 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", - }, - }, - { - user: "{{agent}}", - content: { - text: "Sure, I'll send 100 USDC to that address now.", - action: "SEND_TOKEN", - }, - }, - { - user: "{{agent}}", - content: { - text: "Successfully sent 100 USDC to 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62\nTransaction: 0x4fed598033f0added272c3ddefd4d83a521634a738474400b27378db462a76ec", - }, - }, - ], - [ - { - user: "{{user1}}", - content: { - text: "Please send 0.1 ETH to 0xbD8679cf79137042214fA4239b02F4022208EE82", - }, - }, - { - user: "{{agent}}", - content: { - text: "Of course. Sending 0.1 ETH to that address now.", - action: "SEND_TOKEN", - }, - }, - { - user: "{{agent}}", - content: { - text: "Successfully sent 0.1 ETH to 0xbD8679cf79137042214fA4239b02F4022208EE82\nTransaction: 0x0b9f23e69ea91ba98926744472717960cc7018d35bc3165bdba6ae41670da0f0", - }, - }, - ], - [ - { - user: "{{user1}}", - content: { - text: "Please send 1 MyToken to 0xbD8679cf79137042214fA4239b02F4022208EE82", - }, - }, - { - user: "{{agent}}", - content: { - text: "Of course. Sending 1 MyToken right away.", - action: "SEND_TOKEN", - }, - }, - { - user: "{{agent}}", - content: { - text: "Successfully sent 1 MyToken to 0xbD8679cf79137042214fA4239b02F4022208EE82\nTransaction: 0x0b9f23e69ea91ba98926744472717960cc7018d35bc3165bdba6ae41670da0f0", - }, - }, - ], - ] as ActionExample[][], + name: "SEND_TOKEN", + similes: [ + "TRANSFER_TOKEN_ON_ABSTRACT", + "TRANSFER_TOKENS_ON_ABSTRACT", + "SEND_TOKENS_ON_ABSTRACT", + "SEND_ETH_ON_ABSTRACT", + "PAY_ON_ABSTRACT", + "MOVE_TOKENS_ON_ABSTRACT", + "MOVE_ETH_ON_ABSTRACT", + ], + validate: async (runtime: IAgentRuntime) => { + await validateAbstractConfig(runtime); + return true; + }, + description: "Transfer tokens from the agent's wallet to another address", + handler: async ( + runtime: IAgentRuntime, + message: Memory, + state: State, + _options: { [key: string]: unknown }, + callback?: HandlerCallback, + ): Promise => { + elizaLogger.log("Starting Abstract SEND_TOKEN handler..."); + + // Initialize or update state + if (!state) { + state = (await runtime.composeState(message)) as State; + } else { + state = await runtime.updateRecentMessageState(state); + } + + // Compose transfer context + state.currentMessage = `${state.recentMessagesData[1].content.text}`; + const transferContext = composeContext({ + state, + template: transferTemplate, + }); + + // Generate transfer content + const content = ( + await generateObject({ + runtime, + context: transferContext, + modelClass: ModelClass.SMALL, + schema: TransferSchema, + }) + ).object as TransferContent; + + let tokenAddress = content.tokenAddress; + + if (content.tokenSymbol) { + const tokenMemory = await runtime.messageManager.getMemoryById( + stringToUuid(`${content.tokenSymbol}-${runtime.agentId}`), + ); + + if (typeof tokenMemory?.content?.tokenAddress === "string") { + tokenAddress = tokenMemory.content.tokenAddress; + } + + if (!tokenAddress) { + tokenAddress = getTokenByName(content.tokenSymbol)?.address; + } + } + + const resolvedRecipient = await resolveAddress(content.recipient); + + const input = { + tokenAddress: tokenAddress, + recipient: resolvedRecipient, + amount: content.amount.toString(), + useAGW: content.useAGW, + }; + const result = validatedTransferSchema.safeParse(input); + + if (!result.success) { + elizaLogger.error( + "Invalid content for TRANSFER_TOKEN action.", + result.error.message, + ); + if (callback) { + callback({ + text: "Unable to process transfer request. Did not extract valid parameters.", + content: { error: result.error.message, ...input }, + }); + } + return false; + } + + if (!resolvedRecipient) { + throw new Error("Invalid recipient address or ENS name"); + } + + try { + const account = useGetAccount(runtime); + + let symbol = "ETH"; + let decimals = 18; + const isEthTransfer = result.data.tokenAddress === ETH_ADDRESS; + const { tokenAddress, recipient, amount, useAGW } = result.data; + + if (!isEthTransfer) { + [symbol, decimals] = await Promise.all([ + abstractPublicClient.readContract({ + address: tokenAddress, + abi: erc20Abi, + functionName: "symbol", + }), + abstractPublicClient.readContract({ + address: tokenAddress, + abi: erc20Abi, + functionName: "decimals", + }), + ]); + } + let hash: Hash; + const tokenAmount = parseUnits(amount.toString(), decimals); + + if (useAGW) { + const abstractClient = await createAbstractClient({ + chain: abstractTestnet, + signer: account, + }) as any; // biome-ignore lint/suspicious/noExplicitAny: type being exported as never + + if (isEthTransfer) { + hash = await abstractClient.sendTransaction({ + chain: abstractTestnet, + to: recipient, + value: tokenAmount, + kzg: undefined, + }); + } else { + hash = await abstractClient.writeContract({ + chain: abstractTestnet, + address: tokenAddress, + abi: erc20Abi, + functionName: "transfer", + args: [recipient, tokenAmount], + }); + } + } else { + const walletClient = useGetWalletClient(); + if (isEthTransfer) { + hash = await walletClient.sendTransaction({ + account, + chain: abstractTestnet, + to: recipient, + value: tokenAmount, + kzg: undefined, + }); + } else { + hash = await walletClient.writeContract({ + account, + chain: abstractTestnet, + address: tokenAddress, + abi: erc20Abi, + functionName: "transfer", + args: [recipient, tokenAmount], + }); + } + } + + elizaLogger.success( + `Transfer completed successfully! Transaction hash: ${hash}`, + ); + if (callback) { + callback({ + text: `Transfer completed successfully! Succesfully sent ${formatUnits(tokenAmount, decimals)} ${symbol} to ${recipient} using ${useAGW ? "AGW" : "wallet client"}. Transaction hash: ${hash}`, + content: { + hash, + tokenAmount: formatUnits(tokenAmount, decimals), + symbol, + recipient, + useAGW, + }, + }); + } + + return true; + } catch (error) { + elizaLogger.error("Error during token transfer:", error); + if (callback) { + callback({ + text: `Error transferring tokens: ${error.message}`, + content: { error: error.message }, + }); + } + return false; + } + }, + + examples: [ + [ + { + user: "{{user1}}", + content: { + text: "Send 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4", + }, + }, + { + user: "{{agent}}", + content: { + text: "Sure, I'll send 0.01 ETH to that address now.", + action: "SEND_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully sent 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4\nTransaction: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Send 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4 using your abstract global wallet", + }, + }, + { + user: "{{agent}}", + content: { + text: "Sure, I'll send 0.01 ETH to that address now using my AGW.", + action: "SEND_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully sent 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4\nTransaction: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b using my AGW", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Send 0.01 ETH to alim.getclave.eth", + }, + }, + { + user: "{{agent}}", + content: { + text: "Sure, I'll send 0.01 ETH to alim.getclave.eth now.", + action: "SEND_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully sent 0.01 ETH to alim.getclave.eth\nTransaction: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Send 100 USDC to 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", + }, + }, + { + user: "{{agent}}", + content: { + text: "Sure, I'll send 100 USDC to that address now.", + action: "SEND_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully sent 100 USDC to 0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62\nTransaction: 0x4fed598033f0added272c3ddefd4d83a521634a738474400b27378db462a76ec", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Please send 0.1 ETH to 0xbD8679cf79137042214fA4239b02F4022208EE82", + }, + }, + { + user: "{{agent}}", + content: { + text: "Of course. Sending 0.1 ETH to that address now.", + action: "SEND_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully sent 0.1 ETH to 0xbD8679cf79137042214fA4239b02F4022208EE82\nTransaction: 0x0b9f23e69ea91ba98926744472717960cc7018d35bc3165bdba6ae41670da0f0", + }, + }, + ], + [ + { + user: "{{user1}}", + content: { + text: "Please send 1 MyToken to 0xbD8679cf79137042214fA4239b02F4022208EE82", + }, + }, + { + user: "{{agent}}", + content: { + text: "Of course. Sending 1 MyToken right away.", + action: "SEND_TOKEN", + }, + }, + { + user: "{{agent}}", + content: { + text: "Successfully sent 1 MyToken to 0xbD8679cf79137042214fA4239b02F4022208EE82\nTransaction: 0x0b9f23e69ea91ba98926744472717960cc7018d35bc3165bdba6ae41670da0f0", + }, + }, + ], + ] as ActionExample[][], }; diff --git a/packages/plugin-abstract/src/constants/basicToken.ts b/packages/plugin-abstract/src/constants/basicToken.ts index 63d2645fb90..6ee93bce78c 100644 --- a/packages/plugin-abstract/src/constants/basicToken.ts +++ b/packages/plugin-abstract/src/constants/basicToken.ts @@ -1,333 +1,334 @@ export const abi = [ - { - "inputs": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "internalType": "uint256", - "name": "initialSupply", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "allowance", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "needed", - "type": "uint256" - } - ], - "name": "ERC20InsufficientAllowance", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "needed", - "type": "uint256" - } - ], - "name": "ERC20InsufficientBalance", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "approver", - "type": "address" - } - ], - "name": "ERC20InvalidApprover", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "receiver", - "type": "address" - } - ], - "name": "ERC20InvalidReceiver", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "ERC20InvalidSender", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "ERC20InvalidSpender", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ] as const + { + inputs: [ + { + internalType: "string", + name: "name", + type: "string", + }, + { + internalType: "string", + name: "symbol", + type: "string", + }, + { + internalType: "uint256", + name: "initialSupply", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "allowance", + type: "uint256", + }, + { + internalType: "uint256", + name: "needed", + type: "uint256", + }, + ], + name: "ERC20InsufficientAllowance", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "balance", + type: "uint256", + }, + { + internalType: "uint256", + name: "needed", + type: "uint256", + }, + ], + name: "ERC20InsufficientBalance", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address", + }, + ], + name: "ERC20InvalidApprover", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address", + }, + ], + name: "ERC20InvalidReceiver", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "ERC20InvalidSender", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + ], + name: "ERC20InvalidSpender", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Approval", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "address", + name: "spender", + type: "address", + }, + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, +] as const; -export const bytecode = "0x00070000000000020000008004000039000000400040043f0000006003100270000000fb0330019700000001002001900000002f0000c13d000000040030008c0000004e0000413d000000000201043b000000e002200270000001070020009c000000690000a13d000001080020009c000000b80000a13d000001090020009c0000018c0000613d0000010a0020009c000001a80000613d0000010b0020009c0000004e0000c13d000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000202043b000001130020009c0000004e0000213d0000002401100370000000000101043b000001130010009c0000004e0000213d000000000020043f000700000001001d0000000101000039000000200010043f0000004002000039000000000100001903e803c90000040f0000000702000029000000000020043f000000200010043f00000000010000190000004002000039000000c90000013d0000000002000416000000000002004b0000004e0000c13d0000001f02300039000000fc022001970000008002200039000000400020043f0000001f0530018f000000fd0630019800000080026000390000003f0000613d000000000701034f000000007807043c0000000004840436000000000024004b0000003b0000c13d000000000005004b0000004c0000613d000000000161034f0000000304500210000000000502043300000000054501cf000000000545022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000151019f0000000000120435000000600030008c000000500000813d0000000001000019000003ea00010430000000800400043d000000fe0040009c0000004e0000213d0000001f01400039000000000031004b0000000002000019000000ff02008041000000ff01100197000000000001004b0000000005000019000000ff05004041000000ff0010009c000000000502c019000000000005004b0000004e0000c13d00000080014000390000000002010433000000fe0020009c000000cb0000a13d0000010401000041000000000010043f0000004101000039000000040010043f0000010501000041000003ea000104300000010e0020009c0000007f0000213d000001110020009c000001640000613d000001120020009c0000004e0000c13d000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000302043b000001130030009c0000004e0000213d0000002401100370000000000201043b0000000001000411000000000001004b000001c60000c13d0000011901000041000001c90000013d0000010f0020009c000001840000613d000001100020009c0000004e0000c13d000000640030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000302043b000001130030009c0000004e0000213d0000002402100370000000000202043b000700000002001d000001130020009c0000004e0000213d0000004401100370000000000101043b000500000001001d000000000030043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c70000801002000039000600000003001d03e803e30000040f00000001002001900000004e0000613d000000000101043b0000000002000411000000000020043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000060500002900000001002001900000004e0000613d000000000101043b000000000301041a0000011e0030009c000002290000c13d00000000010500190000000702000029000000050300002903e8035e0000040f000002030000013d0000010c0020009c000001a10000613d0000010d0020009c0000004e0000c13d000000240030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000401100370000000000101043b000001130010009c0000004e0000213d000000000010043f000000200000043f0000004002000039000000000100001903e803c90000040f000001880000013d0000001f012000390000011f011001970000003f011000390000011f01100197000000400900043d0000000005190019000000000095004b00000000010000390000000101004039000000fe0050009c000000630000213d0000000100100190000000630000c13d0000008001300039000000400050043f000000000a290436000000a0044000390000000005420019000000000015004b0000004e0000213d000000000002004b000000e90000613d000000000500001900000000065a00190000000007450019000000000707043300000000007604350000002005500039000000000025004b000000e20000413d000000000292001900000020022000390000000000020435000000a00400043d000000fe0040009c0000004e0000213d0000001f02400039000000000032004b0000000003000019000000ff03008041000000ff02200197000000000002004b0000000005000019000000ff05004041000000ff0020009c000000000503c019000000000005004b0000004e0000c13d00000080024000390000000002020433000000fe0020009c000000630000213d0000001f032000390000011f033001970000003f033000390000011f03300197000000400600043d0000000003360019000000000063004b00000000050000390000000105004039000000fe0030009c000000630000213d0000000100500190000000630000c13d000000400030043f0000000007260436000000a0034000390000000004320019000000000014004b0000004e0000213d000000000002004b0000011c0000613d000000000100001900000000041700190000000005310019000000000505043300000000005404350000002001100039000000000021004b000001150000413d0000000001620019000000200110003900000000000104350000000004090433000000fe0040009c000000630000213d0000000303000039000000000103041a000000010210019000000001051002700000007f0550618f0000001f0050008c00000000010000390000000101002039000000000012004b0000019b0000c13d00030000000a001d000400000009001d000100000007001d000600000006001d000000c00100043d000200000001001d000500000005001d000000200050008c000700000004001d000001520000413d000000000030043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d00000007040000290000001f024000390000000502200270000000200040008c0000000002004019000000000301043b00000005010000290000001f01100039000000050110027000000000011300190000000002230019000000000012004b0000000303000039000001520000813d000000000002041b0000000102200039000000000012004b0000014e0000413d0000001f0040008c0000026e0000a13d000000000030043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f0000000100200190000000200200008a0000004e0000613d0000000702200180000000000101043b0000027b0000c13d0000002003000039000002880000013d0000000001000416000000000001004b0000004e0000c13d0000000303000039000000000203041a000000010520019000000001012002700000007f0410018f00000000010460190000001f0010008c00000000060000390000000106002039000000000662013f00000001006001900000019b0000c13d000000800010043f000000000005004b000001c00000613d000000000030043f000000020020008c000001d00000413d0000011d0200004100000000040000190000000003040019000000000402041a000000a005300039000000000045043500000001022000390000002004300039000000000014004b0000017b0000413d000002150000013d0000000001000416000000000001004b0000004e0000c13d0000000201000039000000000101041a000000800010043f0000011401000041000003e90001042e0000000001000416000000000001004b0000004e0000c13d0000000403000039000000000203041a000000010520019000000001012002700000007f0410018f00000000010460190000001f0010008c00000000060000390000000106002039000000000662013f0000000100600190000001bd0000613d0000010401000041000000000010043f0000002201000039000000040010043f0000010501000041000003ea000104300000000001000416000000000001004b0000004e0000c13d0000001201000039000000800010043f0000011401000041000003e90001042e000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000202043b000001130020009c0000004e0000213d0000002401100370000000000301043b000000000100041103e8035e0000040f0000000101000039000000400200043d0000000000120435000000fb0020009c000000fb02008041000000400120021000000115011001c7000003e90001042e000000800010043f000000000005004b000001cd0000c13d0000012001200197000000a00010043f000000000004004b000000c001000039000000a001006039000002160000013d000000000003004b000001d20000c13d0000011801000041000000800010043f000000840000043f0000011c01000041000003ea00010430000000000030043f000000020020008c0000020b0000813d00000020010000390000021a0000013d000600000002001d000000000010043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c70000801002000039000700000003001d03e803e30000040f000000070300002900000001002001900000004e0000613d000000000101043b000000000030043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000070600002900000001002001900000004e0000613d000000000101043b0000000602000029000000000021041b000000400100043d0000000000210435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000100011001c70000800d0200003900000003030000390000011b04000041000000000500041103e803de0000040f00000001002001900000004e0000613d000000400100043d00000001020000390000000000210435000000fb0010009c000000fb01008041000000400110021000000115011001c7000003e90001042e000001160200004100000000040000190000000003040019000000000402041a000000a005300039000000000045043500000001022000390000002004300039000000000014004b0000020d0000413d000000c001300039000000610110008a0000011f01100197000001170010009c000000630000213d0000008001100039000700000001001d000000400010043f000000800200003903e803410000040f00000007020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003e90001042e0000000504000029000000000143004b0000023d0000813d000000400200043d000700000002001d0000011a0100004100000000001204350000000401200039000000000200041103e803560000040f00000007020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003ea00010430000000000005004b000002420000c13d000000400100043d0000011902000041000002480000013d000400000001001d0000000001000411000000000001004b000002500000c13d000000400100043d0000011802000041000000000021043500000004021000390000000000020435000000fb0010009c000000fb01008041000000400110021000000105011001c7000003ea00010430000000000050043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d000000000101043b0000000002000411000000000020043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000060500002900000001002001900000004e0000613d000000000101043b0000000402000029000000000021041b000000b30000013d000000070000006b0000000001000019000002730000613d00000003010000290000000001010433000000070400002900000003024002100000011e0220027f0000011e02200167000000000121016f0000000102400210000000000121019f000002960000013d000000010320008a0000000503300270000000000431001900000020030000390000000104400039000000040600002900000000056300190000000005050433000000000051041b00000020033000390000000101100039000000000041004b000002810000c13d000000070020006c000002930000813d00000007020000290000000302200210000000f80220018f0000011e0220027f0000011e0220016700000004033000290000000003030433000000000223016f000000000021041b0000000701000029000000010110021000000001011001bf0000000302000039000000000012041b00000006010000290000000001010433000700000001001d000000fe0010009c000000630000213d0000000401000039000000000101041a000000010010019000000001021002700000007f0220618f000500000002001d0000001f0020008c00000000020000390000000102002039000000000121013f00000001001001900000019b0000c13d0000000501000029000000200010008c000002c80000413d0000000401000039000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d00000007030000290000001f023000390000000502200270000000200030008c0000000002004019000000000301043b00000005010000290000001f01100039000000050110027000000000011300190000000002230019000000000012004b000002c80000813d000000000002041b0000000102200039000000000012004b000002c40000413d00000007010000290000001f0010008c000002dc0000a13d0000000401000039000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f0000000100200190000000200200008a0000004e0000613d0000000702200180000000000101043b000002e90000c13d0000002003000039000002f60000013d000000070000006b0000000001000019000002e10000613d00000001010000290000000001010433000000070400002900000003024002100000011e0220027f0000011e02200167000000000121016f0000000102400210000000000121019f000003040000013d000000010320008a0000000503300270000000000431001900000020030000390000000104400039000000060600002900000000056300190000000005050433000000000051041b00000020033000390000000101100039000000000041004b000002ef0000c13d000000070020006c000003010000813d00000007020000290000000302200210000000f80220018f0000011e0220027f0000011e0220016700000006033000290000000003030433000000000223016f000000000021041b0000000701000029000000010110021000000001011001bf0000000402000039000000000012041b0000000001000411000000000001004b0000030c0000c13d000000400100043d0000010602000041000002480000013d0000000201000039000000000201041a000000020020002a0000033b0000413d0000000202200029000000000021041b0000000001000411000000000010043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d000000000101043b000000000201041a00000002030000290000000002320019000000000021041b000000400100043d0000000000310435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000121019f00000100011001c70000800d02000039000000030300003900000102040000410000000005000019000000000600041103e803de0000040f00000001002001900000004e0000613d0000002001000039000001000010044300000120000004430000010301000041000003e90001042e0000010401000041000000000010043f0000001101000039000000040010043f0000010501000041000003ea0001043000000020030000390000000004310436000000003202043400000000002404350000004001100039000000000002004b000003500000613d000000000400001900000000054100190000000006430019000000000606043300000000006504350000002004400039000000000024004b000003490000413d000000000321001900000000000304350000001f022000390000011f022001970000000001210019000000000001042d0000004005100039000000000045043500000020041000390000000000340435000001130220019700000000002104350000006001100039000000000001042d0005000000000002000500000003001d0000011303100198000003aa0000613d000100000001001d000301130020019c000003ad0000613d000400000003001d000000000030043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b000000000301041a0002000500300074000003b70000413d0000000401000029000000000010043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b0000000202000029000000000021041b0000000301000029000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b000000000201041a00000005030000290000000002320019000000000021041b000000400100043d0000000000310435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000100011001c70000800d02000039000000030300003900000102040000410000000405000029000000030600002903e803de0000040f0000000100200190000003a80000613d000000000001042d0000000001000019000003ea00010430000000400100043d0000012202000041000003af0000013d000000400100043d0000010602000041000000000021043500000004021000390000000000020435000000fb0010009c000000fb01008041000000400110021000000105011001c7000003ea00010430000000400200043d000400000002001d0000012101000041000000000012043500000004012000390000000102000029000000050400002903e803560000040f00000004020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003ea00010430000000fb0010009c000000fb010080410000004001100210000000fb0020009c000000fb020080410000006002200210000000000112019f0000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000123011001c7000080100200003903e803e30000040f0000000100200190000003dc0000613d000000000101043b000000000001042d0000000001000019000003ea00010430000003e1002104210000000102000039000000000001042d0000000002000019000000000001042d000003e6002104230000000102000039000000000001042d0000000002000019000000000001042d000003e800000432000003e90001042e000003ea00010430000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000001ffffffe000000000000000000000000000000000000000000000000000000000ffffffe0000000000000000000000000000000000000000000000000ffffffffffffffff800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000200000000000000000000000000200000000000000000000000000000000000040000000000000000000000000ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef00000002000000000000000000000000000000400000010000000000000000004e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000ec442f050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000313ce5660000000000000000000000000000000000000000000000000000000095d89b400000000000000000000000000000000000000000000000000000000095d89b4100000000000000000000000000000000000000000000000000000000a9059cbb00000000000000000000000000000000000000000000000000000000dd62ed3e00000000000000000000000000000000000000000000000000000000313ce5670000000000000000000000000000000000000000000000000000000070a082310000000000000000000000000000000000000000000000000000000018160ddc0000000000000000000000000000000000000000000000000000000018160ddd0000000000000000000000000000000000000000000000000000000023b872dd0000000000000000000000000000000000000000000000000000000006fdde0300000000000000000000000000000000000000000000000000000000095ea7b3000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000002000000080000000000000000000000000000000000000000000000000000000200000000000000000000000008a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b000000000000000000000000000000000000000000000000ffffffffffffff7f94280d6200000000000000000000000000000000000000000000000000000000e602df0500000000000000000000000000000000000000000000000000000000fb8f41b2000000000000000000000000000000000000000000000000000000008c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9250000000000000000000000000000000000000024000000800000000000000000c2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85bffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00e450d38c0000000000000000000000000000000000000000000000000000000096c6fd1e0000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001dbc83e97c797e3233d0240e131aa65294eb9b53fd276d14db99f1ca12c7fd24" +export const bytecode = + "0x00070000000000020000008004000039000000400040043f0000006003100270000000fb0330019700000001002001900000002f0000c13d000000040030008c0000004e0000413d000000000201043b000000e002200270000001070020009c000000690000a13d000001080020009c000000b80000a13d000001090020009c0000018c0000613d0000010a0020009c000001a80000613d0000010b0020009c0000004e0000c13d000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000202043b000001130020009c0000004e0000213d0000002401100370000000000101043b000001130010009c0000004e0000213d000000000020043f000700000001001d0000000101000039000000200010043f0000004002000039000000000100001903e803c90000040f0000000702000029000000000020043f000000200010043f00000000010000190000004002000039000000c90000013d0000000002000416000000000002004b0000004e0000c13d0000001f02300039000000fc022001970000008002200039000000400020043f0000001f0530018f000000fd0630019800000080026000390000003f0000613d000000000701034f000000007807043c0000000004840436000000000024004b0000003b0000c13d000000000005004b0000004c0000613d000000000161034f0000000304500210000000000502043300000000054501cf000000000545022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000151019f0000000000120435000000600030008c000000500000813d0000000001000019000003ea00010430000000800400043d000000fe0040009c0000004e0000213d0000001f01400039000000000031004b0000000002000019000000ff02008041000000ff01100197000000000001004b0000000005000019000000ff05004041000000ff0010009c000000000502c019000000000005004b0000004e0000c13d00000080014000390000000002010433000000fe0020009c000000cb0000a13d0000010401000041000000000010043f0000004101000039000000040010043f0000010501000041000003ea000104300000010e0020009c0000007f0000213d000001110020009c000001640000613d000001120020009c0000004e0000c13d000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000302043b000001130030009c0000004e0000213d0000002401100370000000000201043b0000000001000411000000000001004b000001c60000c13d0000011901000041000001c90000013d0000010f0020009c000001840000613d000001100020009c0000004e0000c13d000000640030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000302043b000001130030009c0000004e0000213d0000002402100370000000000202043b000700000002001d000001130020009c0000004e0000213d0000004401100370000000000101043b000500000001001d000000000030043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c70000801002000039000600000003001d03e803e30000040f00000001002001900000004e0000613d000000000101043b0000000002000411000000000020043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000060500002900000001002001900000004e0000613d000000000101043b000000000301041a0000011e0030009c000002290000c13d00000000010500190000000702000029000000050300002903e8035e0000040f000002030000013d0000010c0020009c000001a10000613d0000010d0020009c0000004e0000c13d000000240030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000401100370000000000101043b000001130010009c0000004e0000213d000000000010043f000000200000043f0000004002000039000000000100001903e803c90000040f000001880000013d0000001f012000390000011f011001970000003f011000390000011f01100197000000400900043d0000000005190019000000000095004b00000000010000390000000101004039000000fe0050009c000000630000213d0000000100100190000000630000c13d0000008001300039000000400050043f000000000a290436000000a0044000390000000005420019000000000015004b0000004e0000213d000000000002004b000000e90000613d000000000500001900000000065a00190000000007450019000000000707043300000000007604350000002005500039000000000025004b000000e20000413d000000000292001900000020022000390000000000020435000000a00400043d000000fe0040009c0000004e0000213d0000001f02400039000000000032004b0000000003000019000000ff03008041000000ff02200197000000000002004b0000000005000019000000ff05004041000000ff0020009c000000000503c019000000000005004b0000004e0000c13d00000080024000390000000002020433000000fe0020009c000000630000213d0000001f032000390000011f033001970000003f033000390000011f03300197000000400600043d0000000003360019000000000063004b00000000050000390000000105004039000000fe0030009c000000630000213d0000000100500190000000630000c13d000000400030043f0000000007260436000000a0034000390000000004320019000000000014004b0000004e0000213d000000000002004b0000011c0000613d000000000100001900000000041700190000000005310019000000000505043300000000005404350000002001100039000000000021004b000001150000413d0000000001620019000000200110003900000000000104350000000004090433000000fe0040009c000000630000213d0000000303000039000000000103041a000000010210019000000001051002700000007f0550618f0000001f0050008c00000000010000390000000101002039000000000012004b0000019b0000c13d00030000000a001d000400000009001d000100000007001d000600000006001d000000c00100043d000200000001001d000500000005001d000000200050008c000700000004001d000001520000413d000000000030043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d00000007040000290000001f024000390000000502200270000000200040008c0000000002004019000000000301043b00000005010000290000001f01100039000000050110027000000000011300190000000002230019000000000012004b0000000303000039000001520000813d000000000002041b0000000102200039000000000012004b0000014e0000413d0000001f0040008c0000026e0000a13d000000000030043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f0000000100200190000000200200008a0000004e0000613d0000000702200180000000000101043b0000027b0000c13d0000002003000039000002880000013d0000000001000416000000000001004b0000004e0000c13d0000000303000039000000000203041a000000010520019000000001012002700000007f0410018f00000000010460190000001f0010008c00000000060000390000000106002039000000000662013f00000001006001900000019b0000c13d000000800010043f000000000005004b000001c00000613d000000000030043f000000020020008c000001d00000413d0000011d0200004100000000040000190000000003040019000000000402041a000000a005300039000000000045043500000001022000390000002004300039000000000014004b0000017b0000413d000002150000013d0000000001000416000000000001004b0000004e0000c13d0000000201000039000000000101041a000000800010043f0000011401000041000003e90001042e0000000001000416000000000001004b0000004e0000c13d0000000403000039000000000203041a000000010520019000000001012002700000007f0410018f00000000010460190000001f0010008c00000000060000390000000106002039000000000662013f0000000100600190000001bd0000613d0000010401000041000000000010043f0000002201000039000000040010043f0000010501000041000003ea000104300000000001000416000000000001004b0000004e0000c13d0000001201000039000000800010043f0000011401000041000003e90001042e000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000202043b000001130020009c0000004e0000213d0000002401100370000000000301043b000000000100041103e8035e0000040f0000000101000039000000400200043d0000000000120435000000fb0020009c000000fb02008041000000400120021000000115011001c7000003e90001042e000000800010043f000000000005004b000001cd0000c13d0000012001200197000000a00010043f000000000004004b000000c001000039000000a001006039000002160000013d000000000003004b000001d20000c13d0000011801000041000000800010043f000000840000043f0000011c01000041000003ea00010430000000000030043f000000020020008c0000020b0000813d00000020010000390000021a0000013d000600000002001d000000000010043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c70000801002000039000700000003001d03e803e30000040f000000070300002900000001002001900000004e0000613d000000000101043b000000000030043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000070600002900000001002001900000004e0000613d000000000101043b0000000602000029000000000021041b000000400100043d0000000000210435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000100011001c70000800d0200003900000003030000390000011b04000041000000000500041103e803de0000040f00000001002001900000004e0000613d000000400100043d00000001020000390000000000210435000000fb0010009c000000fb01008041000000400110021000000115011001c7000003e90001042e000001160200004100000000040000190000000003040019000000000402041a000000a005300039000000000045043500000001022000390000002004300039000000000014004b0000020d0000413d000000c001300039000000610110008a0000011f01100197000001170010009c000000630000213d0000008001100039000700000001001d000000400010043f000000800200003903e803410000040f00000007020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003e90001042e0000000504000029000000000143004b0000023d0000813d000000400200043d000700000002001d0000011a0100004100000000001204350000000401200039000000000200041103e803560000040f00000007020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003ea00010430000000000005004b000002420000c13d000000400100043d0000011902000041000002480000013d000400000001001d0000000001000411000000000001004b000002500000c13d000000400100043d0000011802000041000000000021043500000004021000390000000000020435000000fb0010009c000000fb01008041000000400110021000000105011001c7000003ea00010430000000000050043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d000000000101043b0000000002000411000000000020043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000060500002900000001002001900000004e0000613d000000000101043b0000000402000029000000000021041b000000b30000013d000000070000006b0000000001000019000002730000613d00000003010000290000000001010433000000070400002900000003024002100000011e0220027f0000011e02200167000000000121016f0000000102400210000000000121019f000002960000013d000000010320008a0000000503300270000000000431001900000020030000390000000104400039000000040600002900000000056300190000000005050433000000000051041b00000020033000390000000101100039000000000041004b000002810000c13d000000070020006c000002930000813d00000007020000290000000302200210000000f80220018f0000011e0220027f0000011e0220016700000004033000290000000003030433000000000223016f000000000021041b0000000701000029000000010110021000000001011001bf0000000302000039000000000012041b00000006010000290000000001010433000700000001001d000000fe0010009c000000630000213d0000000401000039000000000101041a000000010010019000000001021002700000007f0220618f000500000002001d0000001f0020008c00000000020000390000000102002039000000000121013f00000001001001900000019b0000c13d0000000501000029000000200010008c000002c80000413d0000000401000039000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d00000007030000290000001f023000390000000502200270000000200030008c0000000002004019000000000301043b00000005010000290000001f01100039000000050110027000000000011300190000000002230019000000000012004b000002c80000813d000000000002041b0000000102200039000000000012004b000002c40000413d00000007010000290000001f0010008c000002dc0000a13d0000000401000039000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f0000000100200190000000200200008a0000004e0000613d0000000702200180000000000101043b000002e90000c13d0000002003000039000002f60000013d000000070000006b0000000001000019000002e10000613d00000001010000290000000001010433000000070400002900000003024002100000011e0220027f0000011e02200167000000000121016f0000000102400210000000000121019f000003040000013d000000010320008a0000000503300270000000000431001900000020030000390000000104400039000000060600002900000000056300190000000005050433000000000051041b00000020033000390000000101100039000000000041004b000002ef0000c13d000000070020006c000003010000813d00000007020000290000000302200210000000f80220018f0000011e0220027f0000011e0220016700000006033000290000000003030433000000000223016f000000000021041b0000000701000029000000010110021000000001011001bf0000000402000039000000000012041b0000000001000411000000000001004b0000030c0000c13d000000400100043d0000010602000041000002480000013d0000000201000039000000000201041a000000020020002a0000033b0000413d0000000202200029000000000021041b0000000001000411000000000010043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d000000000101043b000000000201041a00000002030000290000000002320019000000000021041b000000400100043d0000000000310435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000121019f00000100011001c70000800d02000039000000030300003900000102040000410000000005000019000000000600041103e803de0000040f00000001002001900000004e0000613d0000002001000039000001000010044300000120000004430000010301000041000003e90001042e0000010401000041000000000010043f0000001101000039000000040010043f0000010501000041000003ea0001043000000020030000390000000004310436000000003202043400000000002404350000004001100039000000000002004b000003500000613d000000000400001900000000054100190000000006430019000000000606043300000000006504350000002004400039000000000024004b000003490000413d000000000321001900000000000304350000001f022000390000011f022001970000000001210019000000000001042d0000004005100039000000000045043500000020041000390000000000340435000001130220019700000000002104350000006001100039000000000001042d0005000000000002000500000003001d0000011303100198000003aa0000613d000100000001001d000301130020019c000003ad0000613d000400000003001d000000000030043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b000000000301041a0002000500300074000003b70000413d0000000401000029000000000010043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b0000000202000029000000000021041b0000000301000029000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b000000000201041a00000005030000290000000002320019000000000021041b000000400100043d0000000000310435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000100011001c70000800d02000039000000030300003900000102040000410000000405000029000000030600002903e803de0000040f0000000100200190000003a80000613d000000000001042d0000000001000019000003ea00010430000000400100043d0000012202000041000003af0000013d000000400100043d0000010602000041000000000021043500000004021000390000000000020435000000fb0010009c000000fb01008041000000400110021000000105011001c7000003ea00010430000000400200043d000400000002001d0000012101000041000000000012043500000004012000390000000102000029000000050400002903e803560000040f00000004020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003ea00010430000000fb0010009c000000fb010080410000004001100210000000fb0020009c000000fb020080410000006002200210000000000112019f0000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000123011001c7000080100200003903e803e30000040f0000000100200190000003dc0000613d000000000101043b000000000001042d0000000001000019000003ea00010430000003e1002104210000000102000039000000000001042d0000000002000019000000000001042d000003e6002104230000000102000039000000000001042d0000000002000019000000000001042d000003e800000432000003e90001042e000003ea00010430000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000001ffffffe000000000000000000000000000000000000000000000000000000000ffffffe0000000000000000000000000000000000000000000000000ffffffffffffffff800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000200000000000000000000000000200000000000000000000000000000000000040000000000000000000000000ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef00000002000000000000000000000000000000400000010000000000000000004e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000ec442f050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000313ce5660000000000000000000000000000000000000000000000000000000095d89b400000000000000000000000000000000000000000000000000000000095d89b4100000000000000000000000000000000000000000000000000000000a9059cbb00000000000000000000000000000000000000000000000000000000dd62ed3e00000000000000000000000000000000000000000000000000000000313ce5670000000000000000000000000000000000000000000000000000000070a082310000000000000000000000000000000000000000000000000000000018160ddc0000000000000000000000000000000000000000000000000000000018160ddd0000000000000000000000000000000000000000000000000000000023b872dd0000000000000000000000000000000000000000000000000000000006fdde0300000000000000000000000000000000000000000000000000000000095ea7b3000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000002000000080000000000000000000000000000000000000000000000000000000200000000000000000000000008a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b000000000000000000000000000000000000000000000000ffffffffffffff7f94280d6200000000000000000000000000000000000000000000000000000000e602df0500000000000000000000000000000000000000000000000000000000fb8f41b2000000000000000000000000000000000000000000000000000000008c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9250000000000000000000000000000000000000024000000800000000000000000c2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85bffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00e450d38c0000000000000000000000000000000000000000000000000000000096c6fd1e0000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001dbc83e97c797e3233d0240e131aa65294eb9b53fd276d14db99f1ca12c7fd24"; diff --git a/packages/plugin-abstract/src/environment.ts b/packages/plugin-abstract/src/environment.ts index 4061e22f0c3..502872ef016 100644 --- a/packages/plugin-abstract/src/environment.ts +++ b/packages/plugin-abstract/src/environment.ts @@ -3,42 +3,42 @@ import { isAddress } from "viem"; import { z } from "zod"; export const abstractEnvSchema = z.object({ - ABSTRACT_ADDRESS: z - .string() - .min(1, "Abstract address is required") - .refine((address) => isAddress(address, { strict: false }), { - message: "Abstract address must be a valid address", - }), - ABSTRACT_PRIVATE_KEY: z - .string() - .min(1, "Abstract private key is required") - .refine((key) => /^[a-fA-F0-9]{64}$/.test(key), { - message: - "Abstract private key must be a 64-character hexadecimal string (32 bytes) without the '0x' prefix", - }), + ABSTRACT_ADDRESS: z + .string() + .min(1, "Abstract address is required") + .refine((address) => isAddress(address, { strict: false }), { + message: "Abstract address must be a valid address", + }), + ABSTRACT_PRIVATE_KEY: z + .string() + .min(1, "Abstract private key is required") + .refine((key) => /^[a-fA-F0-9]{64}$/.test(key), { + message: + "Abstract private key must be a 64-character hexadecimal string (32 bytes) without the '0x' prefix", + }), }); export type AbstractConfig = z.infer; export async function validateAbstractConfig( - runtime: IAgentRuntime + runtime: IAgentRuntime, ): Promise { - try { - const config = { - ABSTRACT_ADDRESS: runtime.getSetting("ABSTRACT_ADDRESS"), - ABSTRACT_PRIVATE_KEY: runtime.getSetting("ABSTRACT_PRIVATE_KEY"), - }; + try { + const config = { + ABSTRACT_ADDRESS: runtime.getSetting("ABSTRACT_ADDRESS"), + ABSTRACT_PRIVATE_KEY: runtime.getSetting("ABSTRACT_PRIVATE_KEY"), + }; - return abstractEnvSchema.parse(config); - } catch (error) { - if (error instanceof z.ZodError) { - const errorMessages = error.errors - .map((err) => `${err.path.join(".")}: ${err.message}`) - .join("\n"); - throw new Error( - `Abstract configuration validation failed:\n${errorMessages}` - ); - } - throw error; - } + return abstractEnvSchema.parse(config); + } catch (error) { + if (error instanceof z.ZodError) { + const errorMessages = error.errors + .map((err) => `${err.path.join(".")}: ${err.message}`) + .join("\n"); + throw new Error( + `Abstract configuration validation failed:\n${errorMessages}`, + ); + } + throw error; + } } diff --git a/packages/plugin-abstract/src/hooks/useGetAccount.ts b/packages/plugin-abstract/src/hooks/useGetAccount.ts index 7e2285dc0a6..5700c3f848c 100644 --- a/packages/plugin-abstract/src/hooks/useGetAccount.ts +++ b/packages/plugin-abstract/src/hooks/useGetAccount.ts @@ -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("ABSTRACT_PRIVATE_KEY")!; - return privateKeyToAccount(`0x${PRIVATE_KEY}`); + const PRIVATE_KEY = runtime.getSetting("ABSTRACT_PRIVATE_KEY"); + if (!PRIVATE_KEY) { + throw new Error("ABSTRACT_PRIVATE_KEY is not set"); + } + return privateKeyToAccount(`0x${PRIVATE_KEY}`); }; diff --git a/packages/plugin-abstract/src/hooks/useGetWalletClient.ts b/packages/plugin-abstract/src/hooks/useGetWalletClient.ts index a2ed821f36f..93c464737dd 100644 --- a/packages/plugin-abstract/src/hooks/useGetWalletClient.ts +++ b/packages/plugin-abstract/src/hooks/useGetWalletClient.ts @@ -3,10 +3,10 @@ import { abstractTestnet } from "viem/chains"; import { eip712WalletActions } from "viem/zksync"; export const useGetWalletClient = (): ReturnType => { - const client = createWalletClient({ - chain: abstractTestnet, - transport: http(), - }).extend(eip712WalletActions()); + const client = createWalletClient({ + chain: abstractTestnet, + transport: http(), + }).extend(eip712WalletActions()); - return client; + return client; }; diff --git a/packages/plugin-abstract/src/index.ts b/packages/plugin-abstract/src/index.ts index a995b617649..09076cc0ce8 100644 --- a/packages/plugin-abstract/src/index.ts +++ b/packages/plugin-abstract/src/index.ts @@ -3,11 +3,11 @@ import type { Plugin } from "@elizaos/core"; import { transferAction, getBalanceAction, deployTokenAction } from "./actions"; export const abstractPlugin: Plugin = { - name: "abstract", - description: "Abstract Plugin for Eliza", - actions: [transferAction, getBalanceAction, deployTokenAction], - evaluators: [], - providers: [], + name: "abstract", + description: "Abstract Plugin for Eliza", + actions: [transferAction, getBalanceAction, deployTokenAction], + evaluators: [], + providers: [], }; export default abstractPlugin; diff --git a/packages/plugin-abstract/src/utils/viemHelpers.ts b/packages/plugin-abstract/src/utils/viemHelpers.ts index b1d1e2c513a..1420e931e98 100644 --- a/packages/plugin-abstract/src/utils/viemHelpers.ts +++ b/packages/plugin-abstract/src/utils/viemHelpers.ts @@ -1,71 +1,83 @@ import { - type Address, - createPublicClient, - getAddress, - http, - isAddress, - type PublicClient, + type Address, + createPublicClient, + getAddress, + http, + isAddress, + type PublicClient, } from "viem"; import { abstractTestnet, mainnet } from "viem/chains"; import { normalize } from "viem/ens"; import { elizaLogger } from "@elizaos/core"; -import { ETH_ADDRESS, } from "../constants"; +import { ETH_ADDRESS } from "../constants"; + +import { + type Account, + type Client, + createClient, + createWalletClient, + type Transport, +} from "viem"; +import { toAccount } from "viem/accounts"; +import type { ChainEIP712 } from "viem/zksync"; + +import { getSmartAccountAddressFromInitialSigner } from "./utils.js"; +import { + type AbstractWalletActions, + globalWalletActions, +} from "./walletActions.js"; // Shared clients export const ethereumClient = createPublicClient({ - chain: mainnet, - transport: http(), + chain: mainnet, + transport: http(), }); export const abstractPublicClient = createPublicClient({ - chain: abstractTestnet, - transport: http(), + chain: abstractTestnet, + transport: http(), }); - - // Helper to resolve ENS names -export async function resolveAddress(addressOrEns: string): Promise
{ - if (isAddress(addressOrEns)) { - return getAddress(addressOrEns); - } - - let address:string - try { - const name = normalize(addressOrEns.trim()); - const resolved = await ethereumClient.getEnsAddress({ name }); - if (resolved) { - address = resolved; - elizaLogger.log(`Resolved ${name} to ${resolved}`); - - } - } catch (error) { - elizaLogger.error("Error resolving ENS name:", error); - } - - - return getAddress(address); - +export async function resolveAddress( + addressOrEns: string, +): Promise
{ + if (isAddress(addressOrEns)) { + return getAddress(addressOrEns); + } + + let address: string; + try { + const name = normalize(addressOrEns.trim()); + const resolved = await ethereumClient.getEnsAddress({ name }); + if (resolved) { + address = resolved; + elizaLogger.log(`Resolved ${name} to ${resolved}`); + } + } catch (error) { + elizaLogger.error("Error resolving ENS name:", error); + } + + return getAddress(address); } const tokens = [ - { - address: ETH_ADDRESS, - symbol: "ETH", - decimals: 18, - }, - { - address: "0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc", - symbol: "USDC", - decimals: 6, - } -] - - export function getTokenByName(name: string) { - - const token = tokens.find(token => token.symbol.toLowerCase() === name.toLowerCase()) - - return token + { + address: ETH_ADDRESS, + symbol: "ETH", + decimals: 18, + }, + { + address: "0xe4c7fbb0a626ed208021ccaba6be1566905e2dfc", + symbol: "USDC", + decimals: 6, + }, +]; + +export function getTokenByName(name: string) { + const token = tokens.find( + (token) => token.symbol.toLowerCase() === name.toLowerCase(), + ); + + return token; } - - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb3cf0d7713..2d68eacc0d6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,19 +14,19 @@ importers: dependencies: '@0glabs/0g-ts-sdk': specifier: 0.2.1 - version: 0.2.1(bufferutil@4.0.9)(ethers@6.13.4(bufferutil@4.0.9)(utf-8-validate@5.0.10))(utf-8-validate@5.0.10) + version: 0.2.1(bufferutil@4.0.9)(ethers@6.13.4(bufferutil@4.0.9)(utf-8-validate@6.0.5))(utf-8-validate@6.0.5) '@coinbase/coinbase-sdk': specifier: 0.10.0 - version: 0.10.0(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.24.1) + version: 0.10.0(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@6.0.5)(zod@3.24.1) '@deepgram/sdk': specifier: ^3.9.0 - version: 3.9.0(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10) + version: 3.9.0(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@6.0.5) '@injectivelabs/sdk-ts': specifier: ^1.14.33 - version: 1.14.33(@types/react@19.0.7)(bufferutil@4.0.9)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(utf-8-validate@5.0.10) + version: 1.14.33(@types/react@19.0.7)(bufferutil@4.0.9)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(utf-8-validate@6.0.5) '@vitest/eslint-plugin': specifier: 1.0.1 - version: 1.0.1(@typescript-eslint/utils@8.20.0(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3))(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3)(vitest@2.1.5(@types/node@20.17.9)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@5.0.10))(terser@5.37.0)) + version: 1.0.1(@typescript-eslint/utils@8.20.0(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3))(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3)(vitest@2.1.5(@types/node@22.10.7)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@6.0.5))(terser@5.37.0)) amqplib: specifier: 0.10.5 version: 0.10.5 @@ -57,7 +57,7 @@ importers: version: 1.9.4 '@commitlint/cli': specifier: 18.6.1 - version: 18.6.1(@types/node@20.17.9)(typescript@5.6.3) + version: 18.6.1(@types/node@22.10.7)(typescript@5.6.3) '@commitlint/config-conventional': specifier: 18.6.3 version: 18.6.3 @@ -75,7 +75,7 @@ importers: version: 9.1.7 jest: specifier: ^29.7.0 - version: 29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) + version: 29.7.0(@types/node@22.10.7)(babel-plugin-macros@3.1.0) lerna: specifier: 8.1.5 version: 8.1.5(@swc/core@1.10.7(@swc/helpers@0.5.15))(babel-plugin-macros@3.1.0)(encoding@0.1.13) @@ -93,13 +93,13 @@ importers: version: 5.6.3 viem: specifier: 2.21.58 - version: 2.21.58(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.24.1) + version: 2.21.58(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@6.0.5)(zod@3.24.1) vite: specifier: 5.4.11 - version: 5.4.11(@types/node@20.17.9)(terser@5.37.0) + version: 5.4.11(@types/node@22.10.7)(terser@5.37.0) vitest: specifier: 2.1.5 - version: 2.1.5(@types/node@20.17.9)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@5.0.10))(terser@5.37.0) + version: 2.1.5(@types/node@22.10.7)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@6.0.5))(terser@5.37.0) agent: dependencies: @@ -1286,8 +1286,8 @@ importers: packages/plugin-abstract: dependencies: '@abstract-foundation/agw-client': - specifier: ^0.1.7 - version: 0.1.8(abitype@1.0.8(typescript@5.7.3)(zod@3.24.1))(typescript@5.7.3)(viem@2.21.58(bufferutil@4.0.9)(typescript@5.7.3)(utf-8-validate@6.0.5)(zod@3.24.1)) + specifier: 1.0.1 + version: 1.0.1(abitype@1.0.8(typescript@5.7.3)(zod@3.24.1))(typescript@5.7.3)(viem@2.21.58(bufferutil@4.0.9)(typescript@5.7.3)(utf-8-validate@6.0.5)(zod@3.24.1)) '@elizaos/core': specifier: workspace:* version: link:../core @@ -3441,8 +3441,8 @@ packages: '@3land/listings-sdk@0.0.6': resolution: {integrity: sha512-1OG4qddbij7kLGcyRvwA9WUiif7DJi2gEWODHF4NnfgQHRl22yLSFHZeHPLlo9mE1T2LZnn0I6HtUxvUtCHCAQ==} - '@abstract-foundation/agw-client@0.1.8': - resolution: {integrity: sha512-MEPfFRWtEVXUuWkE43Vrqxzk7s+23cRtY2ctzqiZSiqJ+Hg4uPCymowmqPATdYgGNQXPCzUYNQN4tFxFWRMaFA==} + '@abstract-foundation/agw-client@1.0.1': + resolution: {integrity: sha512-ZJEC2siysQz9FdnWs6xFDY9vuIV+5E01nUFgv/Kvw2mRmf148T7H99SoelN2o8qCmv1r3z2iWQCLCLTa5f3FtQ==} peerDependencies: abitype: ^1.0.0 typescript: '>=5.0.4' @@ -24280,18 +24280,6 @@ packages: snapshots: - '@0glabs/0g-ts-sdk@0.2.1(bufferutil@4.0.9)(ethers@6.13.4(bufferutil@4.0.9)(utf-8-validate@5.0.10))(utf-8-validate@5.0.10)': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - ethers: 6.13.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) - open-jsonrpc-provider: 0.2.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) - transitivePeerDependencies: - - bufferutil - - debug - - supports-color - - utf-8-validate - '@0glabs/0g-ts-sdk@0.2.1(bufferutil@4.0.9)(ethers@6.13.4(bufferutil@4.0.9)(utf-8-validate@6.0.5))(utf-8-validate@6.0.5)': dependencies: '@ethersproject/bytes': 5.7.0 @@ -24414,7 +24402,7 @@ snapshots: - typescript - utf-8-validate - '@abstract-foundation/agw-client@0.1.8(abitype@1.0.8(typescript@5.7.3)(zod@3.24.1))(typescript@5.7.3)(viem@2.21.58(bufferutil@4.0.9)(typescript@5.7.3)(utf-8-validate@6.0.5)(zod@3.24.1))': + '@abstract-foundation/agw-client@1.0.1(abitype@1.0.8(typescript@5.7.3)(zod@3.24.1))(typescript@5.7.3)(viem@2.21.58(bufferutil@4.0.9)(typescript@5.7.3)(utf-8-validate@6.0.5)(zod@3.24.1))': dependencies: abitype: 1.0.8(typescript@5.7.3)(zod@3.24.1) viem: 2.21.58(bufferutil@4.0.9)(typescript@5.7.3)(utf-8-validate@6.0.5)(zod@3.24.1) @@ -24424,7 +24412,7 @@ snapshots: '@acuminous/bitsyntax@0.1.2': dependencies: buffer-more-ints: 1.0.0 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) safe-buffer: 5.1.2 transitivePeerDependencies: - supports-color @@ -25592,7 +25580,7 @@ snapshots: '@babel/traverse': 7.26.5 '@babel/types': 7.26.5 convert-source-map: 2.0.0 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -26372,7 +26360,7 @@ snapshots: '@babel/parser': 7.26.5 '@babel/template': 7.25.9 '@babel/types': 7.26.5 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -26634,7 +26622,7 @@ snapshots: - typescript - utf-8-validate - '@coinbase/coinbase-sdk@0.10.0(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.24.1)': + '@coinbase/coinbase-sdk@0.10.0(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@6.0.5)(zod@3.24.1)': dependencies: '@scure/bip32': 1.6.2 abitype: 1.0.8(typescript@5.6.3)(zod@3.24.1) @@ -26645,10 +26633,10 @@ snapshots: bip39: 3.1.0 decimal.js: 10.4.3 dotenv: 16.4.7 - ethers: 6.13.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) + ethers: 6.13.4(bufferutil@4.0.9)(utf-8-validate@6.0.5) node-jose: 2.2.0 secp256k1: 5.0.1 - viem: 2.21.58(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.24.1) + viem: 2.21.58(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@6.0.5)(zod@3.24.1) transitivePeerDependencies: - bufferutil - debug @@ -26688,11 +26676,11 @@ snapshots: '@colors/colors@1.5.0': optional: true - '@commitlint/cli@18.6.1(@types/node@20.17.9)(typescript@5.6.3)': + '@commitlint/cli@18.6.1(@types/node@22.10.7)(typescript@5.6.3)': dependencies: '@commitlint/format': 18.6.1 '@commitlint/lint': 18.6.1 - '@commitlint/load': 18.6.1(@types/node@20.17.9)(typescript@5.6.3) + '@commitlint/load': 18.6.1(@types/node@22.10.7)(typescript@5.6.3) '@commitlint/read': 18.6.1 '@commitlint/types': 18.6.1 execa: 5.1.1 @@ -26742,7 +26730,7 @@ snapshots: '@commitlint/rules': 18.6.1 '@commitlint/types': 18.6.1 - '@commitlint/load@18.6.1(@types/node@20.17.9)(typescript@5.6.3)': + '@commitlint/load@18.6.1(@types/node@22.10.7)(typescript@5.6.3)': dependencies: '@commitlint/config-validator': 18.6.1 '@commitlint/execute-rule': 18.6.1 @@ -26750,7 +26738,7 @@ snapshots: '@commitlint/types': 18.6.1 chalk: 4.1.2 cosmiconfig: 8.3.6(typescript@5.6.3) - cosmiconfig-typescript-loader: 5.1.0(@types/node@20.17.9)(cosmiconfig@8.3.6(typescript@5.6.3))(typescript@5.6.3) + cosmiconfig-typescript-loader: 5.1.0(@types/node@22.10.7)(cosmiconfig@8.3.6(typescript@5.6.3))(typescript@5.6.3) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -27609,14 +27597,14 @@ snapshots: dependencies: dayjs: 1.11.13 - '@deepgram/sdk@3.9.0(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@5.0.10)': + '@deepgram/sdk@3.9.0(bufferutil@4.0.9)(encoding@0.1.13)(utf-8-validate@6.0.5)': dependencies: '@deepgram/captions': 1.2.0 '@types/node': 18.19.71 cross-fetch: 3.2.0(encoding@0.1.13) deepmerge: 4.3.1 events: 3.3.0 - ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@6.0.5) transitivePeerDependencies: - bufferutil - encoding @@ -29443,7 +29431,7 @@ snapshots: '@eslint/config-array@0.19.1': dependencies: '@eslint/object-schema': 2.1.5 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -29473,7 +29461,7 @@ snapshots: '@eslint/eslintrc@3.2.0': dependencies: ajv: 6.12.6 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) espree: 10.3.0 globals: 14.0.0 ignore: 5.3.2 @@ -30437,12 +30425,12 @@ snapshots: protobufjs: 7.4.0 rxjs: 7.8.1 - '@injectivelabs/sdk-ts@1.14.33(@types/react@19.0.7)(bufferutil@4.0.9)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(utf-8-validate@5.0.10)': + '@injectivelabs/sdk-ts@1.14.33(@types/react@19.0.7)(bufferutil@4.0.9)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(utf-8-validate@6.0.5)': dependencies: '@apollo/client': 3.12.6(@types/react@19.0.7)(graphql@16.10.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@cosmjs/amino': 0.32.4 '@cosmjs/proto-signing': 0.32.4 - '@cosmjs/stargate': 0.32.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@cosmjs/stargate': 0.32.4(bufferutil@4.0.9)(utf-8-validate@6.0.5) '@ethersproject/bytes': 5.7.0 '@injectivelabs/core-proto-ts': 1.13.4 '@injectivelabs/exceptions': 1.14.33(google-protobuf@3.21.4) @@ -30463,7 +30451,7 @@ snapshots: bip39: 3.1.0 cosmjs-types: 0.9.0 ethereumjs-util: 7.1.5 - ethers: 6.13.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) + ethers: 6.13.4(bufferutil@4.0.9)(utf-8-validate@6.0.5) google-protobuf: 3.21.4 graphql: 16.10.0 http-status-codes: 2.3.0 @@ -30915,41 +30903,6 @@ snapshots: jest-util: 29.7.0 slash: 3.0.0 - '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3))': - dependencies: - '@jest/console': 29.7.0 - '@jest/reporters': 29.7.0 - '@jest/test-result': 29.7.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.17.9 - ansi-escapes: 4.3.2 - chalk: 4.1.2 - ci-info: 3.9.0 - exit: 0.1.2 - graceful-fs: 4.2.11 - jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) - jest-haste-map: 29.7.0 - jest-message-util: 29.7.0 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-resolve-dependencies: 29.7.0 - jest-runner: 29.7.0 - jest-runtime: 29.7.0 - jest-snapshot: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - jest-watcher: 29.7.0 - micromatch: 4.0.8 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-ansi: 6.0.1 - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - - ts-node - '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.7.3))': dependencies: '@jest/console': 29.7.0 @@ -38637,7 +38590,7 @@ snapshots: dependencies: '@typescript-eslint/types': 8.20.0 '@typescript-eslint/visitor-keys': 8.20.0 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 @@ -38838,13 +38791,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@vitest/eslint-plugin@1.0.1(@typescript-eslint/utils@8.20.0(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3))(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3)(vitest@2.1.5(@types/node@20.17.9)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@5.0.10))(terser@5.37.0))': + '@vitest/eslint-plugin@1.0.1(@typescript-eslint/utils@8.20.0(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3))(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3)(vitest@2.1.5(@types/node@22.10.7)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@6.0.5))(terser@5.37.0))': dependencies: eslint: 9.18.0(jiti@2.4.2) optionalDependencies: '@typescript-eslint/utils': 8.20.0(eslint@9.18.0(jiti@2.4.2))(typescript@5.6.3) typescript: 5.6.3 - vitest: 2.1.5(@types/node@20.17.9)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@5.0.10))(terser@5.37.0) + vitest: 2.1.5(@types/node@22.10.7)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@6.0.5))(terser@5.37.0) '@vitest/expect@0.34.6': dependencies: @@ -38900,14 +38853,6 @@ snapshots: optionalDependencies: vite: 5.4.11(@types/node@22.10.7)(terser@5.37.0) - '@vitest/mocker@2.1.5(vite@5.4.11(@types/node@20.17.9)(terser@5.37.0))': - dependencies: - '@vitest/spy': 2.1.5 - estree-walker: 3.0.3 - magic-string: 0.30.17 - optionalDependencies: - vite: 5.4.11(@types/node@20.17.9)(terser@5.37.0) - '@vitest/mocker@2.1.5(vite@5.4.11(@types/node@22.10.7)(terser@5.37.0))': dependencies: '@vitest/spy': 2.1.5 @@ -40082,7 +40027,7 @@ snapshots: agent-base@6.0.2: dependencies: - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) transitivePeerDependencies: - supports-color @@ -40684,13 +40629,6 @@ snapshots: transitivePeerDependencies: - debug - axios@0.27.2: - dependencies: - follow-redirects: 1.15.9 - form-data: 4.0.1 - transitivePeerDependencies: - - debug - axios@0.27.2(debug@4.3.4): dependencies: follow-redirects: 1.15.9(debug@4.3.4) @@ -40739,7 +40677,7 @@ snapshots: axios@1.7.9: dependencies: - follow-redirects: 1.15.9 + follow-redirects: 1.15.9(debug@4.3.4) form-data: 4.0.1 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -42219,9 +42157,9 @@ snapshots: dependencies: layout-base: 2.0.1 - cosmiconfig-typescript-loader@5.1.0(@types/node@20.17.9)(cosmiconfig@8.3.6(typescript@5.6.3))(typescript@5.6.3): + cosmiconfig-typescript-loader@5.1.0(@types/node@22.10.7)(cosmiconfig@8.3.6(typescript@5.6.3))(typescript@5.6.3): dependencies: - '@types/node': 20.17.9 + '@types/node': 22.10.7 cosmiconfig: 8.3.6(typescript@5.6.3) jiti: 1.21.7 typescript: 5.6.3 @@ -42303,21 +42241,6 @@ snapshots: safe-buffer: 5.2.1 sha.js: 2.4.11 - create-jest@29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)): - 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)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(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)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.7.3)): dependencies: '@jest/types': 29.6.3 @@ -42914,10 +42837,6 @@ snapshots: dependencies: ms: 2.1.3 - debug@4.4.0: - dependencies: - ms: 2.1.3 - debug@4.4.0(supports-color@5.5.0): dependencies: ms: 2.1.3 @@ -44026,7 +43945,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.6 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) escape-string-regexp: 4.0.0 eslint-scope: 8.2.0 eslint-visitor-keys: 4.2.0 @@ -44515,7 +44434,7 @@ snapshots: extract-zip@2.0.1: dependencies: - debug: 4.3.4 + debug: 4.4.0(supports-color@5.5.0) get-stream: 5.2.0 yauzl: 2.10.0 optionalDependencies: @@ -44804,8 +44723,6 @@ snapshots: async: 0.2.10 which: 1.3.1 - follow-redirects@1.15.9: {} - follow-redirects@1.15.9(debug@4.3.4): optionalDependencies: debug: 4.3.4 @@ -45891,7 +45808,7 @@ snapshots: http-proxy-agent@7.0.2: dependencies: agent-base: 7.1.3 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) transitivePeerDependencies: - supports-color @@ -45949,14 +45866,14 @@ snapshots: https-proxy-agent@5.0.1: dependencies: agent-base: 6.0.2 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) transitivePeerDependencies: - supports-color https-proxy-agent@7.0.6: dependencies: agent-base: 7.1.3 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) transitivePeerDependencies: - supports-color @@ -46599,7 +46516,7 @@ snapshots: istanbul-lib-source-maps@4.0.1: dependencies: - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) istanbul-lib-coverage: 3.2.2 source-map: 0.6.1 transitivePeerDependencies: @@ -46716,25 +46633,6 @@ snapshots: - babel-plugin-macros - supports-color - jest-cli@29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)): - dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@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 - create-jest: 29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) - exit: 0.1.2 - import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(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)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.7.3)): dependencies: '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.7.3)) @@ -46792,37 +46690,6 @@ snapshots: - supports-color - ts-node - jest-config@29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)): - dependencies: - '@babel/core': 7.26.0 - '@jest/test-sequencer': 29.7.0 - '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.26.0) - chalk: 4.1.2 - ci-info: 3.9.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.7.0(babel-plugin-macros@3.1.0) - jest-environment-node: 29.7.0 - jest-get-type: 29.6.3 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-runner: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - micromatch: 4.0.8 - parse-json: 5.2.0 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-json-comments: 3.1.1 - optionalDependencies: - '@types/node': 20.17.9 - ts-node: 10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3) - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - jest-config@29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.7.3)): dependencies: '@babel/core': 7.26.0 @@ -47167,18 +47034,6 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)): - dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@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@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.6.3)) - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - jest@29.7.0(@types/node@20.17.9)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.7.3)): dependencies: '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.10.7(@swc/helpers@0.5.15))(@types/node@20.17.9)(typescript@5.7.3)) @@ -49802,18 +49657,6 @@ snapshots: platform: 1.3.6 protobufjs: 7.4.0 - open-jsonrpc-provider@0.2.1(bufferutil@4.0.9)(utf-8-validate@5.0.10): - dependencies: - axios: 0.27.2 - reconnecting-websocket: 4.4.0 - websocket: 1.0.35 - ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - transitivePeerDependencies: - - bufferutil - - debug - - supports-color - - utf-8-validate - open-jsonrpc-provider@0.2.1(bufferutil@4.0.9)(utf-8-validate@6.0.5): dependencies: axios: 0.27.2(debug@4.3.4) @@ -53091,7 +52934,7 @@ snapshots: socks-proxy-agent@8.0.5: dependencies: agent-base: 7.1.3 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) socks: 2.8.3 transitivePeerDependencies: - supports-color @@ -54638,7 +54481,7 @@ snapshots: tuf-js@2.2.1: dependencies: '@tufjs/models': 2.0.1 - debug: 4.4.0 + debug: 4.4.0(supports-color@5.5.0) make-fetch-happen: 13.0.1 transitivePeerDependencies: - supports-color @@ -55318,17 +55161,17 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.2 - viem@2.21.58(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.24.1): + viem@2.21.58(bufferutil@4.0.9)(typescript@5.6.3)(utf-8-validate@6.0.5)(zod@3.24.1): dependencies: '@noble/curves': 1.7.0 '@noble/hashes': 1.6.1 '@scure/bip32': 1.6.0 '@scure/bip39': 1.5.0 abitype: 1.0.7(typescript@5.6.3)(zod@3.24.1) - isows: 1.0.6(ws@8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) + isows: 1.0.6(ws@8.18.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)) ox: 0.4.4(typescript@5.6.3)(zod@3.24.1) webauthn-p256: 0.0.10 - ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@6.0.5) optionalDependencies: typescript: 5.6.3 transitivePeerDependencies: @@ -55533,24 +55376,6 @@ snapshots: - supports-color - terser - vite-node@2.1.5(@types/node@20.17.9)(terser@5.37.0): - dependencies: - cac: 6.7.14 - debug: 4.4.0 - es-module-lexer: 1.6.0 - pathe: 1.1.2 - vite: 5.4.11(@types/node@20.17.9)(terser@5.37.0) - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - vite-node@2.1.5(@types/node@22.10.7)(terser@5.37.0): dependencies: cac: 6.7.14 @@ -56132,42 +55957,6 @@ snapshots: - supports-color - terser - vitest@2.1.5(@types/node@20.17.9)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@5.0.10))(terser@5.37.0): - dependencies: - '@vitest/expect': 2.1.5 - '@vitest/mocker': 2.1.5(vite@5.4.11(@types/node@20.17.9)(terser@5.37.0)) - '@vitest/pretty-format': 2.1.8 - '@vitest/runner': 2.1.5 - '@vitest/snapshot': 2.1.5 - '@vitest/spy': 2.1.5 - '@vitest/utils': 2.1.5 - chai: 5.1.2 - debug: 4.4.0 - expect-type: 1.1.0 - magic-string: 0.30.17 - pathe: 1.1.2 - std-env: 3.8.0 - tinybench: 2.9.0 - tinyexec: 0.3.2 - tinypool: 1.0.2 - tinyrainbow: 1.2.0 - vite: 5.4.11(@types/node@20.17.9)(terser@5.37.0) - vite-node: 2.1.5(@types/node@20.17.9)(terser@5.37.0) - why-is-node-running: 2.3.0 - optionalDependencies: - '@types/node': 20.17.9 - jsdom: 25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@5.0.10) - transitivePeerDependencies: - - less - - lightningcss - - msw - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - vitest@2.1.5(@types/node@22.10.7)(jsdom@25.0.1(bufferutil@4.0.9)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@6.0.5))(terser@5.37.0): dependencies: '@vitest/expect': 2.1.5 From 357886a4e98e1ee416870949d9368005b720e6ba Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 19 Jan 2025 22:09:42 +0100 Subject: [PATCH 3/3] update on coderabbit comments --- .../src/actions/deployTokenAction.ts | 14 +- .../src/actions/getBalanceAction.ts | 4 +- .../src/actions/transferAction.ts | 8 +- .../src/constants/basicToken.ts | 334 ----------------- .../src/constants/contracts/basicToken.json | 339 ++++++++++++++++++ .../plugin-abstract/src/utils/viemHelpers.ts | 6 +- 6 files changed, 357 insertions(+), 348 deletions(-) delete mode 100644 packages/plugin-abstract/src/constants/basicToken.ts create mode 100644 packages/plugin-abstract/src/constants/contracts/basicToken.json diff --git a/packages/plugin-abstract/src/actions/deployTokenAction.ts b/packages/plugin-abstract/src/actions/deployTokenAction.ts index fc58b0dfc5d..e06a22fbf8b 100644 --- a/packages/plugin-abstract/src/actions/deployTokenAction.ts +++ b/packages/plugin-abstract/src/actions/deployTokenAction.ts @@ -21,7 +21,7 @@ import { } from "@abstract-foundation/agw-client"; import { z } from "zod"; import { useGetAccount, useGetWalletClient } from "../hooks"; -import { abi as basicTokenAbi, bytecode } from "../constants/basicToken"; +import basicToken from "../constants/contracts/basicToken.json"; import { abstractPublicClient } from "../utils/viemHelpers"; const DeploySchema = z.object({ @@ -147,20 +147,20 @@ export const deployTokenAction: Action = { })) as any; // type being exported as never hash = await abstractClient.deployContract({ - abi: basicTokenAbi, - bytecode, + abi: basicToken.abi, + bytecode: basicToken.bytecode, args: [result.data.name, result.data.symbol, supply], }); } else { const walletClient = useGetWalletClient(); hash = await walletClient.deployContract({ - chain: abstractTestnet, + chain: abstractTestnet, account, - abi: basicTokenAbi, - bytecode, + abi: basicToken.abi, + bytecode: basicToken.bytecode, args: [result.data.name, result.data.symbol, supply], - kzg: undefined + kzg: undefined, }); } diff --git a/packages/plugin-abstract/src/actions/getBalanceAction.ts b/packages/plugin-abstract/src/actions/getBalanceAction.ts index fe750d49f8b..9b4c68ecd00 100644 --- a/packages/plugin-abstract/src/actions/getBalanceAction.ts +++ b/packages/plugin-abstract/src/actions/getBalanceAction.ts @@ -51,8 +51,8 @@ const balanceTemplate = `Respond with a JSON markdown block containing only the Example response: \`\`\`json { - "tokenAddress": "0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E", - "walletAddress": "0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", + "tokenAddress": "", + "walletAddress": "", "tokenSymbol": "USDC" } \`\`\` diff --git a/packages/plugin-abstract/src/actions/transferAction.ts b/packages/plugin-abstract/src/actions/transferAction.ts index 94ef86ab131..6fbe1ec4b7c 100644 --- a/packages/plugin-abstract/src/actions/transferAction.ts +++ b/packages/plugin-abstract/src/actions/transferAction.ts @@ -58,8 +58,8 @@ const transferTemplate = `Respond with a JSON markdown block containing only the Example response: \`\`\`json { - "tokenAddress": "0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E", - "recipient": "0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62", + "tokenAddress": "", + "recipient": "", "amount": "1000", "useAGW": true, "tokenSymbol": "USDC" @@ -199,10 +199,10 @@ export const transferAction: Action = { const tokenAmount = parseUnits(amount.toString(), decimals); if (useAGW) { - const abstractClient = await createAbstractClient({ + const abstractClient = (await createAbstractClient({ chain: abstractTestnet, signer: account, - }) as any; // biome-ignore lint/suspicious/noExplicitAny: type being exported as never + })) as any; // biome-ignore lint/suspicious/noExplicitAny: type being exported as never if (isEthTransfer) { hash = await abstractClient.sendTransaction({ diff --git a/packages/plugin-abstract/src/constants/basicToken.ts b/packages/plugin-abstract/src/constants/basicToken.ts deleted file mode 100644 index 6ee93bce78c..00000000000 --- a/packages/plugin-abstract/src/constants/basicToken.ts +++ /dev/null @@ -1,334 +0,0 @@ -export const abi = [ - { - inputs: [ - { - internalType: "string", - name: "name", - type: "string", - }, - { - internalType: "string", - name: "symbol", - type: "string", - }, - { - internalType: "uint256", - name: "initialSupply", - type: "uint256", - }, - ], - stateMutability: "nonpayable", - type: "constructor", - }, - { - inputs: [ - { - internalType: "address", - name: "spender", - type: "address", - }, - { - internalType: "uint256", - name: "allowance", - type: "uint256", - }, - { - internalType: "uint256", - name: "needed", - type: "uint256", - }, - ], - name: "ERC20InsufficientAllowance", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "uint256", - name: "balance", - type: "uint256", - }, - { - internalType: "uint256", - name: "needed", - type: "uint256", - }, - ], - name: "ERC20InsufficientBalance", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "approver", - type: "address", - }, - ], - name: "ERC20InvalidApprover", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "receiver", - type: "address", - }, - ], - name: "ERC20InvalidReceiver", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "sender", - type: "address", - }, - ], - name: "ERC20InvalidSender", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "spender", - type: "address", - }, - ], - name: "ERC20InvalidSpender", - type: "error", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "owner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "spender", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "Approval", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "from", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "to", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "Transfer", - type: "event", - }, - { - inputs: [ - { - internalType: "address", - name: "owner", - type: "address", - }, - { - internalType: "address", - name: "spender", - type: "address", - }, - ], - name: "allowance", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "spender", - type: "address", - }, - { - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "approve", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "account", - type: "address", - }, - ], - name: "balanceOf", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "decimals", - outputs: [ - { - internalType: "uint8", - name: "", - type: "uint8", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "name", - outputs: [ - { - internalType: "string", - name: "", - type: "string", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "symbol", - outputs: [ - { - internalType: "string", - name: "", - type: "string", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "totalSupply", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "to", - type: "address", - }, - { - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "transfer", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "from", - type: "address", - }, - { - internalType: "address", - name: "to", - type: "address", - }, - { - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "transferFrom", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, -] as const; - -export const bytecode = - "0x00070000000000020000008004000039000000400040043f0000006003100270000000fb0330019700000001002001900000002f0000c13d000000040030008c0000004e0000413d000000000201043b000000e002200270000001070020009c000000690000a13d000001080020009c000000b80000a13d000001090020009c0000018c0000613d0000010a0020009c000001a80000613d0000010b0020009c0000004e0000c13d000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000202043b000001130020009c0000004e0000213d0000002401100370000000000101043b000001130010009c0000004e0000213d000000000020043f000700000001001d0000000101000039000000200010043f0000004002000039000000000100001903e803c90000040f0000000702000029000000000020043f000000200010043f00000000010000190000004002000039000000c90000013d0000000002000416000000000002004b0000004e0000c13d0000001f02300039000000fc022001970000008002200039000000400020043f0000001f0530018f000000fd0630019800000080026000390000003f0000613d000000000701034f000000007807043c0000000004840436000000000024004b0000003b0000c13d000000000005004b0000004c0000613d000000000161034f0000000304500210000000000502043300000000054501cf000000000545022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000151019f0000000000120435000000600030008c000000500000813d0000000001000019000003ea00010430000000800400043d000000fe0040009c0000004e0000213d0000001f01400039000000000031004b0000000002000019000000ff02008041000000ff01100197000000000001004b0000000005000019000000ff05004041000000ff0010009c000000000502c019000000000005004b0000004e0000c13d00000080014000390000000002010433000000fe0020009c000000cb0000a13d0000010401000041000000000010043f0000004101000039000000040010043f0000010501000041000003ea000104300000010e0020009c0000007f0000213d000001110020009c000001640000613d000001120020009c0000004e0000c13d000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000302043b000001130030009c0000004e0000213d0000002401100370000000000201043b0000000001000411000000000001004b000001c60000c13d0000011901000041000001c90000013d0000010f0020009c000001840000613d000001100020009c0000004e0000c13d000000640030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000302043b000001130030009c0000004e0000213d0000002402100370000000000202043b000700000002001d000001130020009c0000004e0000213d0000004401100370000000000101043b000500000001001d000000000030043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c70000801002000039000600000003001d03e803e30000040f00000001002001900000004e0000613d000000000101043b0000000002000411000000000020043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000060500002900000001002001900000004e0000613d000000000101043b000000000301041a0000011e0030009c000002290000c13d00000000010500190000000702000029000000050300002903e8035e0000040f000002030000013d0000010c0020009c000001a10000613d0000010d0020009c0000004e0000c13d000000240030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000401100370000000000101043b000001130010009c0000004e0000213d000000000010043f000000200000043f0000004002000039000000000100001903e803c90000040f000001880000013d0000001f012000390000011f011001970000003f011000390000011f01100197000000400900043d0000000005190019000000000095004b00000000010000390000000101004039000000fe0050009c000000630000213d0000000100100190000000630000c13d0000008001300039000000400050043f000000000a290436000000a0044000390000000005420019000000000015004b0000004e0000213d000000000002004b000000e90000613d000000000500001900000000065a00190000000007450019000000000707043300000000007604350000002005500039000000000025004b000000e20000413d000000000292001900000020022000390000000000020435000000a00400043d000000fe0040009c0000004e0000213d0000001f02400039000000000032004b0000000003000019000000ff03008041000000ff02200197000000000002004b0000000005000019000000ff05004041000000ff0020009c000000000503c019000000000005004b0000004e0000c13d00000080024000390000000002020433000000fe0020009c000000630000213d0000001f032000390000011f033001970000003f033000390000011f03300197000000400600043d0000000003360019000000000063004b00000000050000390000000105004039000000fe0030009c000000630000213d0000000100500190000000630000c13d000000400030043f0000000007260436000000a0034000390000000004320019000000000014004b0000004e0000213d000000000002004b0000011c0000613d000000000100001900000000041700190000000005310019000000000505043300000000005404350000002001100039000000000021004b000001150000413d0000000001620019000000200110003900000000000104350000000004090433000000fe0040009c000000630000213d0000000303000039000000000103041a000000010210019000000001051002700000007f0550618f0000001f0050008c00000000010000390000000101002039000000000012004b0000019b0000c13d00030000000a001d000400000009001d000100000007001d000600000006001d000000c00100043d000200000001001d000500000005001d000000200050008c000700000004001d000001520000413d000000000030043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d00000007040000290000001f024000390000000502200270000000200040008c0000000002004019000000000301043b00000005010000290000001f01100039000000050110027000000000011300190000000002230019000000000012004b0000000303000039000001520000813d000000000002041b0000000102200039000000000012004b0000014e0000413d0000001f0040008c0000026e0000a13d000000000030043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f0000000100200190000000200200008a0000004e0000613d0000000702200180000000000101043b0000027b0000c13d0000002003000039000002880000013d0000000001000416000000000001004b0000004e0000c13d0000000303000039000000000203041a000000010520019000000001012002700000007f0410018f00000000010460190000001f0010008c00000000060000390000000106002039000000000662013f00000001006001900000019b0000c13d000000800010043f000000000005004b000001c00000613d000000000030043f000000020020008c000001d00000413d0000011d0200004100000000040000190000000003040019000000000402041a000000a005300039000000000045043500000001022000390000002004300039000000000014004b0000017b0000413d000002150000013d0000000001000416000000000001004b0000004e0000c13d0000000201000039000000000101041a000000800010043f0000011401000041000003e90001042e0000000001000416000000000001004b0000004e0000c13d0000000403000039000000000203041a000000010520019000000001012002700000007f0410018f00000000010460190000001f0010008c00000000060000390000000106002039000000000662013f0000000100600190000001bd0000613d0000010401000041000000000010043f0000002201000039000000040010043f0000010501000041000003ea000104300000000001000416000000000001004b0000004e0000c13d0000001201000039000000800010043f0000011401000041000003e90001042e000000440030008c0000004e0000413d0000000002000416000000000002004b0000004e0000c13d0000000402100370000000000202043b000001130020009c0000004e0000213d0000002401100370000000000301043b000000000100041103e8035e0000040f0000000101000039000000400200043d0000000000120435000000fb0020009c000000fb02008041000000400120021000000115011001c7000003e90001042e000000800010043f000000000005004b000001cd0000c13d0000012001200197000000a00010043f000000000004004b000000c001000039000000a001006039000002160000013d000000000003004b000001d20000c13d0000011801000041000000800010043f000000840000043f0000011c01000041000003ea00010430000000000030043f000000020020008c0000020b0000813d00000020010000390000021a0000013d000600000002001d000000000010043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c70000801002000039000700000003001d03e803e30000040f000000070300002900000001002001900000004e0000613d000000000101043b000000000030043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000070600002900000001002001900000004e0000613d000000000101043b0000000602000029000000000021041b000000400100043d0000000000210435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000100011001c70000800d0200003900000003030000390000011b04000041000000000500041103e803de0000040f00000001002001900000004e0000613d000000400100043d00000001020000390000000000210435000000fb0010009c000000fb01008041000000400110021000000115011001c7000003e90001042e000001160200004100000000040000190000000003040019000000000402041a000000a005300039000000000045043500000001022000390000002004300039000000000014004b0000020d0000413d000000c001300039000000610110008a0000011f01100197000001170010009c000000630000213d0000008001100039000700000001001d000000400010043f000000800200003903e803410000040f00000007020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003e90001042e0000000504000029000000000143004b0000023d0000813d000000400200043d000700000002001d0000011a0100004100000000001204350000000401200039000000000200041103e803560000040f00000007020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003ea00010430000000000005004b000002420000c13d000000400100043d0000011902000041000002480000013d000400000001001d0000000001000411000000000001004b000002500000c13d000000400100043d0000011802000041000000000021043500000004021000390000000000020435000000fb0010009c000000fb01008041000000400110021000000105011001c7000003ea00010430000000000050043f0000000101000039000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d000000000101043b0000000002000411000000000020043f000000200010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f000000060500002900000001002001900000004e0000613d000000000101043b0000000402000029000000000021041b000000b30000013d000000070000006b0000000001000019000002730000613d00000003010000290000000001010433000000070400002900000003024002100000011e0220027f0000011e02200167000000000121016f0000000102400210000000000121019f000002960000013d000000010320008a0000000503300270000000000431001900000020030000390000000104400039000000040600002900000000056300190000000005050433000000000051041b00000020033000390000000101100039000000000041004b000002810000c13d000000070020006c000002930000813d00000007020000290000000302200210000000f80220018f0000011e0220027f0000011e0220016700000004033000290000000003030433000000000223016f000000000021041b0000000701000029000000010110021000000001011001bf0000000302000039000000000012041b00000006010000290000000001010433000700000001001d000000fe0010009c000000630000213d0000000401000039000000000101041a000000010010019000000001021002700000007f0220618f000500000002001d0000001f0020008c00000000020000390000000102002039000000000121013f00000001001001900000019b0000c13d0000000501000029000000200010008c000002c80000413d0000000401000039000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d00000007030000290000001f023000390000000502200270000000200030008c0000000002004019000000000301043b00000005010000290000001f01100039000000050110027000000000011300190000000002230019000000000012004b000002c80000813d000000000002041b0000000102200039000000000012004b000002c40000413d00000007010000290000001f0010008c000002dc0000a13d0000000401000039000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000100011001c7000080100200003903e803e30000040f0000000100200190000000200200008a0000004e0000613d0000000702200180000000000101043b000002e90000c13d0000002003000039000002f60000013d000000070000006b0000000001000019000002e10000613d00000001010000290000000001010433000000070400002900000003024002100000011e0220027f0000011e02200167000000000121016f0000000102400210000000000121019f000003040000013d000000010320008a0000000503300270000000000431001900000020030000390000000104400039000000060600002900000000056300190000000005050433000000000051041b00000020033000390000000101100039000000000041004b000002ef0000c13d000000070020006c000003010000813d00000007020000290000000302200210000000f80220018f0000011e0220027f0000011e0220016700000006033000290000000003030433000000000223016f000000000021041b0000000701000029000000010110021000000001011001bf0000000402000039000000000012041b0000000001000411000000000001004b0000030c0000c13d000000400100043d0000010602000041000002480000013d0000000201000039000000000201041a000000020020002a0000033b0000413d0000000202200029000000000021041b0000000001000411000000000010043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f00000001002001900000004e0000613d000000000101043b000000000201041a00000002030000290000000002320019000000000021041b000000400100043d0000000000310435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000121019f00000100011001c70000800d02000039000000030300003900000102040000410000000005000019000000000600041103e803de0000040f00000001002001900000004e0000613d0000002001000039000001000010044300000120000004430000010301000041000003e90001042e0000010401000041000000000010043f0000001101000039000000040010043f0000010501000041000003ea0001043000000020030000390000000004310436000000003202043400000000002404350000004001100039000000000002004b000003500000613d000000000400001900000000054100190000000006430019000000000606043300000000006504350000002004400039000000000024004b000003490000413d000000000321001900000000000304350000001f022000390000011f022001970000000001210019000000000001042d0000004005100039000000000045043500000020041000390000000000340435000001130220019700000000002104350000006001100039000000000001042d0005000000000002000500000003001d0000011303100198000003aa0000613d000100000001001d000301130020019c000003ad0000613d000400000003001d000000000030043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b000000000301041a0002000500300074000003b70000413d0000000401000029000000000010043f000000200000043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b0000000202000029000000000021041b0000000301000029000000000010043f0000000001000414000000fb0010009c000000fb01008041000000c00110021000000101011001c7000080100200003903e803e30000040f0000000100200190000003a80000613d000000000101043b000000000201041a00000005030000290000000002320019000000000021041b000000400100043d0000000000310435000000fb0010009c000000fb0100804100000040011002100000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000100011001c70000800d02000039000000030300003900000102040000410000000405000029000000030600002903e803de0000040f0000000100200190000003a80000613d000000000001042d0000000001000019000003ea00010430000000400100043d0000012202000041000003af0000013d000000400100043d0000010602000041000000000021043500000004021000390000000000020435000000fb0010009c000000fb01008041000000400110021000000105011001c7000003ea00010430000000400200043d000400000002001d0000012101000041000000000012043500000004012000390000000102000029000000050400002903e803560000040f00000004020000290000000001210049000000fb0010009c000000fb010080410000006001100210000000fb0020009c000000fb020080410000004002200210000000000121019f000003ea00010430000000fb0010009c000000fb010080410000004001100210000000fb0020009c000000fb020080410000006002200210000000000112019f0000000002000414000000fb0020009c000000fb02008041000000c002200210000000000112019f00000123011001c7000080100200003903e803e30000040f0000000100200190000003dc0000613d000000000101043b000000000001042d0000000001000019000003ea00010430000003e1002104210000000102000039000000000001042d0000000002000019000000000001042d000003e6002104230000000102000039000000000001042d0000000002000019000000000001042d000003e800000432000003e90001042e000003ea00010430000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000001ffffffe000000000000000000000000000000000000000000000000000000000ffffffe0000000000000000000000000000000000000000000000000ffffffffffffffff800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000200000000000000000000000000200000000000000000000000000000000000040000000000000000000000000ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef00000002000000000000000000000000000000400000010000000000000000004e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000ec442f050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000313ce5660000000000000000000000000000000000000000000000000000000095d89b400000000000000000000000000000000000000000000000000000000095d89b4100000000000000000000000000000000000000000000000000000000a9059cbb00000000000000000000000000000000000000000000000000000000dd62ed3e00000000000000000000000000000000000000000000000000000000313ce5670000000000000000000000000000000000000000000000000000000070a082310000000000000000000000000000000000000000000000000000000018160ddc0000000000000000000000000000000000000000000000000000000018160ddd0000000000000000000000000000000000000000000000000000000023b872dd0000000000000000000000000000000000000000000000000000000006fdde0300000000000000000000000000000000000000000000000000000000095ea7b3000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000002000000080000000000000000000000000000000000000000000000000000000200000000000000000000000008a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b000000000000000000000000000000000000000000000000ffffffffffffff7f94280d6200000000000000000000000000000000000000000000000000000000e602df0500000000000000000000000000000000000000000000000000000000fb8f41b2000000000000000000000000000000000000000000000000000000008c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9250000000000000000000000000000000000000024000000800000000000000000c2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85bffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00e450d38c0000000000000000000000000000000000000000000000000000000096c6fd1e0000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001dbc83e97c797e3233d0240e131aa65294eb9b53fd276d14db99f1ca12c7fd24"; diff --git a/packages/plugin-abstract/src/constants/contracts/basicToken.json b/packages/plugin-abstract/src/constants/contracts/basicToken.json new file mode 100644 index 00000000000..c36c2b8982d --- /dev/null +++ b/packages/plugin-abstract/src/constants/contracts/basicToken.json @@ -0,0 +1,339 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "BasicToken", + "sourceName": "contracts/BasicToken.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "initialSupply", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b506040516117bf3803806117bf833981810160405281019061003291906104c6565b828281600390816100439190610768565b5080600490816100539190610768565b505050610066338261006e60201b60201c565b50505061095a565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036100e05760006040517fec442f050000000000000000000000000000000000000000000000000000000081526004016100d7919061087b565b60405180910390fd5b6100f2600083836100f660201b60201c565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361014857806002600082825461013c91906108c5565b9250508190555061021b565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156101d4578381836040517fe450d38c0000000000000000000000000000000000000000000000000000000081526004016101cb93929190610908565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361026457806002600082825403925050819055506102b1565b806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161030e919061093f565b60405180910390a3505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61038282610339565b810181811067ffffffffffffffff821117156103a1576103a061034a565b5b80604052505050565b60006103b461031b565b90506103c08282610379565b919050565b600067ffffffffffffffff8211156103e0576103df61034a565b5b6103e982610339565b9050602081019050919050565b60005b838110156104145780820151818401526020810190506103f9565b60008484015250505050565b600061043361042e846103c5565b6103aa565b90508281526020810184848401111561044f5761044e610334565b5b61045a8482856103f6565b509392505050565b600082601f8301126104775761047661032f565b5b8151610487848260208601610420565b91505092915050565b6000819050919050565b6104a381610490565b81146104ae57600080fd5b50565b6000815190506104c08161049a565b92915050565b6000806000606084860312156104df576104de610325565b5b600084015167ffffffffffffffff8111156104fd576104fc61032a565b5b61050986828701610462565b935050602084015167ffffffffffffffff81111561052a5761052961032a565b5b61053686828701610462565b9250506040610547868287016104b1565b9150509250925092565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806105a357607f821691505b6020821081036105b6576105b561055c565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b60006008830261061e7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826105e1565b61062886836105e1565b95508019841693508086168417925050509392505050565b6000819050919050565b600061066561066061065b84610490565b610640565b610490565b9050919050565b6000819050919050565b61067f8361064a565b61069361068b8261066c565b8484546105ee565b825550505050565b600090565b6106a861069b565b6106b3818484610676565b505050565b5b818110156106d7576106cc6000826106a0565b6001810190506106b9565b5050565b601f82111561071c576106ed816105bc565b6106f6846105d1565b81016020851015610705578190505b610719610711856105d1565b8301826106b8565b50505b505050565b600082821c905092915050565b600061073f60001984600802610721565b1980831691505092915050565b6000610758838361072e565b9150826002028217905092915050565b61077182610551565b67ffffffffffffffff81111561078a5761078961034a565b5b610794825461058b565b61079f8282856106db565b600060209050601f8311600181146107d257600084156107c0578287015190505b6107ca858261074c565b865550610832565b601f1984166107e0866105bc565b60005b82811015610808578489015182556001820191506020850194506020810190506107e3565b868310156108255784890151610821601f89168261072e565b8355505b6001600288020188555050505b505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108658261083a565b9050919050565b6108758161085a565b82525050565b6000602082019050610890600083018461086c565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006108d082610490565b91506108db83610490565b92508282019050808211156108f3576108f2610896565b5b92915050565b61090281610490565b82525050565b600060608201905061091d600083018661086c565b61092a60208301856108f9565b61093760408301846108f9565b949350505050565b600060208201905061095460008301846108f9565b92915050565b610e56806109696000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce5671461013457806370a082311461015257806395d89b4114610182578063a9059cbb146101a0578063dd62ed3e146101d057610093565b806306fdde0314610098578063095ea7b3146100b657806318160ddd146100e657806323b872dd14610104575b600080fd5b6100a0610200565b6040516100ad9190610aaa565b60405180910390f35b6100d060048036038101906100cb9190610b65565b610292565b6040516100dd9190610bc0565b60405180910390f35b6100ee6102b5565b6040516100fb9190610bea565b60405180910390f35b61011e60048036038101906101199190610c05565b6102bf565b60405161012b9190610bc0565b60405180910390f35b61013c6102ee565b6040516101499190610c74565b60405180910390f35b61016c60048036038101906101679190610c8f565b6102f7565b6040516101799190610bea565b60405180910390f35b61018a61033f565b6040516101979190610aaa565b60405180910390f35b6101ba60048036038101906101b59190610b65565b6103d1565b6040516101c79190610bc0565b60405180910390f35b6101ea60048036038101906101e59190610cbc565b6103f4565b6040516101f79190610bea565b60405180910390f35b60606003805461020f90610d2b565b80601f016020809104026020016040519081016040528092919081815260200182805461023b90610d2b565b80156102885780601f1061025d57610100808354040283529160200191610288565b820191906000526020600020905b81548152906001019060200180831161026b57829003601f168201915b5050505050905090565b60008061029d61047b565b90506102aa818585610483565b600191505092915050565b6000600254905090565b6000806102ca61047b565b90506102d7858285610495565b6102e285858561052a565b60019150509392505050565b60006012905090565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461034e90610d2b565b80601f016020809104026020016040519081016040528092919081815260200182805461037a90610d2b565b80156103c75780601f1061039c576101008083540402835291602001916103c7565b820191906000526020600020905b8154815290600101906020018083116103aa57829003601f168201915b5050505050905090565b6000806103dc61047b565b90506103e981858561052a565b600191505092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b610490838383600161061e565b505050565b60006104a184846103f4565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156105245781811015610514578281836040517ffb8f41b200000000000000000000000000000000000000000000000000000000815260040161050b93929190610d6b565b60405180910390fd5b6105238484848403600061061e565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361059c5760006040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016105939190610da2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361060e5760006040517fec442f050000000000000000000000000000000000000000000000000000000081526004016106059190610da2565b60405180910390fd5b6106198383836107f5565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036106905760006040517fe602df050000000000000000000000000000000000000000000000000000000081526004016106879190610da2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036107025760006040517f94280d620000000000000000000000000000000000000000000000000000000081526004016106f99190610da2565b60405180910390fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080156107ef578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516107e69190610bea565b60405180910390a35b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361084757806002600082825461083b9190610dec565b9250508190555061091a565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156108d3578381836040517fe450d38c0000000000000000000000000000000000000000000000000000000081526004016108ca93929190610d6b565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361096357806002600082825403925050819055506109b0565b806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610a0d9190610bea565b60405180910390a3505050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610a54578082015181840152602081019050610a39565b60008484015250505050565b6000601f19601f8301169050919050565b6000610a7c82610a1a565b610a868185610a25565b9350610a96818560208601610a36565b610a9f81610a60565b840191505092915050565b60006020820190508181036000830152610ac48184610a71565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610afc82610ad1565b9050919050565b610b0c81610af1565b8114610b1757600080fd5b50565b600081359050610b2981610b03565b92915050565b6000819050919050565b610b4281610b2f565b8114610b4d57600080fd5b50565b600081359050610b5f81610b39565b92915050565b60008060408385031215610b7c57610b7b610acc565b5b6000610b8a85828601610b1a565b9250506020610b9b85828601610b50565b9150509250929050565b60008115159050919050565b610bba81610ba5565b82525050565b6000602082019050610bd56000830184610bb1565b92915050565b610be481610b2f565b82525050565b6000602082019050610bff6000830184610bdb565b92915050565b600080600060608486031215610c1e57610c1d610acc565b5b6000610c2c86828701610b1a565b9350506020610c3d86828701610b1a565b9250506040610c4e86828701610b50565b9150509250925092565b600060ff82169050919050565b610c6e81610c58565b82525050565b6000602082019050610c896000830184610c65565b92915050565b600060208284031215610ca557610ca4610acc565b5b6000610cb384828501610b1a565b91505092915050565b60008060408385031215610cd357610cd2610acc565b5b6000610ce185828601610b1a565b9250506020610cf285828601610b1a565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680610d4357607f821691505b602082108103610d5657610d55610cfc565b5b50919050565b610d6581610af1565b82525050565b6000606082019050610d806000830186610d5c565b610d8d6020830185610bdb565b610d9a6040830184610bdb565b949350505050565b6000602082019050610db76000830184610d5c565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610df782610b2f565b9150610e0283610b2f565b9250828201905080821115610e1a57610e19610dbd565b5b9291505056fea2646970667358221220f413ecdb821df363531c0a0bcc98dfeb9baf7e41031710ae13ffb1596f19db2b64736f6c634300081c0033", + "linkReferences": {}, + "deployedLinkReferences": {} +} \ No newline at end of file diff --git a/packages/plugin-abstract/src/utils/viemHelpers.ts b/packages/plugin-abstract/src/utils/viemHelpers.ts index 1420e931e98..c1c7044e169 100644 --- a/packages/plugin-abstract/src/utils/viemHelpers.ts +++ b/packages/plugin-abstract/src/utils/viemHelpers.ts @@ -58,7 +58,7 @@ export async function resolveAddress( elizaLogger.error("Error resolving ENS name:", error); } - return getAddress(address); + return address ? getAddress(address) : null; } const tokens = [ @@ -79,5 +79,9 @@ export function getTokenByName(name: string) { (token) => token.symbol.toLowerCase() === name.toLowerCase(), ); + if (!token) { + throw new Error(`Token ${name} not found`); + } + return token; }