diff --git a/packages/plugin-flow/src/actions/transfer.ts b/packages/plugin-flow/src/actions/transfer.ts index 88366028b5..bc04dcfec3 100644 --- a/packages/plugin-flow/src/actions/transfer.ts +++ b/packages/plugin-flow/src/actions/transfer.ts @@ -2,7 +2,7 @@ import { composeContext, Content, elizaLogger, - generateObjectDEPRECATED, + generateObjectArray, ModelClass, type Action, type ActionExample, @@ -87,12 +87,17 @@ export class TransferAction { }); // Generate transfer content - const content = await generateObjectDEPRECATED({ + const recommendations = await generateObjectArray({ runtime, context: transferContext, - modelClass: ModelClass.SMALL, + modelClass: ModelClass.MEDIUM, }); + elizaLogger.debug("Recommendations", recommendations); + + // Convert array to object + const content = recommendations[recommendations.length - 1]; + // Validate transfer content if (!isTransferContent(runtime, content)) { elizaLogger.error("Invalid content for SEND_COIN action."); diff --git a/packages/plugin-flow/src/assets/cadence/transactions/evm/call.cdc b/packages/plugin-flow/src/assets/cadence/transactions/evm/call.cdc index 1f7c60143b..44fffbcf7f 100644 --- a/packages/plugin-flow/src/assets/cadence/transactions/evm/call.cdc +++ b/packages/plugin-flow/src/assets/cadence/transactions/evm/call.cdc @@ -10,7 +10,20 @@ transaction(evmContractAddressHex: String, calldata: String, gasLimit: UInt64, v prepare(signer: auth(BorrowValue) &Account) { self.evmAddress = EVM.addressFromString(evmContractAddressHex) - self.coa = signer.storage.borrow(from: /storage/evm) + let storagePath = StoragePath(identifier: "evm")! + let publicPath = PublicPath(identifier: "evm")! + + // Reference signer's COA if one exists + let coa = signer.storage.borrow(from: storagePath) + if coa == nil { + let coa <- EVM.createCadenceOwnedAccount() + signer.storage.save<@EVM.CadenceOwnedAccount>(<-coa, to: storagePath) + let addressableCap = signer.capabilities.storage.issue<&EVM.CadenceOwnedAccount>(storagePath) + signer.capabilities.unpublish(publicPath) + signer.capabilities.publish(addressableCap, at: publicPath) + } + + self.coa = signer.storage.borrow(from: storagePath) ?? panic("Could not borrow COA from provided gateway address") } diff --git a/packages/plugin-flow/src/providers/connector.provider.ts b/packages/plugin-flow/src/providers/connector.provider.ts index f0a7e3913d..7d81fe3c87 100644 --- a/packages/plugin-flow/src/providers/connector.provider.ts +++ b/packages/plugin-flow/src/providers/connector.provider.ts @@ -72,7 +72,7 @@ export class FlowConnectorProvider { constructor(private readonly instance: FlowConnector) {} getConnectorStatus(runtime: IAgentRuntime): string { - let output = `${runtime.character.name}[${runtime.character.id ?? 0}] Connected to\n`; + let output = `Now user<${runtime.character.name}> connected to\n`; output += `Flow network: ${this.instance.network}\n`; output += `Flow Endpoint: ${this.instance.rpcEndpoint}\n`; return output; diff --git a/packages/plugin-flow/src/providers/wallet.provider.ts b/packages/plugin-flow/src/providers/wallet.provider.ts index 7e6ba65bf0..1d300bafa7 100644 --- a/packages/plugin-flow/src/providers/wallet.provider.ts +++ b/packages/plugin-flow/src/providers/wallet.provider.ts @@ -232,7 +232,12 @@ const flowWalletProvider: Provider = { elizaLogger.error("Invalid account info"); return null; } - return `Flow Wallet Address: ${walletProvider.address}\nBalance: ${info.balance} FLOW\nFlow COA(EVM) Address: ${info.coaAddress || "unknown"}\nFLOW COA(EVM) Balance: ${info.coaBalance ?? 0} FLOW`; + let output = `Here is user<${runtime.character.name}>'s wallet status:\n`; + output += `Flow wallet address: ${walletProvider.address}\n`; + output += `FLOW balance: ${info.balance} FLOW\n`; + output += `Flow wallet's COA(EVM) address: ${info.coaAddress || "unknown"}\n`; + output += `FLOW balance in COA(EVM) address: ${info.coaBalance ?? 0} FLOW`; + return output; } catch (error) { elizaLogger.error("Error in Flow wallet provider:", error.message); return null; diff --git a/packages/plugin-flow/src/templates/index.ts b/packages/plugin-flow/src/templates/index.ts index 1f6a3878e0..66b27b1854 100644 --- a/packages/plugin-flow/src/templates/index.ts +++ b/packages/plugin-flow/src/templates/index.ts @@ -8,7 +8,9 @@ Extract the following information about the requested transfer: - Field "token": Cadence Resource Identifier or ERC20 contract address (if not native token). this field should be null if the token is native token: $FLOW or FLOW. Examples for this field: 1. For Cadence resource identifier, the field should be "A.1654653399040a61.ContractName" 2. For ERC20 contract address, the field should be "0xe6ffc15a5bde7dd33c127670ba2b9fcb82db971a" -- Field "amount": Amount to transfer +- Field "amount": Amount to transfer, it should be a number or a string. Examples for this field: + 1. "1000" + 2. 1000 - Field "to": Recipient wallet address, can be EVM address or Cadence address. Examples for this field: 1. Cadence address: "0x1654653399040a61" 2. EVM address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e" @@ -21,7 +23,7 @@ Respond with a JSON markdown block containing only the extracted values. Use nul \`\`\`json { "token": string | null - "amount": string | null, + "amount": number | string | null, "to": string | null, "matched": boolean }