diff --git a/src/actions/createMultisigProposal.ts b/src/actions/createMultisigProposal.ts index 9c83ab56..2100f986 100644 --- a/src/actions/createMultisigProposal.ts +++ b/src/actions/createMultisigProposal.ts @@ -36,16 +36,18 @@ const createMultisigProposalAction: Action = { transactionIndex: z.number().optional(), }), handler: async (agent: SolanaAgentKit, input: Record) => { - const multisig = await multisig_create_proposal( - agent, - input.transactionIndex as number, - ); + const transactionIndex = + input.transactionIndex !== undefined + ? Number(input.transactionIndex) + : undefined; + + const multisig = await multisig_create_proposal(agent, transactionIndex); return { status: "success", message: "Proposal created successfully", transaction: multisig, - transactionIndex: input.transactionIndex as number, + transactionIndex: transactionIndex, }; }, }; diff --git a/src/actions/executeMultisigProposal.ts b/src/actions/executeMultisigProposal.ts new file mode 100644 index 00000000..fee9c28e --- /dev/null +++ b/src/actions/executeMultisigProposal.ts @@ -0,0 +1,53 @@ +import { Action } from "../types/action"; +import { SolanaAgentKit } from "../agent"; +import { z } from "zod"; +import { multisig_execute_proposal } from "../tools"; + +const executeMultisigProposalAction: Action = { + name: "EXECUTE_MULTISIG_PROPOSAL_ACTION", + similes: [ + "execute proposal", + "execute proposal to transfer funds", + "execute proposal to transfer funds from 2-of-2 multisig", + "execute proposal to transfer funds from 2-of-2 multisig account", + "execute proposal to transfer funds from 2-of-2 multisig account on Solana", + ], + description: `Execute a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.`, + examples: [ + [ + { + input: { + proposalIndex: 0, + }, + output: { + status: "success", + message: "Proposal executed successfully", + transaction: "4xKpN2...", + proposalIndex: "0", + }, + explanation: + "Execute a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana", + }, + ], + ], + schema: z.object({ + proposalIndex: z.number().optional(), + }), + handler: async (agent: SolanaAgentKit, input: Record) => { + const proposalIndex = + input.proposalIndex !== undefined + ? Number(input.proposalIndex) + : undefined; + + const multisig = await multisig_execute_proposal(agent, proposalIndex); + + return { + status: "success", + message: "Proposal executed successfully", + transaction: multisig, + proposalIndex, + }; + }, +}; + +export default executeMultisigProposalAction; diff --git a/src/actions/index.ts b/src/actions/index.ts index c29483a6..ed005884 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -35,6 +35,8 @@ import depositToMultisigAction from "./depositToMultisigTreasury"; import transferFromMultisigAction from "./transferFromMultisigTreasury"; import createMultisigProposalAction from "./createMultisigProposal"; import approveMultisigProposalAction from "./approveMultisigProposal"; +import rejectMultisigProposalAction from "./rejectMultisigProposal"; +import executeMultisigProposalAction from "./executeMultisigProposal"; export const ACTIONS = { WALLET_ADDRESS_ACTION: getWalletAddressAction, @@ -75,6 +77,8 @@ export const ACTIONS = { TRANSFER_FROM_MULTISIG_ACTION: transferFromMultisigAction, CREATE_MULTISIG_PROPOSAL_ACTION: createMultisigProposalAction, APPROVE_MULTISIG_PROPOSAL_ACTION: approveMultisigProposalAction, + REJECT_MULTISIG_PROPOSAL_ACTION: rejectMultisigProposalAction, + EXECUTE_MULTISIG_PROPOSAL_ACTION: executeMultisigProposalAction, }; export type { Action, ActionExample, Handler } from "../types/action"; diff --git a/src/actions/rejectMultisigProposal.ts b/src/actions/rejectMultisigProposal.ts new file mode 100644 index 00000000..7e62ce00 --- /dev/null +++ b/src/actions/rejectMultisigProposal.ts @@ -0,0 +1,53 @@ +import { Action } from "../types/action"; +import { SolanaAgentKit } from "../agent"; +import { z } from "zod"; +import { multisig_reject_proposal } from "../tools"; + +const rejectMultisigProposalAction: Action = { + name: "REJECT_MULTISIG_PROPOSAL_ACTION", + similes: [ + "reject proposal", + "reject proposal to transfer funds", + "reject proposal to transfer funds from 2-of-2 multisig", + "reject proposal to transfer funds from 2-of-2 multisig account", + "reject proposal to transfer funds from 2-of-2 multisig account on Solana", + ], + description: `Reject a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.`, + examples: [ + [ + { + input: { + transactionIndex: 0, + }, + output: { + status: "success", + message: "Proposal rejected successfully", + transaction: "4xKpN2...", + transactionIndex: "0", + }, + explanation: + "Reject a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana", + }, + ], + ], + schema: z.object({ + transactionIndex: z.number().optional(), + }), + handler: async (agent: SolanaAgentKit, input: Record) => { + const transactionIndex = + input.transactionIndex !== undefined + ? Number(input.transactionIndex) + : undefined; + + const tx = await multisig_reject_proposal(agent, transactionIndex); + + return { + status: "success", + message: "Proposal rejected successfully", + transaction: tx, + transactionIndex: transactionIndex, + }; + }, +}; + +export default rejectMultisigProposalAction; diff --git a/src/actions/transferFromMultisigTreasury.ts b/src/actions/transferFromMultisigTreasury.ts index cddb2054..16db4b55 100644 --- a/src/actions/transferFromMultisigTreasury.ts +++ b/src/actions/transferFromMultisigTreasury.ts @@ -34,7 +34,7 @@ const transferFromMultisigAction: Action = { ], schema: z.object({ amount: z.number().min(0, "Amount must be greater than 0"), - recipient: z.string().optional(), + recipient: z.string(), }), handler: async (agent: SolanaAgentKit, input: Record) => { const multisig = await multisig_transfer_from_treasury(