diff --git a/packages/plugin-movement/src/actions/transfer.ts b/packages/plugin-movement/src/actions/transfer.ts index 3a2e27cfbcb..41dcd6ee2cf 100644 --- a/packages/plugin-movement/src/actions/transfer.ts +++ b/packages/plugin-movement/src/actions/transfer.ts @@ -21,7 +21,11 @@ import { PrivateKeyVariants, } from "@aptos-labs/ts-sdk"; import { walletProvider } from "../providers/wallet"; -import { MOVEMENT_NETWORK_CONFIG, MOVE_DECIMALS, MOVEMENT_EXPLORER_URL } from "../constants"; +import { + MOVEMENT_NETWORK_CONFIG, + MOVE_DECIMALS, + MOVEMENT_EXPLORER_URL, +} from "../constants"; export interface TransferContent extends Content { recipient: string; @@ -80,19 +84,27 @@ export default { "transfer token", "can you send", "please send", - "send" + "send", ], shouldHandle: (message: Memory) => { const text = message.content?.text?.toLowerCase() || ""; - return text.includes("send") && text.includes("move") && text.includes("0x"); + return ( + text.includes("send") && + text.includes("move") && + text.includes("0x") + ); }, validate: async (_runtime: IAgentRuntime, message: Memory) => { - elizaLogger.debug("Starting transfer validation for user:", message.userId); + elizaLogger.debug( + "Starting transfer validation for user:", + message.userId + ); elizaLogger.debug("Message text:", message.content?.text); return true; // Let the handler do the validation }, priority: 1000, // High priority for transfer actions - description: "Transfer Move tokens from the agent's wallet to another address", + description: + "Transfer Move tokens from the agent's wallet to another address", handler: async ( runtime: IAgentRuntime, message: Memory, @@ -104,16 +116,22 @@ export default { elizaLogger.debug("Message:", { text: message.content?.text, userId: message.userId, - action: message.content?.action + action: message.content?.action, }); try { const privateKey = runtime.getSetting("MOVEMENT_PRIVATE_KEY"); - elizaLogger.debug("Got private key:", privateKey ? "Present" : "Missing"); + elizaLogger.debug( + "Got private key:", + privateKey ? "Present" : "Missing" + ); const network = runtime.getSetting("MOVEMENT_NETWORK"); elizaLogger.debug("Network config:", network); - elizaLogger.debug("Available networks:", Object.keys(MOVEMENT_NETWORK_CONFIG)); + elizaLogger.debug( + "Available networks:", + Object.keys(MOVEMENT_NETWORK_CONFIG) + ); const movementAccount = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey( @@ -123,33 +141,37 @@ export default { ) ), }); - elizaLogger.debug("Created Movement account:", movementAccount.accountAddress.toStringLong()); + elizaLogger.debug( + "Created Movement account:", + movementAccount.accountAddress.toStringLong() + ); const aptosClient = new Aptos( new AptosConfig({ network: Network.CUSTOM, - fullnode: MOVEMENT_NETWORK_CONFIG[network].fullnode + fullnode: MOVEMENT_NETWORK_CONFIG[network].fullnode, }) ); - elizaLogger.debug("Created Aptos client with network:", MOVEMENT_NETWORK_CONFIG[network].fullnode); + elizaLogger.debug( + "Created Aptos client with network:", + MOVEMENT_NETWORK_CONFIG[network].fullnode + ); - const walletInfo = await walletProvider.get(runtime, message, state); + const walletInfo = await walletProvider.get( + runtime, + message, + state + ); state.walletInfo = walletInfo; - // // Initialize or update state - // if (!state) { - // state = (await runtime.composeState(message)) as State; - // } else { - // state = await runtime.updateRecentMessageState(state); - // } - + // Initialize or update state let currentState: State; if (!state) { currentState = (await runtime.composeState(message)) as State; } else { currentState = await runtime.updateRecentMessageState(state); } - + // Compose transfer context const transferContext = composeContext({ state: currentState, @@ -176,7 +198,7 @@ export default { } const adjustedAmount = BigInt( - Number(content.amount) * (10 ** MOVE_DECIMALS) + Number(content.amount) * 10 ** MOVE_DECIMALS ); console.log( `Transferring: ${content.amount} tokens (${adjustedAmount} base units)` @@ -204,7 +226,7 @@ export default { hash: executedTransaction.hash, amount: content.amount, recipient: content.recipient, - explorerUrl + explorerUrl, }); if (callback) { @@ -215,7 +237,7 @@ export default { hash: executedTransaction.hash, amount: content.amount, recipient: content.recipient, - explorerUrl + explorerUrl, }, }); } @@ -263,6 +285,6 @@ export default { action: "TRANSFER_MOVE", }, }, - ] + ], ] as ActionExample[][], } as Action; diff --git a/packages/plugin-near/src/actions/transfer.ts b/packages/plugin-near/src/actions/transfer.ts index e3012e3536b..e6456174aa8 100644 --- a/packages/plugin-near/src/actions/transfer.ts +++ b/packages/plugin-near/src/actions/transfer.ts @@ -93,11 +93,8 @@ async function transferNEAR( if (!parsedAmount) { throw new Error("Failed to parse NEAR amount"); } - - const result = await account.sendMoney( - recipient, - BigInt(parsedAmount) - ); + + const result = await account.sendMoney(recipient, BigInt(parsedAmount)); return result.transaction.hash; } @@ -117,15 +114,8 @@ export const executeTransfer: Action = { callback?: HandlerCallback ): Promise => { // Initialize or update state - - // if (!state) { - // state = (await runtime.composeState(message)) as State; - // } else { - // state = await runtime.updateRecentMessageState(state); - // } - let currentState: State; - + if (!state) { currentState = (await runtime.composeState(message)) as State; } else {