-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/timelock #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kostyamospan
wants to merge
16
commits into
main
Choose a base branch
from
feat/timelock
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/timelock #22
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1befe7b
chore: basic timelock tests
kostyamospan dc7314b
chore: more squads scripts
kostyamospan 4644d35
chore: timelock deployment scripts
kostyamospan 4cf5cbe
chore: upgrade scripts
kostyamospan f79eb80
fix: comments
kostyamospan 56f8695
chore: timelock scripts
kostyamospan de43bdd
fix: timelock scripts
kostyamospan 0f58758
fix: typo
kostyamospan fc365d0
fix: log
kostyamospan bb9f79d
fix: timelock transfer authority
kostyamospan d4d704d
Merge remote-tracking branch 'origin/main' into feat/timelock
kostyamospan 601a014
fix: tests
kostyamospan 8e08b02
fix: toolchain
kostyamospan fae25f1
fix: resize instruction
kostyamospan e221eed
fix: log
kostyamospan abb8ccf
fix: timelock flows
kostyamospan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Binary file not shown.
This file contains hidden or 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 hidden or 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,3 @@ | ||
| import { PublicKey } from "@solana/web3.js"; | ||
|
|
||
| export const SQUADS_PROGRAM_ID = new PublicKey('SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf'); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,138 @@ | ||
| import { Program } from '@coral-xyz/anchor'; | ||
| import { Keypair, PublicKey, Transaction } from '@solana/web3.js'; | ||
|
|
||
| import { AccessControl } from 'target/types/access_control'; | ||
|
|
||
| import ACCESS_CONTROL_IDL from '../../target/idl/access_control.json' with { type: 'json' }; | ||
| import { AC_ROLES } from '../constants/ac.constants'; | ||
| import { acRoleToBuffer, generateAcRoleAccount } from '../helpers/ac.helpers'; | ||
| import { initBankrun, processTransaction } from '../helpers/common.helpers'; | ||
| import { generateAcAccount } from '../helpers/vaults.helpers'; | ||
| import { ProgramTestContext } from 'solana-bankrun'; | ||
| import { DAY } from '../constants/common.constants'; | ||
| import * as multisig from "@sqds/multisig"; | ||
| import { SQUADS_PROGRAM_ID } from '../constants/squads.constant'; | ||
|
|
||
| const createMultisig = async (context: ProgramTestContext, { | ||
| authority, | ||
| timelock = 2n * DAY, | ||
| connection, | ||
| member | ||
| }: { | ||
| authority: Keypair, | ||
| member?: PublicKey | ||
| timelock?: bigint; | ||
| connection: any; | ||
| }) => { | ||
| const createKey = Keypair.generate(); | ||
| const [multisigPda] = multisig.getMultisigPda({ | ||
| createKey: createKey.publicKey, | ||
| }); | ||
|
|
||
| const programConfigPda = multisig.getProgramConfigPda({})[0]; | ||
|
|
||
| const programConfig = | ||
| await multisig.accounts.ProgramConfig.fromAccountAddress( | ||
| connection, | ||
| programConfigPda | ||
| ); | ||
|
|
||
| const configTreasury = programConfig.treasury; | ||
|
|
||
| await processTransaction(context, new Transaction().add(multisig.instructions.multisigCreateV2({ | ||
| // Must sign the transaction, unless the .rpc method is used. | ||
| createKey: createKey.publicKey, | ||
| // The creator & fee payer | ||
| creator: authority.publicKey, | ||
| // The PDA of the multisig you are creating, derived by a random PublicKey | ||
| multisigPda, | ||
| // Here the config authority will be the system program | ||
| configAuthority: null, | ||
| // Create without any time-lock | ||
| timeLock: Number(timelock), | ||
| // List of the members to add to the multisig | ||
| members: [{ | ||
| // Members Public Key | ||
| key: member ?? authority.publicKey, | ||
| // Granted Proposer, Voter, and Executor permissions | ||
| permissions: multisig.types.Permissions.all(), | ||
| }, | ||
|
|
||
| ], | ||
| // This means that there needs to be 2 votes for a transaction proposal to be approved | ||
| threshold: 1, | ||
| // This is for the program config treasury account | ||
| treasury: configTreasury, | ||
| // Rent reclaim account | ||
| rentCollector: null | ||
| })), [authority, createKey]); | ||
|
|
||
| return multisigPda as PublicKey; | ||
|
|
||
| } | ||
|
|
||
| export const squadsFixture = async (initSlot?: bigint) => { | ||
| const { provider, context, accounts } = await initBankrun(10, initSlot, [{ | ||
| name: 'external/squads', | ||
| programId: SQUADS_PROGRAM_ID, | ||
| }]); | ||
|
|
||
| const [authority, ...regularAccounts] = accounts; | ||
|
|
||
|
|
||
| const mockAccounts = [{ | ||
| data: Buffer.from('xNJa55CVjD92Raz2HiWPdZHPcd7iP2i7V0ot8H6/wFdsT5Tc2zbKegAAAAAAAAAAPpPXMsRIJCeQ0tu1MaQKvRnxbFXjEyz/UnetydaTq1oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', | ||
| 'base64'), | ||
kostyamospan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| publicKey: new PublicKey('BSTq9w3kZwNwpBXJEvTZz2G9ZTNyKBvoSeXMvwb4cNZr'), | ||
| owner: SQUADS_PROGRAM_ID, | ||
| }] | ||
|
|
||
| for (const account of mockAccounts) { | ||
| context.setAccount(account.publicKey, { | ||
| data: account.data, | ||
| owner: account.owner, | ||
| lamports: 10000, | ||
| executable: false | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| const multisigPda = await createMultisig(context, { | ||
| authority, | ||
| connection: provider.connection, | ||
| }); | ||
|
|
||
| const multisigSignerPda = await createMultisig(context, { | ||
| authority, | ||
| connection: provider.connection, | ||
| timelock: 0n | ||
| }); | ||
|
|
||
| const multisigWithSquadsSignerPda = await createMultisig(context, { | ||
| authority, | ||
| connection: provider.connection, | ||
| member: multisigSignerPda | ||
| }); | ||
|
|
||
| const squadsConnection = provider.connection as any; | ||
kostyamospan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return { | ||
| provider, | ||
| context, | ||
| authority, | ||
| multisigPda, | ||
| regularAccounts, | ||
| squadsConnection, | ||
| accounts, | ||
| multisigSignerPda, | ||
| multisigWithSquadsSignerPda, | ||
| getMutlisigData: async (pda?: PublicKey) => { | ||
| return await multisig.accounts.Multisig.fromAccountAddress( | ||
| squadsConnection, | ||
| pda ?? multisigPda | ||
| ); | ||
| } | ||
| }; | ||
| }; | ||
|
|
||
| export type SquadsFixtureReturnType = Awaited<ReturnType<typeof squadsFixture>>; | ||
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.