Skip to content

Commit

Permalink
feat(add_vault): remove the field and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
vovacodes committed Apr 24, 2023
1 parent fb4aa32 commit 38a2e93
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 479 deletions.
11 changes: 0 additions & 11 deletions programs/multisig/src/instructions/config_transaction_execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,6 @@ impl ConfigTransactionExecute<'_> {

multisig.config_updated();
}

ConfigAction::AddVault { new_vault_index } => {
require!(
*new_vault_index == multisig.vault_index.checked_add(1).expect("overflow"),
MultisigError::InvalidVaultIndex
);
multisig.vault_index = *new_vault_index;

multisig.config_updated();
}
}
}

Expand Down Expand Up @@ -177,7 +167,6 @@ fn members_length_after_actions(members_length: usize, actions: &[ConfigAction])
ConfigAction::RemoveMember { .. } => acc.checked_sub(1).expect("overflow"),
ConfigAction::ChangeThreshold { .. } => acc,
ConfigAction::SetTimeLock { .. } => acc,
ConfigAction::AddVault { .. } => acc,
});

let abs_members_delta =
Expand Down
25 changes: 0 additions & 25 deletions programs/multisig/src/instructions/multisig_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,29 +209,4 @@ impl MultisigConfig<'_> {

Ok(())
}

/// Increment the multisig `vault_index`.
/// This doesn't actually "add" a new vault, because vaults are derived from the multisig address and index, so technically
/// they always exist. This just increments the index so that UIs can show the "used" vaults.
///
/// NOTE: This instruction must be called only by the `config_authority` if one is set (Controlled Multisig).
/// Uncontrolled Mustisigs should use `config_transaction_create` instead.
#[access_control(ctx.accounts.validate())]
pub fn multisig_add_vault(ctx: Context<Self>, args: MultisigAddVaultArgs) -> Result<()> {
let multisig = &mut ctx.accounts.multisig;

require!(
args.vault_index == multisig.vault_index.checked_add(1).expect("overflow"),
MultisigError::InvalidVaultIndex
);

multisig.vault_index = args.vault_index;

multisig.invariant()?;

// NOTE: we don't call `multisig.config_updated` here, because this doesn't
// affect the transactions by any means, and really just a UI feature.

Ok(())
}
}
1 change: 0 additions & 1 deletion programs/multisig/src/instructions/multisig_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ impl MultisigCreate<'_> {
multisig.threshold = args.threshold;
multisig.members = members;
multisig.time_lock = args.time_lock;
multisig.vault_index = 0;
multisig.transaction_index = 0;
multisig.stale_transaction_index = 0;
multisig.create_key = ctx.accounts.create_key.to_account_info().key();
Expand Down
13 changes: 0 additions & 13 deletions programs/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ pub mod multisig {
MultisigConfig::multisig_set_config_authority(ctx, args)
}

/// Increment the multisig `vault_index`.
/// This doesn't actually "add" a new vault, because vaults are derived from the multisig address and index, so technically
/// they always exist. This just increments the index so that UIs can show the "used" vaults.
///
/// NOTE: This instruction must be called only by the `config_authority` if one is set (Controlled Multisig).
/// Uncontrolled Mustisigs should use `config_transaction_create` instead.
pub fn multisig_add_vault(
ctx: Context<MultisigConfig>,
args: MultisigAddVaultArgs,
) -> Result<()> {
MultisigConfig::multisig_add_vault(ctx, args)
}

/// Create a new config transaction.
pub fn config_transaction_create(
ctx: Context<ConfigTransactionCreate>,
Expand Down
2 changes: 0 additions & 2 deletions programs/multisig/src/state/config_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@ pub enum ConfigAction {
ChangeThreshold { new_threshold: u16 },
/// Change the `time_lock` of the multisig.
SetTimeLock { new_time_lock: u32 },
/// Increment the `vault_index` of the multisig.
AddVault { new_vault_index: u8 },
}
6 changes: 3 additions & 3 deletions programs/multisig/src/state/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ pub struct Multisig {
/// Last stale transaction index. All transactions up until this index are stale.
/// This index is updated when multisig config (members/threshold/time_lock) changes.
pub stale_transaction_index: u64,
/// Index to track the last created vault for this multisig.
pub vault_index: u8,
/// Reserved for future use.
pub _reserved: u8,
/// Bump for the multisig PDA seed.
pub bump: u8,
/// Members of the multisig.
Expand All @@ -43,7 +43,7 @@ impl Multisig {
4 + // time_lock
8 + // transaction_index
8 + // stale_transaction_index
1 + // vault_index
1 + // _reserved
1 + // bump
4 + // members vector length
members_length * Member::size() // members
Expand Down
67 changes: 2 additions & 65 deletions sdk/multisig/idl/multisig.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,60 +241,6 @@
}
]
},
{
"name": "multisigAddVault",
"docs": [
"Increment the multisig `vault_index`.",
"This doesn't actually \"add\" a new vault, because vaults are derived from the multisig address and index, so technically",
"they always exist. This just increments the index so that UIs can show the \"used\" vaults.",
"",
"NOTE: This instruction must be called only by the `config_authority` if one is set (Controlled Multisig).",
"Uncontrolled Mustisigs should use `config_transaction_create` instead."
],
"accounts": [
{
"name": "multisig",
"isMut": true,
"isSigner": false
},
{
"name": "configAuthority",
"isMut": false,
"isSigner": true,
"docs": [
"Multisig `config_authority` that must authorize the configuration change."
]
},
{
"name": "rentPayer",
"isMut": true,
"isSigner": true,
"isOptional": true,
"docs": [
"The account that will be charged in case the multisig account needs to reallocate space,",
"for example when adding a new member.",
"This is usually the same as `config_authority`, but can be a different account if needed."
]
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false,
"isOptional": true,
"docs": [
"We might need it in case reallocation is needed."
]
}
],
"args": [
{
"name": "args",
"type": {
"defined": "MultisigAddVaultArgs"
}
}
]
},
{
"name": "configTransactionCreate",
"docs": [
Expand Down Expand Up @@ -997,9 +943,9 @@
"type": "u64"
},
{
"name": "vaultIndex",
"name": "reserved",
"docs": [
"Index to track the last created vault for this multisig."
"Reserved for future use."
],
"type": "u8"
},
Expand Down Expand Up @@ -1713,15 +1659,6 @@
"type": "u32"
}
]
},
{
"name": "AddVault",
"fields": [
{
"name": "new_vault_index",
"type": "u8"
}
]
}
]
}
Expand Down
10 changes: 5 additions & 5 deletions sdk/multisig/src/generated/accounts/Multisig.ts

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

1 change: 0 additions & 1 deletion sdk/multisig/src/generated/instructions/index.ts

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

130 changes: 0 additions & 130 deletions sdk/multisig/src/generated/instructions/multisigAddVault.ts

This file was deleted.

Loading

0 comments on commit 38a2e93

Please sign in to comment.