Skip to content

Commit

Permalink
solana: reformat; pin solana to 1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
a5-pickle committed Jul 31, 2023
1 parent 642e60a commit c4e9bc8
Show file tree
Hide file tree
Showing 23 changed files with 1,390 additions and 4,996 deletions.
601 changes: 140 additions & 461 deletions cross-chain/solana/Cargo.lock

Large diffs are not rendered by default.

1,947 changes: 0 additions & 1,947 deletions cross-chain/solana/package-lock.json

This file was deleted.

5 changes: 3 additions & 2 deletions cross-chain/solana/programs/tbtc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = { version = "0.28.0", features = ["init-if-needed"] }
anchor-spl = "0.28.0"
anchor-lang = { version = "=0.28.0", features = ["derive", "init-if-needed"] }
anchor-spl = "=0.28.0"
solana-program = "=1.14.20"
2 changes: 1 addition & 1 deletion cross-chain/solana/programs/tbtc/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anchor_lang::prelude::constant;

#[constant]
pub const SEED_PREFIX_TBTC_MINT: &[u8] = b"tbtc-mint";
pub const SEED_PREFIX_TBTC_MINT: &[u8] = b"tbtc-mint";
57 changes: 18 additions & 39 deletions cross-chain/solana/programs/tbtc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,76 +1,55 @@
use anchor_lang::prelude::*;

mod constants;
pub use constants::*;
pub use error::*;
pub(crate) use processor::*;
pub use state::*;

pub mod constants;
pub mod error;

mod processor;
pub mod state;
pub(crate) use processor::*;

mod state;
pub use state::*;

use anchor_lang::prelude::*;

declare_id!("HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG");

