Skip to content

Commit

Permalink
add callback
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 committed Jan 12, 2025
1 parent 96b5d09 commit ea0a9b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/plugin-nft-collections/src/actions/list-nft.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Action, IAgentRuntime, Memory, State } from "@elizaos/core";
import { ReservoirService } from "../services/reservoir";
import { HandlerCallback } from "@elizaos/core";

// Helper function to extract NFT listing details from the message
function extractListingDetails(text: string): {
Expand Down Expand Up @@ -39,7 +40,9 @@ export const listNFTAction = (nftService: ReservoirService): Action => {
handler: async (
runtime: IAgentRuntime,
message: Memory,
state?: State
state: State,
options: any,
callback: HandlerCallback
) => {
try {
const {
Expand Down Expand Up @@ -92,6 +95,10 @@ export const listNFTAction = (nftService: ReservoirService): Action => {
? `• Transaction: ${listing.transactionHash}\n`
: "");

callback({
text: response,
});

await runtime.messageManager.createMemory({
id: message.id,
content: { text: response },
Expand Down
9 changes: 7 additions & 2 deletions packages/plugin-nft-collections/src/actions/sweep-floor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Action, IAgentRuntime, Memory, State } from "@elizaos/core";
import { ReservoirService } from "../services/reservoir";
import { HandlerCallback } from "@elizaos/core";

// Helper function to extract NFT details from the message
function extractNFTDetails(text: string): {
Expand Down Expand Up @@ -34,7 +35,9 @@ export const sweepFloorAction = (nftService: ReservoirService): Action => {
handler: async (
runtime: IAgentRuntime,
message: Memory,
state?: State
state: State,
options: any,
callback: HandlerCallback
) => {
try {
const { collectionAddress, quantity } = extractNFTDetails(
Expand Down Expand Up @@ -80,7 +83,9 @@ export const sweepFloorAction = (nftService: ReservoirService): Action => {
`• Average Price: ${(totalPrice / quantity).toFixed(4)} ETH\n` +
`• Transaction Path: ${result.path}\n` +
`• Status: ${result.steps.map((step) => `${step.action} - ${step.status}`).join(", ")}`;

callback({
text: response,
});
await runtime.messageManager.createMemory({
id: message.id,
content: { text: response },
Expand Down

0 comments on commit ea0a9b7

Please sign in to comment.