-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding 2/2 multisig \w agent & user (#88)
# Pull Request Description ## Related Issue Fixes #149 ## Changes Made This PR adds the following changes: - added create squads multisig - deposit to multisig - tx from multisig - create proposal from multisig - approve proposal from multisig - reject proposal from multisig - exexute proposal from multisig ## Implementation Details <!-- Provide technical details about the implementation --> - added `@sqds/multisig` sdk ## Tests are added in comment below ## Transaction Links: https://explorer.solana.com/tx/4weMdQnnkV3SW3JAngdpZz3WEeugWni2ep2MP71KTbtLGHTLF7ok2EVKZP9Ug8T4twqr9HsB3tjLUyrGLnngzYVS?cluster=devnet https://explorer.solana.com/tx/4QUxE5VQGWZw1LCYbj3BYtzGfn2o45Zk71K8LBkTva8hAdv4o1jUNEwWmuQRMJpXY9yKKwiwD59tZRh6oXgd4Jzc?cluster=devnet https://explorer.solana.com/tx/TVuzkLBkCtJ5PvroXLnnW1PTeLMQ4R9NeoiHeoHhsGR2gJX3cLjq1Ndq6DVD72dQLLbJM6CqnJZDYu9VSp4YbxV?cluster=devnet https://explorer.solana.com/tx/62PDfY46rGFezTnVCbDHUeCMyoVCEfWdGJWkkDhFL1GoAcfznWgCYXo2DnSgpgZu59vvYuaNj5C32bjAkNnJZvtJ?cluster=devnet https://explorer.solana.com/tx/3Pxvyo2MVEEbqcPcQ6Q6ErFTEu9EGHPwgciMuXUXzLsB8XTdyCZbxfrscxJbCbW8DgRVA6AomTXX6Uup9Bnubzpu?cluster=devnet https://explorer.solana.com/tx/5MyWxoTUzL3Zb4rStXzqsX1Cp3L3ToQdYyPq2sDDHBHsJV9idoHZYcKQjzfmgkGdwg3mtJZdUeywuTGvhcdvzkGU?cluster=devnet https://explorer.solana.com/tx/3haMJ9EoLfDA7H5ACPb1K1A9Eyezfx9DtB2eCUgNE38CkQd95KtZNEjRopaMva2bqtRvTzRNqkLVvbVcu2Gjzphs?cluster=devnet https://explorer.solana.com/tx/4Rn1AD9bUGwQzN661pexyPEffp25bUujRUXk18NvfxinZD12rrBLdeASdtnb7QnDfgvwkfzwk2akgU4Sf8ek7XwR?cluster=devnet ## Checklist - [x] I have tested these changes locally - [x] I have updated the documentation - [x] I have added a transaction link - [x] I have added the prompt used to test it
- Loading branch information
Showing
13 changed files
with
1,137 additions
and
354 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { SolanaAgentKit } from "../../index"; | ||
import * as multisig from "@sqds/multisig"; | ||
const { Multisig } = multisig.accounts; | ||
|
||
/** | ||
* Approves a proposal in a Solana multisig wallet. | ||
* | ||
* @param {SolanaAgentKit} agent - The Solana agent kit instance. | ||
* @param {number | bigint} [transactionIndex] - The index of the transaction to approve. If not provided, the current transaction index will be used. | ||
* @returns {Promise<string>} - A promise that resolves to the transaction ID of the approved proposal. | ||
* @throws {Error} - Throws an error if the approval process fails. | ||
*/ | ||
export async function approve_proposal( | ||
agent: SolanaAgentKit, | ||
transactionIndex?: number | bigint, | ||
): Promise<string> { | ||
try { | ||
const createKey = agent.wallet; | ||
const [multisigPda] = multisig.getMultisigPda({ | ||
createKey: createKey.publicKey, | ||
}); | ||
const multisigInfo = await Multisig.fromAccountAddress( | ||
agent.connection, | ||
multisigPda, | ||
); | ||
const currentTransactionIndex = Number(multisigInfo.transactionIndex); | ||
if (!transactionIndex) { | ||
transactionIndex = BigInt(currentTransactionIndex); | ||
} else if (typeof transactionIndex !== "bigint") { | ||
transactionIndex = BigInt(transactionIndex); | ||
} | ||
// const [proposalPda, proposalBump] = multisig.getProposalPda({ | ||
// multisigPda, | ||
// transactionIndex, | ||
// }); | ||
const multisigTx = multisig.transactions.proposalApprove({ | ||
blockhash: (await agent.connection.getLatestBlockhash()).blockhash, | ||
feePayer: agent.wallet.publicKey, | ||
multisigPda, | ||
transactionIndex: transactionIndex, | ||
member: agent.wallet.publicKey, | ||
}); | ||
|
||
multisigTx.sign([agent.wallet]); | ||
const tx = await agent.connection.sendRawTransaction( | ||
multisigTx.serialize(), | ||
); | ||
return tx; | ||
} catch (error: any) { | ||
throw new Error(`Transfer failed: ${error}`); | ||
} | ||
} |
Oops, something went wrong.