Skip to content

Commit 8b08475

Browse files
committed
Refactor PDA seed definitions
1 parent c689777 commit 8b08475

28 files changed

+113
-79
lines changed

programs/inference-staking/src/instructions/operator_pool/change_operator_admin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct ChangeOperatorAdmin<'info> {
1212
pub new_admin: Signer<'info>,
1313

1414
#[account(
15-
seeds = [b"PoolOverview".as_ref()],
15+
seeds = [PoolOverview::SEED],
1616
bump = pool_overview.bump,
1717
constraint = !pool_overview.is_epoch_finalizing @ ErrorCode::EpochMustNotBeFinalizing,
1818
)]
@@ -21,7 +21,7 @@ pub struct ChangeOperatorAdmin<'info> {
2121
#[account(
2222
mut,
2323
seeds = [
24-
b"OperatorPool".as_ref(),
24+
OperatorPool::SEED,
2525
operator_pool.initial_pool_admin.as_ref(),
2626
],
2727
bump = operator_pool.bump,

programs/inference-staking/src/instructions/operator_pool/change_operator_staking_record.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ pub struct ChangeOperatorStakingRecord<'info> {
1616
pub owner: Signer<'info>,
1717

1818
#[account(
19-
seeds = [b"PoolOverview".as_ref()],
19+
seeds = [PoolOverview::SEED],
2020
bump = pool_overview.bump,
2121
)]
2222
pub pool_overview: Account<'info, PoolOverview>,
2323

2424
#[account(
2525
mut,
2626
seeds = [
27-
b"OperatorPool".as_ref(),
27+
OperatorPool::SEED,
2828
operator_pool.initial_pool_admin.as_ref(),
2929
],
3030
bump = operator_pool.bump,
@@ -39,7 +39,7 @@ pub struct ChangeOperatorStakingRecord<'info> {
3939
pub operator_staking_record: Account<'info, StakingRecord>,
4040

4141
#[account(
42-
seeds = [b"StakingRecord".as_ref(), operator_pool.key().as_ref(), owner.key().as_ref()],
42+
seeds = [StakingRecord::SEED, operator_pool.key().as_ref(), owner.key().as_ref()],
4343
bump,
4444
has_one = owner,
4545
has_one = operator_pool,

programs/inference-staking/src/instructions/operator_pool/close_operator_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct CloseOperatorPool<'info> {
1010
pub admin: Signer<'info>,
1111

1212
#[account(
13-
seeds = [b"PoolOverview".as_ref()],
13+
seeds = [PoolOverview::SEED],
1414
bump = pool_overview.bump,
1515
)]
1616
pub pool_overview: Box<Account<'info, PoolOverview>>,

programs/inference-staking/src/instructions/operator_pool/create_operator_pool.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct CreateOperatorPool<'info> {
1919
#[account(
2020
init,
2121
seeds = [
22-
b"OperatorPool".as_ref(),
22+
OperatorPool::SEED,
2323
admin.key().as_ref(),
2424
],
2525
bump,
@@ -31,7 +31,7 @@ pub struct CreateOperatorPool<'info> {
3131
#[account(
3232
init,
3333
seeds = [
34-
b"StakingRecord".as_ref(),
34+
StakingRecord::SEED,
3535
operator_pool.key().as_ref(),
3636
admin.key().as_ref()
3737
],
@@ -43,7 +43,7 @@ pub struct CreateOperatorPool<'info> {
4343

4444
#[account(
4545
mut,
46-
seeds = [b"PoolOverview".as_ref()],
46+
seeds = [PoolOverview::SEED],
4747
bump = pool_overview.bump,
4848
has_one = mint,
4949
constraint = pool_overview.allow_pool_creation @ ErrorCode::PoolCreationDisabled,
@@ -52,7 +52,7 @@ pub struct CreateOperatorPool<'info> {
5252

5353
#[account(
5454
init,
55-
seeds = [b"PoolStakedTokenVault".as_ref(), operator_pool.key().as_ref()],
55+
seeds = [OperatorPool::POOL_STAKED_TOKEN_VAULT_SEED, operator_pool.key().as_ref()],
5656
bump,
5757
payer = payer,
5858
token::mint = mint,
@@ -62,7 +62,7 @@ pub struct CreateOperatorPool<'info> {
6262

