Skip to content

Commit

Permalink
Revert "Release (#109) - Final V4 Upgrade"
Browse files Browse the repository at this point in the history
This reverts commit 4a39ae1.
  • Loading branch information
0xRigel committed Nov 22, 2024
1 parent 4a39ae1 commit f74aa54
Show file tree
Hide file tree
Showing 70 changed files with 680 additions and 6,291 deletions.
2 changes: 1 addition & 1 deletion Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[toolchain]
anchor_version = "0.29.0" # `anchor-cli` version to use
solana_version = "1.18.16" # Solana version to use
solana_version = "1.17.0" # Solana version to use

[features]
seeds = false
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 27 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
{
"private": true,
"workspaces": [
"sdk/*"
],
"scripts": {
"build": "turbo run build",
"test:detached": "turbo run build && anchor test --detach -- --features=testing && echo \"\n⚠️ Don't forget to recompile the .so file before deployment\n\"",
"test": "turbo run build && anchor test -- --features=testing && echo \"\n⚠️ Don't forget to recompile the .so file before deployment\n\"",
"pretest": "mkdir -p target/deploy && cp ./test-program-keypair.json ./target/deploy/squads_multisig_program-keypair.json",
"ts": "turbo run ts && yarn tsc --noEmit"
},
"devDependencies": {
"@solana/spl-token": "*",
"@solana/spl-memo": "^0.2.3",
"@types/bn.js": "5.1.0",
"@types/mocha": "10.0.1",
"@types/node-fetch": "2.6.2",
"mocha": "10.2.0",
"prettier": "2.6.2",
"ts-node": "10.9.1",
"turbo": "1.6.3",
"typescript": "*"
},
"resolutions": {
"@solana/web3.js": "1.70.3",
"@solana/spl-token": "0.3.6",
"typescript": "4.9.4"
}
"private": true,
"workspaces": [
"sdk/*"
],
"scripts": {
"build": "turbo run build",
"test": "turbo run build && anchor test -- --features=testing && echo \"\n⚠️ Don't forget to recompile the .so file before deployment\n\"",
"pretest": "mkdir -p target/deploy && cp ./test-program-keypair.json ./target/deploy/squads_multisig_program-keypair.json",
"ts": "turbo run ts && yarn tsc --noEmit"
},
"devDependencies": {
"@solana/spl-token": "*",
"@solana/spl-memo": "^0.2.3",
"@types/bn.js": "5.1.0",
"@types/mocha": "10.0.1",
"@types/node-fetch": "2.6.2",
"mocha": "10.2.0",
"prettier": "2.6.2",
"ts-node": "10.9.1",
"turbo": "1.6.3",
"typescript": "*"
},
"resolutions": {
"@solana/web3.js": "1.70.3",
"@solana/spl-token": "0.3.6",
"typescript": "4.9.4"
}
}
5 changes: 2 additions & 3 deletions programs/squads_multisig_program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "squads-multisig-program"
version = "2.1.0"
version = "2.0.0"
description = "Squads Multisig Program V4"
edition = "2021"
license-file = "../../LICENSE"
Expand All @@ -10,13 +10,12 @@ crate-type = ["cdylib", "lib"]
name = "squads_multisig_program"

[features]
default = ["custom-heap"]
custom-heap = []
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
testing = []
default = []

[dependencies]
anchor-lang = { version = "=0.29.0", features = ["allow-missing-optionals"] }
Expand Down
133 changes: 0 additions & 133 deletions programs/squads_multisig_program/src/allocator.rs

This file was deleted.

10 changes: 0 additions & 10 deletions programs/squads_multisig_program/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,4 @@ pub enum MultisigError {
BatchNotEmpty,
#[msg("Invalid SpendingLimit amount")]
SpendingLimitInvalidAmount,
#[msg("Invalid Instruction Arguments")]
InvalidInstructionArgs,
#[msg("Final message buffer hash doesnt match the expected hash")]
FinalBufferHashMismatch,
#[msg("Final buffer size cannot exceed 4000 bytes")]
FinalBufferSizeExceeded,
#[msg("Final buffer size mismatch")]
FinalBufferSizeMismatch,
#[msg("multisig_create has been deprecated. Use multisig_create_v2 instead.")]
MultisigCreateDeprecated,
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ impl BatchExecuteTransaction<'_> {
let multisig = &mut ctx.accounts.multisig;
let proposal = &mut ctx.accounts.proposal;
let batch = &mut ctx.accounts.batch;

// NOTE: After `take()` is called, the VaultTransaction is reduced to
// its default empty value, which means it should no longer be referenced or
// used after this point to avoid faulty behavior.
// Instead only make use of the returned `transaction` value.
let transaction = ctx.accounts.transaction.take();
let transaction = &mut ctx.accounts.transaction;

let multisig_key = multisig.key();
let batch_key = batch.key();
Expand All @@ -126,7 +121,7 @@ impl BatchExecuteTransaction<'_> {
&[batch.vault_bump],
];