#[program]
pub mod tbtc {
use super::*;

pub fn initialize(
ctx: Context<Initialize>,
) -> Result<()> {

pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
processor::initialize(ctx)
}

pub fn change_authority(
ctx: Context<ChangeAuthority>,
) -> Result<()> {
pub fn change_authority(ctx: Context<ChangeAuthority>) -> Result<()> {
processor::change_authority(ctx)
}

pub fn add_minter(
ctx: Context<AddMinter>,
) -> Result<()> {
pub fn add_minter(ctx: Context<AddMinter>) -> Result<()> {
processor::add_minter(ctx)
}

pub fn remove_minter(
ctx: Context<RemoveMinter>,
minter: Pubkey,
) -> Result<()> {
pub fn remove_minter(ctx: Context<RemoveMinter>, minter: Pubkey) -> Result<()> {
processor::remove_minter(ctx, minter)
}

pub fn add_guardian(
ctx: Context<AddGuardian>,
) -> Result<()> {
pub fn add_guardian(ctx: Context<AddGuardian>) -> Result<()> {
processor::add_guardian(ctx)
}

pub fn remove_guardian(
ctx: Context<RemoveGuardian>,
guardian: Pubkey,
) -> Result<()> {
pub fn remove_guardian(ctx: Context<RemoveGuardian>, guardian: Pubkey) -> Result<()> {
processor::remove_guardian(ctx, guardian)
}

pub fn pause(
ctx: Context<Pause>,
) -> Result<()> {
pub fn pause(ctx: Context<Pause>) -> Result<()> {
processor::pause(ctx)
}

pub fn unpause(
ctx: Context<Unpause>,
) -> Result<()> {
pub fn unpause(ctx: Context<Unpause>) -> Result<()> {
processor::unpause(ctx)
}

pub fn mint(
ctx: Context<Mint>,
amount: u64,
) -> Result<()> {
pub fn mint(ctx: Context<Mint>, amount: u64) -> Result<()> {
processor::mint(ctx, amount)
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error::TbtcError,
state::{Tbtc, GuardianInfo},
state::{GuardianInfo, Tbtc},
};
use anchor_lang::prelude::*;

Expand Down Expand Up @@ -33,4 +33,4 @@ pub fn add_guardian(ctx: Context<AddGuardian>) -> Result<()> {

ctx.accounts.tbtc.guardians += 1;
Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error::TbtcError,
state::{Tbtc, MinterInfo},
state::{MinterInfo, Tbtc},
};
use anchor_lang::prelude::*;

Expand Down Expand Up @@ -33,4 +33,4 @@ pub fn add_minter(ctx: Context<AddMinter>) -> Result<()> {

ctx.accounts.tbtc.minters += 1;
Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::{
error::TbtcError,
state::{Tbtc},
};
use crate::{error::TbtcError, state::Tbtc};
use anchor_lang::prelude::*;

#[derive(Accounts)]
Expand All @@ -20,4 +17,4 @@ pub struct ChangeAuthority<'info> {
pub fn change_authority(ctx: Context<ChangeAuthority>) -> Result<()> {
ctx.accounts.tbtc.authority = ctx.accounts.new_authority.key();
Ok(())
}
}
18 changes: 5 additions & 13 deletions cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
use crate::{
constants::SEED_PREFIX_TBTC_MINT,
state::{Tbtc},
};
use crate::{constants::SEED_PREFIX_TBTC_MINT, state::Tbtc};
use anchor_lang::prelude::*;
use anchor_spl::{
token,
};



use anchor_spl::token;

#[derive(Accounts)]
pub struct Initialize<'info> {
Expand All @@ -29,9 +21,9 @@ pub struct Initialize<'info> {

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

pub token_program: Program<'info, token::Token>,
pub system_program: Program<'info, System>
pub system_program: Program<'info, System>,
}

pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
Expand All @@ -44,4 +36,4 @@ pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
paused: false,
});
Ok(())
}
}
24 changes: 15 additions & 9 deletions cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
mod add_guardian;
mod add_minter;
mod change_authority;
mod initialize;
mod pause;
mod remove_guardian;
mod remove_minter;
mod unpause;

pub use add_guardian::*;

mod add_minter;
pub use add_minter::*;

mod change_authority;
pub use change_authority::*;

mod initialize;
pub use initialize::*;

mod pause;
pub use pause::*;

mod remove_guardian;
pub use remove_guardian::*;

mod remove_minter;
pub use remove_minter::*;
pub use unpause::*;

mod unpause;
pub use unpause::*;
4 changes: 2 additions & 2 deletions cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error::TbtcError,
state::{Tbtc, GuardianInfo},
state::{GuardianInfo, Tbtc},
};
use anchor_lang::prelude::*;

Expand All @@ -23,4 +23,4 @@ pub struct Pause<'info> {
pub fn pause(ctx: Context<Pause>) -> Result<()> {
ctx.accounts.tbtc.paused = true;
Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error::TbtcError,
state::{Tbtc, GuardianInfo},
state::{GuardianInfo, Tbtc},
};
use anchor_lang::prelude::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error::TbtcError,
state::{Tbtc, MinterInfo},
state::{MinterInfo, Tbtc},
};
use anchor_lang::prelude::*;

Expand All @@ -26,4 +26,4 @@ pub struct RemoveMinter<'info> {
pub fn remove_minter(ctx: Context<RemoveMinter>, _minter: Pubkey) -> Result<()> {
ctx.accounts.tbtc.minters -= 1;
Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::{
error::TbtcError,
state::Tbtc,
};
use crate::{error::TbtcError, state::Tbtc};
use anchor_lang::prelude::*;

#[derive(Accounts)]
Expand All @@ -18,4 +15,4 @@ pub struct Unpause<'info> {
pub fn unpause(ctx: Context<Unpause>) -> Result<()> {
ctx.accounts.tbtc.paused = false;
Ok(())
}
}
13 changes: 4 additions & 9 deletions cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use crate::{
constants::SEED_PREFIX_TBTC_MINT,
error::TbtcError,
state::{Tbtc, MinterInfo},
state::{MinterInfo, Tbtc},
};
use anchor_lang::prelude::*;
use anchor_spl::{
associated_token::AssociatedToken,
token,
};
use anchor_spl::{associated_token::AssociatedToken, token};

#[derive(Accounts)]
pub struct Mint<'info> {
Expand Down Expand Up @@ -49,9 +46,7 @@ pub struct Mint<'info> {
/// Validating the recipient is the minter's responsibility.
pub recipient: UncheckedAccount<'info>,

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

pub token_program: Program<'info, token::Token>,
Expand All @@ -75,4 +70,4 @@ pub fn mint(ctx: Context<Mint>, amount: u64) -> Result<()> {
signer,
);
token::mint_to(cpi_ctx, amount)
}
}
3 changes: 1 addition & 2 deletions cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
mod mint;

pub use mint::*;
pub use mint::*;
6 changes: 3 additions & 3 deletions cross-chain/solana/programs/tbtc/src/processor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod admin;
mod mint;

pub use admin::*;
pub use mint::*;

mod mint;
pub use mint::*;
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ impl GuardianInfo {

pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; // discriminator + pubkey + bump
pub const SEED_PREFIX: &'static [u8; 13] = b"guardian-info";
}
}
2 changes: 1 addition & 1 deletion cross-chain/solana/programs/tbtc/src/state/minter_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ impl MinterInfo {

pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; // discriminator + pubkey + bump
pub const SEED_PREFIX: &'static [u8; 11] = b"minter-info";
}
}
2 changes: 1 addition & 1 deletion cross-chain/solana/programs/tbtc/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pub use tbtc::*;

pub mod guardian_info;
pub mod minter_info;
pub mod tbtc;
pub mod tbtc;
3 changes: 1 addition & 2 deletions cross-chain/solana/programs/tbtc/src/state/tbtc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anchor_lang::prelude::*;


#[account]
#[derive(Default)]
pub struct Tbtc {
Expand All @@ -21,4 +20,4 @@ impl Tbtc {
// 1 u8
// 1 bool
pub const MAXIMUM_SIZE: usize = 8 + 32 + 32 + 1 + 1 + 1 + 1;
}
}
File renamed without changes.
Loading

0 comments on commit c4e9bc8

Please sign in to comment.