6363
#[account(
6464
init,
65-
seeds = [b"PoolRewardCommissionTokenVault".as_ref(), operator_pool.key().as_ref()],
65+
seeds = [OperatorPool::POOL_REWARD_COMMISSION_TOKEN_VAULT_SEED, operator_pool.key().as_ref()],
6666
bump,
6767
payer = payer,
6868
token::mint = mint,
@@ -72,7 +72,7 @@ pub struct CreateOperatorPool<'info> {
7272

7373
#[account(
7474
init,
75-
seeds = [b"PoolUsdcCommissionTokenVault".as_ref(), operator_pool.key().as_ref()],
75+
seeds = [OperatorPool::POOL_USDC_COMMISSION_TOKEN_VAULT_SEED, operator_pool.key().as_ref()],
7676
bump,
7777
payer = payer,
7878
token::mint = usdc_mint,
@@ -82,7 +82,7 @@ pub struct CreateOperatorPool<'info> {
8282

8383
#[account(
8484
init,
85-
seeds = [b"PoolDelegatorUsdcEarningsVault".as_ref(), operator_pool.key().as_ref()],
85+
seeds = [OperatorPool::POOL_DELEGATOR_USDC_EARNINGS_VAULT_SEED, operator_pool.key().as_ref()],
8686
bump,
8787
payer = payer,
8888
token::mint = usdc_mint,

programs/inference-staking/src/instructions/operator_pool/set_halt_status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct SetHaltStatus<'info> {
1010
pub authority: Signer<'info>,
1111

1212
#[account(
13-
seeds = [b"PoolOverview".as_ref()],
13+
seeds = [PoolOverview::SEED],
1414
bump = pool_overview.bump,
1515
constraint = pool_overview.halt_authorities.contains(authority.key)
1616
@ ErrorCode::InvalidHaltAuthority,
@@ -19,7 +19,7 @@ pub struct SetHaltStatus<'info> {
1919

2020
#[account(
2121
mut,
22-
seeds = [b"OperatorPool".as_ref(), operator_pool.initial_pool_admin.as_ref()],
22+
seeds = [OperatorPool::SEED, operator_pool.initial_pool_admin.as_ref()],
2323
bump = operator_pool.bump,
2424
)]
2525
pub operator_pool: Account<'info, OperatorPool>,

programs/inference-staking/src/instructions/operator_pool/slash_stake.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct SlashStake<'info> {
1515
pub authority: Signer<'info>,
1616

1717
#[account(
18-
seeds = [b"PoolOverview".as_ref()],
18+
seeds = [PoolOverview::SEED],
1919
bump = pool_overview.bump,
2020
constraint = pool_overview.slashing_authorities.contains(authority.key)
2121
@ ErrorCode::InvalidSlashingAuthority,
@@ -24,7 +24,7 @@ pub struct SlashStake<'info> {
2424

2525
#[account(
2626
mut,
27-
seeds = [b"OperatorPool".as_ref(), operator_pool.initial_pool_admin.as_ref()],
27+
seeds = [OperatorPool::SEED, operator_pool.initial_pool_admin.as_ref()],
2828
bump = operator_pool.bump,
2929
)]
3030
pub operator_pool: Account<'info, OperatorPool>,
@@ -37,28 +37,28 @@ pub struct SlashStake<'info> {
3737

3838
#[account(
3939
mut,
40-
seeds = [b"PoolStakedTokenVault".as_ref(), operator_pool.key().as_ref()],
40+
seeds = [OperatorPool::POOL_STAKED_TOKEN_VAULT_SEED, operator_pool.key().as_ref()],
4141
bump,
4242
)]
4343
pub staked_token_account: Account<'info, TokenAccount>,
4444

4545
#[account(
4646
mut,
47-
seeds = [b"PoolDelegatorUsdcEarningsVault", operator_pool.key().as_ref()],
47+
seeds = [OperatorPool::POOL_DELEGATOR_USDC_EARNINGS_VAULT_SEED, operator_pool.key().as_ref()],
4848
bump,
4949
)]
5050
pub pool_usdc_vault: Account<'info, TokenAccount>,
5151

5252
#[account(
5353
mut,
54-
seeds = [b"PoolRewardCommissionTokenVault".as_ref(), operator_pool.key().as_ref()],
54+
seeds = [OperatorPool::POOL_REWARD_COMMISSION_TOKEN_VAULT_SEED, operator_pool.key().as_ref()],
5555
bump,
5656
)]
5757
pub reward_fee_token_account: Account<'info, TokenAccount>,
5858

