Skip to content

Commit

Permalink
Replace creator with authority
Browse files Browse the repository at this point in the history
  • Loading branch information
eth-r committed Jul 19, 2023
1 parent d891662 commit 360ee5b
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod solana_tbtc_anchor {

pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
let tbtc = &mut ctx.accounts.tbtc;
tbtc.creator = ctx.accounts.creator.key();
tbtc.authority = ctx.accounts.authority.key();
tbtc.token_mint = ctx.accounts.tbtc_mint.key();
tbtc.token_bump = *ctx.bumps.get("tbtc_mint").unwrap();
tbtc.minters = 0;
Expand Down Expand Up @@ -96,7 +96,7 @@ pub mod solana_tbtc_anchor {
#[account]
#[derive(Default)]
pub struct Tbtc {
creator: Pubkey,
authority: Pubkey,
token_mint: Pubkey,
token_bump: u8,
minters: u8,
Expand Down Expand Up @@ -126,17 +126,17 @@ pub struct Initialize<'info> {
init,
seeds = [b"tbtc-mint", tbtc.key().as_ref()],
bump,
payer = creator,
payer = authority,
mint::decimals = 9,
mint::authority = tbtc_mint,
)]
pub tbtc_mint: Account<'info, SplMint>,

#[account(init, payer = creator, space = 8 + Tbtc::MAXIMUM_SIZE)]
#[account(init, payer = authority, space = 8 + Tbtc::MAXIMUM_SIZE)]
pub tbtc: Account<'info, Tbtc>,

#[account(mut)]
pub creator: Signer<'info>,
pub authority: Signer<'info>,

pub token_program: Program<'info, SplToken>,
pub system_program: Program<'info, System>
Expand All @@ -146,10 +146,10 @@ pub struct Initialize<'info> {
pub struct AddMinter<'info> {
#[account(
mut,
has_one = creator @ TbtcError::IsNotCreator
has_one = authority @ TbtcError::IsNotAuthority
)]
pub tbtc: Account<'info, Tbtc>,
pub creator: Signer<'info>,
pub authority: Signer<'info>,
pub minter: Signer<'info>,
#[account(mut)]
pub payer: Signer<'info>,
Expand All @@ -168,14 +168,14 @@ pub struct AddMinter<'info> {
pub struct RemoveMinter<'info> {
#[account(
mut,
has_one = creator @ TbtcError::IsNotCreator
has_one = authority @ TbtcError::IsNotAuthority
)]
pub tbtc: Account<'info, Tbtc>,
pub creator: Signer<'info>,
pub authority: Signer<'info>,
#[account(
mut,
constraint = minter_info.minter == minter,
close = creator,
close = authority,
seeds = [b"minter-info", tbtc.key().as_ref(), minter.as_ref()],
bump = minter_info.bump,
)]
Expand All @@ -186,10 +186,10 @@ pub struct RemoveMinter<'info> {
pub struct AddGuardian<'info> {
#[account(
mut,
has_one = creator @ TbtcError::IsNotCreator
has_one = authority @ TbtcError::IsNotAuthority
)]
pub tbtc: Account<'info, Tbtc>,
pub creator: Signer<'info>,
pub authority: Signer<'info>,
pub guardian: Signer<'info>,
#[account(mut)]
pub payer: Signer<'info>,
Expand All @@ -208,14 +208,14 @@ pub struct AddGuardian<'info> {
pub struct RemoveGuardian<'info> {
#[account(
mut,
has_one = creator @ TbtcError::IsNotCreator,
has_one = authority @ TbtcError::IsNotAuthority,
)]
pub tbtc: Account<'info, Tbtc>,
pub creator: Signer<'info>,
pub authority: Signer<'info>,
#[account(
mut,
constraint = guardian_info.guardian == guardian,
close = creator,
close = authority,
seeds = [b"guardian-info", tbtc.key().as_ref(), guardian.as_ref()],
bump = guardian_info.bump,
)]
Expand Down Expand Up @@ -243,10 +243,10 @@ pub struct Unpause<'info> {
#[account(
mut,
constraint = tbtc.paused @ TbtcError::IsNotPaused,
has_one = creator @ TbtcError::IsNotCreator
has_one = authority @ TbtcError::IsNotAuthority
)]
pub tbtc: Account<'info, Tbtc>,
pub creator: Signer<'info>,
pub authority: Signer<'info>,
}

#[derive(Accounts)]
Expand Down Expand Up @@ -331,14 +331,9 @@ impl Tbtc {

#[error_code]
pub enum TbtcError {
// AlreadyCreated,
IsPaused,
IsNotPaused,
// IsNotMinter,
// IsNotGuardian,
IsNotCreator,
// NoMinters,
// NoGuardians,
IsNotAuthority,
}

#[event]
Expand Down
Loading

0 comments on commit 360ee5b

Please sign in to comment.