mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-16 07:36:45 +00:00
add Solana 2-of-2 multisig account creation and deposit tools
This commit is contained in:
@@ -2125,6 +2125,73 @@ export class SolanaFetchTokenDetailedReportTool extends Tool {
|
||||
}
|
||||
}
|
||||
|
||||
export class SolanaCreate2by2Multisig extends Tool {
|
||||
name = "create_2by2_multisig";
|
||||
description = `Create a 2-of-2 multisig account on Solana.
|
||||
|
||||
Inputs (JSON string):
|
||||
- creator: string, the public key of the creator (required).`;
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
super();
|
||||
}
|
||||
|
||||
protected async _call(input: string): Promise<string> {
|
||||
try {
|
||||
const inputFormat = JSON.parse(input);
|
||||
const creator = new PublicKey(inputFormat.creator);
|
||||
|
||||
const multisig = await this.solanaKit.createSquadsMultisig(creator);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "2-by-2 multisig account created successfully",
|
||||
multisig,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "CREATE_2BY2_MULTISIG_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SolanaDepositTo2by2Multisig extends Tool {
|
||||
name = "deposit_to_2by2_multisig";
|
||||
description = `Deposit funds to a 2-of-2 multisig account on Solana.
|
||||
|
||||
Inputs (JSON string):
|
||||
- amount: number, the amount to deposit in SOL (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 tx = await this.solanaKit.depositToMultisig(amount.toNumber());
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Funds deposited to 2-by-2 multisig account successfully",
|
||||
transaction: tx,
|
||||
amount: amount.toString(),
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "DEPOSIT_TO_2BY2_MULTISIG_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createSolanaTools(solanaKit: SolanaAgentKit) {
|
||||
return [
|
||||
new SolanaBalanceTool(solanaKit),
|
||||
@@ -2179,5 +2246,7 @@ export function createSolanaTools(solanaKit: SolanaAgentKit) {
|
||||
new SolanaFetchTokenDetailedReportTool(solanaKit),
|
||||
new SolanaPerpOpenTradeTool(solanaKit),
|
||||
new SolanaPerpCloseTradeTool(solanaKit),
|
||||
new SolanaCreate2by2Multisig(solanaKit),
|
||||
new SolanaDepositTo2by2Multisig(solanaKit),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user