5959
#[account(
6060
mut,
61-
seeds = [b"PoolUsdcCommissionTokenVault".as_ref(), operator_pool.key().as_ref()],
61+
seeds = [OperatorPool::POOL_USDC_COMMISSION_TOKEN_VAULT_SEED, operator_pool.key().as_ref()],
6262
bump,
6363
)]
6464
pub usdc_fee_token_account: Account<'info, TokenAccount>,

programs/inference-staking/src/instructions/operator_pool/sweep_closed_pool_usdc_dust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct SweepClosedPoolUsdcDust<'info> {
2727
#[account(
2828
mut,
2929
// This is the vault we are sweeping.
30-
seeds = [b"PoolDelegatorUsdcEarningsVault".as_ref(), operator_pool.key().as_ref()],
30+
seeds = [OperatorPool::POOL_DELEGATOR_USDC_EARNINGS_VAULT_SEED, operator_pool.key().as_ref()],
3131
bump,
3232
)]
3333
pub operator_usdc_vault: Account<'info, TokenAccount>,
@@ -40,7 +40,7 @@ pub struct SweepClosedPoolUsdcDust<'info> {
4040
pub admin_usdc_account: Account<'info, TokenAccount>,
4141

4242
#[account(
43-
seeds = [b"PoolOverview".as_ref()],
43+
seeds = [PoolOverview::SEED],
4444
bump = pool_overview.bump,
4545
)]
4646
pub pool_overview: Account<'info, PoolOverview>,

programs/inference-staking/src/instructions/operator_pool/update_operator_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct UpdateOperatorPool<'info> {
99
#[account(
1010
mut,
1111
seeds = [
12-
b"OperatorPool".as_ref(),
12+
OperatorPool::SEED,
1313
operator_pool.initial_pool_admin.as_ref(),
1414
],
1515
bump = operator_pool.bump,

programs/inference-staking/src/instructions/operator_pool/withdraw_operator_reward_commission.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ pub struct WithdrawOperatorRewardCommission<'info> {
1414
pub admin: Signer<'info>,
1515

1616
#[account(
17-
seeds = [b"PoolOverview".as_ref()],
17+
seeds = [PoolOverview::SEED],
1818
bump = pool_overview.bump,
1919
)]
2020
pub pool_overview: Account<'info, PoolOverview>,
2121

2222
#[account(
23-
seeds = [b"OperatorPool".as_ref(), operator_pool.initial_pool_admin.as_ref()],
23+
seeds = [OperatorPool::SEED, operator_pool.initial_pool_admin.as_ref()],
2424
bump = operator_pool.bump,
2525
// Admin must sign to invoke this instruction
2626
has_one = admin,
@@ -29,7 +29,7 @@ pub struct WithdrawOperatorRewardCommission<'info> {
2929

3030
#[account(
3131
mut,
32-
seeds = [b"PoolRewardCommissionTokenVault".as_ref(), operator_pool.key().as_ref()],
32+
seeds = [OperatorPool::POOL_REWARD_COMMISSION_TOKEN_VAULT_SEED, operator_pool.key().as_ref()],
3333
bump,
3434
)]
3535
pub reward_fee_token_account: Account<'info, TokenAccount>,

programs/inference-staking/src/instructions/operator_pool/withdraw_operator_usdc_commission.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ pub struct WithdrawOperatorUsdcCommission<'info> {
1414
pub admin: Signer<'info>,
1515

1616
#[account(
17-
seeds = [b"PoolOverview".as_ref()],
17+
seeds = [PoolOverview::SEED],
1818
bump = pool_overview.bump,
1919
)]
2020
pub pool_overview: Account<'info, PoolOverview>,
2121

2222
#[account(
23-
seeds = [b"OperatorPool".as_ref(), operator_pool.initial_pool_admin.as_ref()],
23+
seeds = [OperatorPool::SEED, operator_pool.initial_pool_admin.as_ref()],
2424
bump = operator_pool.bump,
2525
// Admin must sign to invoke this instruction
2626
has_one = admin,
@@ -29,7 +29,7 @@ pub struct WithdrawOperatorUsdcCommission<'info> {
2929

3030
#[account(
3131
mut,
32-
seeds = [b"PoolUsdcCommissionTokenVault".as_ref(), operator_pool.key().as_ref()],
32+
seeds = [OperatorPool::POOL_USDC_COMMISSION_TOKEN_VAULT_SEED, operator_pool.key().as_ref()],
3333
bump,
3434
)]
3535
pub usdc_fee_token_account: Account<'info, TokenAccount>,

0 commit comments

Comments
 (0)