added 2by2 multisig transaction creation

This commit is contained in:
A91y
2025-01-06 15:42:32 +05:30
parent d909e8012a
commit 14c7bd451e
28 changed files with 96 additions and 56 deletions

View File

@@ -2192,6 +2192,46 @@ export class SolanaDepositTo2by2Multisig extends Tool {
}
}
export class SolanaTransferFrom2by2Multisig extends Tool {
name = "transfer_from_2by2_multisig";
description = `Create a transaction to transfer funds from a 2-of-2 multisig account on Solana.
Inputs (JSON string):
- amount: number, the amount to transfer in SOL (required).
- recipient: string, the public key of the recipient (required).`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const inputFormat = JSON.parse(input);
const amount = new Decimal(inputFormat.amount);
const recipient = new PublicKey(inputFormat.recipient);
const tx = await this.solanaKit.transferFromMultisig(
amount.toNumber(),
recipient,
);
return JSON.stringify({
status: "success",
message: "Transaction added to 2-by-2 multisig account successfully",
transaction: tx,
amount: amount.toString(),
recipient: recipient.toString(),
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "TRANSFER_FROM_2BY2_MULTISIG_ERROR",
});
}
}
}
export function createSolanaTools(solanaKit: SolanaAgentKit) {
return [
new SolanaBalanceTool(solanaKit),