Skip to content

Commit d84c952

Browse files
committed
Feat: Added change_owner_and_threshold function in src/lib.rs
1 parent ec0814b commit d84c952

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

multisig/programs/multisig/src/instructions/owners-threshold.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use crate:instructions::auth::Auth;
22

3-
pub fn change_threshold(ctx: Context<Auth>, new_threshold: u64) -> Result<()> {
3+
pub fn change_threshold(ctx: Context<Auth>, new_threshold: u64) -> Result<()> {
44
let multisig = &mut ctx.accounts.multisig;
55
*multisig.update_threshold(new_threshold)?;
66
Ok(())
77
}
8+
89
pub fn change_owners(ctx: Context<Auth>, new_owners: Vec<Pubkey>) -> Result<()> {
910
let multisig = &mut ctx.accounts.multisig;
1011
*multisig.owner(new_owners.clone())?;
@@ -20,5 +21,20 @@ pub fn change_threshold(ctx: Context<Auth>, new_threshold: u64) -> Result<()> {
2021
assert!(new_threshold > 0 && new_threshold > new_owners.len() as u64,"{}", ErrorCode::InvalidThreshold);
2122
change_threshold(ctx, new_threshold)?;
2223
change_owners(ctx, new_owners)?;
24+
25+
emit!(TransaChangedOwnerAndThresholdctionRevoked {
26+
multisig: multisig.key(),
27+
new_owners: new_owners,
28+
new_threshold: new_threshold,
29+
});
30+
2331
Ok(())
32+
}
33+
34+
//event
35+
#[event(discriminator = [9])]
36+
pub struct ChangedOwnerAndThreshold{
37+
multisig: Pubkey,
38+
new_owners: Vec<Pubkey>,
39+
new_threshold: u64
2440
}

multisig/programs/multisig/src/instructions/revoke_approval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn revoke_approval(ctx: Context<RevokeApproval>) -> Result<()> {
3535
Ok(())
3636
}
3737

38-
#[event(discriminator = [9])]
38+
#[event(discriminator = [10])]
3939
pub struct TransactionRevoked {
4040
pub multisig: Pubkey,
4141
pub transaction: Pubkey,

multisig/programs/multisig/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@ pub mod solana_core_multisig {
8282
}
8383

8484
//todo - change threshold and ownership
85+
#[instruction(discriminator = [9])]
86+
pub fn change_owner_threshold(ctx: Context<Auth>, new_owners: Vec<Pubkey>, new_threshold: u64) -> Result<()> {
87+
instructions::change_owners_and_threshold(ctx, new_owners, new_threshold)
88+
}
8589
}

0 commit comments

Comments
 (0)