forked from Squads-Protocol/v4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vault_transaction_accounts_close): instruction, sdk, tests
- Loading branch information
Showing
15 changed files
with
2,328 additions
and
855 deletions.
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
sdk/multisig/src/generated/instructions/vaultTransactionAccountsClose.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
39 changes: 39 additions & 0 deletions
39
sdk/multisig/src/instructions/vaultTransactionAccountsClose.ts
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,39 @@ | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { | ||
createVaultTransactionAccountsCloseInstruction, | ||
PROGRAM_ID, | ||
} from "../generated"; | ||
import { getProposalPda, getTransactionPda } from "../pda"; | ||
|
||
export function vaultTransactionAccountsClose({ | ||
multisigPda, | ||
rentCollector, | ||
transactionIndex, | ||
programId = PROGRAM_ID, | ||
}: { | ||
multisigPda: PublicKey; | ||
rentCollector: PublicKey; | ||
transactionIndex: bigint; | ||
programId?: PublicKey; | ||
}) { | ||
const [proposalPda] = getProposalPda({ | ||
multisigPda, | ||
transactionIndex, | ||
programId, | ||
}); | ||
const [transactionPda] = getTransactionPda({ | ||
multisigPda, | ||
index: transactionIndex, | ||
programId, | ||
}); | ||
|
||
return createVaultTransactionAccountsCloseInstruction( | ||
{ | ||
multisig: multisigPda, | ||
rentCollector, | ||
proposal: proposalPda, | ||
transaction: transactionPda, | ||
}, | ||
programId | ||
); | ||
} |
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,49 @@ | ||
import { | ||
Connection, | ||
PublicKey, | ||
SendOptions, | ||
Signer, | ||
TransactionSignature, | ||
} from "@solana/web3.js"; | ||
import * as transactions from "../transactions/index.js"; | ||
import { translateAndThrowAnchorError } from "../errors"; | ||
|
||
/** | ||
* Close the Proposal and ConfigTransaction accounts associated with a config transaction. | ||
*/ | ||
export async function vaultTransactionAccountsClose({ | ||
connection, | ||
feePayer, | ||
multisigPda, | ||
rentCollector, | ||
transactionIndex, | ||
sendOptions, | ||
programId, | ||
}: { | ||
connection: Connection; | ||
feePayer: Signer; | ||
multisigPda: PublicKey; | ||
rentCollector: PublicKey; | ||
transactionIndex: bigint; | ||
sendOptions?: SendOptions; | ||
programId?: PublicKey; | ||
}): Promise<TransactionSignature> { | ||
const blockhash = (await connection.getLatestBlockhash()).blockhash; | ||
|
||
const tx = transactions.vaultTransactionAccountsClose({ | ||
blockhash, | ||
feePayer: feePayer.publicKey, | ||
rentCollector, | ||
transactionIndex, | ||
multisigPda, | ||
programId, | ||
}); | ||
|
||
tx.sign([feePayer]); | ||
|
||
try { | ||
return await connection.sendTransaction(tx, sendOptions); | ||
} catch (err) { | ||
translateAndThrowAnchorError(err); | ||
} | ||
} |
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
Oops, something went wrong.