Skip to content

Commit 0ed2e05

Browse files
committed
solana: store custody account in config
1 parent 49d5ab0 commit 0ed2e05

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

solana/programs/example-native-token-transfers/src/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub struct Config {
3535
pub enabled_transceivers: Bitmap,
3636
/// Pause the program. This is useful for upgrades and other maintenance.
3737
pub paused: bool,
38+
/// The custody account that holds tokens in locking mode.
39+
pub custody: Pubkey,
3840
}
3941

4042
impl Config {

solana/programs/example-native-token-transfers/src/instructions/initialize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::{
1212
queue::{outbox::OutboxRateLimit, rate_limit::RateLimitState},
1313
};
1414

15-
// TODO: upgradeability
1615
#[derive(Accounts)]
1716
#[instruction(args: InitializeArgs)]
1817
pub struct Initialize<'info> {
@@ -102,6 +101,7 @@ pub fn initialize(ctx: Context<Initialize>, args: InitializeArgs) -> Result<()>
102101
// NOTE: can't be changed for now
103102
threshold: 1,
104103
enabled_transceivers: Bitmap::new(),
104+
custody: ctx.accounts.custody.key(),
105105
});
106106

107107
ctx.accounts.rate_limit.set_inner(OutboxRateLimit {

solana/programs/example-native-token-transfers/src/instructions/release_inbound.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ pub struct ReleaseInboundUnlock<'info> {
104104
common: ReleaseInbound<'info>,
105105

106106
/// CHECK: the token program checks if this indeed the right authority for the mint
107-
#[account(mut)]
107+
#[account(
108+
mut,
109+
address = common.config.custody
110+
)]
108111
pub custody: InterfaceAccount<'info, token_interface::TokenAccount>,
109112
}
110113

solana/programs/example-native-token-transfers/src/instructions/transfer.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ pub struct TransferLock<'info> {
171171

172172
#[account(
173173
mut,
174-
token::mint = common.mint,
175-
token::authority = common.token_authority,
174+
address = common.config.custody
176175
)]
177176
pub custody: InterfaceAccount<'info, token_interface::TokenAccount>,
178177
}

0 commit comments

Comments
 (0)