let transaction_message = transaction.message;
let transaction_message = &transaction.message;
let num_lookups = transaction_message.address_table_lookups.len();

let message_account_infos = ctx
Expand Down Expand Up @@ -154,13 +149,11 @@ impl BatchExecuteTransaction<'_> {
let protected_accounts = &[proposal.key(), batch_key];

// Execute the transaction message instructions one-by-one.
// NOTE: `execute_message()` calls `self.to_instructions_and_accounts()`
// which in turn calls `take()` on
// `self.message.instructions`, therefore after this point no more
// references or usages of `self.message` should be made to avoid
// faulty behavior.
executable_message.execute_message(
vault_seeds,
&vault_seeds
.iter()
.map(|seed| seed.to_vec())
.collect::<Vec<Vec<u8>>>(),
&ephemeral_signer_seeds,
protected_accounts,
)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ impl<'info> ConfigTransactionExecute<'info> {
members,
destinations,
} => {
// SpendingLimit members must all be members of the multisig.
for sl_member in members.iter() {
require!(
multisig.is_member(*sl_member).is_some(),
MultisigError::NotAMember
);
}

let (spending_limit_key, spending_limit_bump) = Pubkey::find_program_address(
&[
SEED_PREFIX,
Expand Down
12 changes: 2 additions & 10 deletions programs/squads_multisig_program/src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ pub use multisig_add_spending_limit::*;
pub use multisig_config::*;
pub use multisig_create::*;
pub use multisig_remove_spending_limit::*;
pub use program_config::*;
pub use program_config_init::*;
pub use program_config::*;
pub use proposal_activate::*;
pub use proposal_create::*;
pub use proposal_vote::*;
pub use spending_limit_use::*;
pub use transaction_accounts_close::*;
pub use transaction_buffer_close::*;
pub use transaction_buffer_create::*;
pub use transaction_buffer_extend::*;
pub use vault_transaction_create::*;
pub use vault_transaction_create_from_buffer::*;
pub use vault_transaction_execute::*;

mod batch_add_transaction;
Expand All @@ -30,16 +26,12 @@ mod multisig_add_spending_limit;
mod multisig_config;
mod multisig_create;
mod multisig_remove_spending_limit;
mod program_config;
mod program_config_init;
mod program_config;
mod proposal_activate;
mod proposal_create;
mod proposal_vote;
mod spending_limit_use;
mod transaction_accounts_close;
mod transaction_buffer_close;
mod transaction_buffer_create;
mod transaction_buffer_extend;
mod vault_transaction_create;
mod vault_transaction_create_from_buffer;
mod vault_transaction_execute;
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ pub struct MultisigAddSpendingLimitArgs {
/// The reset period of the spending limit.
/// When it passes, the remaining amount is reset, unless it's `Period::OneTime`.
pub period: Period,
/// Members of the Spending Limit that can use it.
/// Don't have to be members of the multisig.
/// Members of the multisig that can use the spending limit.
/// In case a member is removed from the multisig, the spending limit will remain existent
/// (until explicitly deleted), but the removed member will not be able to use it anymore.
pub members: Vec<Pubkey>,
/// The destination addresses the spending limit is allowed to sent funds to.
/// If empty, funds can be sent to any address.
Expand Down Expand Up @@ -72,6 +73,14 @@ impl MultisigAddSpendingLimit<'_> {

// `spending_limit` is partially checked via its seeds.

// SpendingLimit members must all be members of the multisig.
for sl_member in self.spending_limit.members.iter() {
require!(
self.multisig.is_member(*sl_member).is_some(),
MultisigError::NotAMember
);
}

Ok(())
}

Expand All @@ -85,10 +94,6 @@ impl MultisigAddSpendingLimit<'_> {
) -> Result<()> {
let spending_limit = &mut ctx.accounts.spending_limit;

// Make sure there are no duplicate keys in this direct invocation by sorting so the invariant will catch
let mut sorted_members = args.members;
sorted_members.sort();

spending_limit.multisig = ctx.accounts.multisig.key();
spending_limit.create_key = args.create_key;
spending_limit.vault_index = args.vault_index;
Expand All @@ -98,7 +103,7 @@ impl MultisigAddSpendingLimit<'_> {
spending_limit.remaining_amount = args.amount;
spending_limit.last_reset = Clock::get()?.unix_timestamp;
spending_limit.bump = ctx.bumps.spending_limit;
spending_limit.members = sorted_members;
spending_limit.members = args.members;
spending_limit.destinations = args.destinations;

spending_limit.invariant()?;
Expand Down
Loading

0 comments on commit f74aa54

Please sign in to comment.