Further harmonizing of PDA seeds

This commit is contained in:
Christian Kamm 2022-03-14 13:39:54 +01:00
parent 71cd1755ec
commit 07c9b9de7e
8 changed files with 17 additions and 17 deletions

View File

@ -10,7 +10,7 @@ pub struct CreateAccount<'info> {
#[account(
init,
seeds = [group.key().as_ref(), b"account".as_ref(), owner.key().as_ref(), &account_num.to_le_bytes()],
seeds = [group.key().as_ref(), b"MangoAccount".as_ref(), owner.key().as_ref(), &account_num.to_le_bytes()],
bump,
payer = payer,
space = 8 + std::mem::size_of::<MangoAccount>(),

View File

@ -7,7 +7,7 @@ use crate::state::*;
pub struct CreateGroup<'info> {
#[account(
init,
seeds = [b"group".as_ref(), admin.key().as_ref()],
seeds = [b"Group".as_ref(), admin.key().as_ref()],
bump,
payer = payer,
space = 8 + std::mem::size_of::<Group>(),

View File

@ -8,7 +8,7 @@ use crate::state::*;
pub struct CreateStubOracle<'info> {
#[account(
init,
seeds = [b"stub_oracle".as_ref(), token_mint.key().as_ref()],
seeds = [b"StubOracle".as_ref(), token_mint.key().as_ref()],
bump,
payer = payer,
space = 8 + std::mem::size_of::<StubOracle>(),

View File

@ -19,7 +19,7 @@ pub struct RegisterSerumMarket<'info> {
#[account(
init,
// TODO: possibly use the market index instead of serum_market in the seed
seeds = [group.key().as_ref(), b"serum".as_ref(), serum_market_external.key().as_ref()],
seeds = [group.key().as_ref(), b"SerumMarket".as_ref(), serum_market_external.key().as_ref()],
bump,
payer = payer,
space = 8 + std::mem::size_of::<SerumMarket>(),

View File

@ -23,7 +23,7 @@ pub struct RegisterToken<'info> {
#[account(
init,
seeds = [group.key().as_ref(), b"TokenBank".as_ref(), &token_index.to_le_bytes()],
seeds = [group.key().as_ref(), b"Bank".as_ref(), &token_index.to_le_bytes()],
bump,
payer = payer,
space = 8 + std::mem::size_of::<Bank>(),
@ -32,7 +32,7 @@ pub struct RegisterToken<'info> {
#[account(
init,
seeds = [group.key().as_ref(), b"TokenVault".as_ref(), &token_index.to_le_bytes()],
seeds = [group.key().as_ref(), b"Vault".as_ref(), &token_index.to_le_bytes()],
bump,
token::authority = group,
token::mint = mint,

View File

@ -39,7 +39,7 @@ pub struct Group {
#[macro_export]
macro_rules! group_seeds {
( $group:expr ) => {
&[b"group".as_ref(), $group.admin.as_ref(), &[$group.bump]]
&[b"Group".as_ref(), $group.admin.as_ref(), &[$group.bump]]
};
}

View File

@ -23,7 +23,7 @@ macro_rules! serum_market_seeds {
( $acc:expr ) => {
&[
$acc.group.as_ref(),
b"serum".as_ref(),
b"SerumMarket".as_ref(),
$acc.serum_market_external.as_ref(),
&[$acc.bump],
]

View File

@ -86,7 +86,7 @@ async fn get_mint_info_by_token_index(
let bank_pk = Pubkey::find_program_address(
&[
account.group.as_ref(),
b"TokenBank".as_ref(),
b"Bank".as_ref(),
&token_index.to_le_bytes(),
],
&mango_v4::id(),
@ -387,7 +387,7 @@ impl<'keypair> ClientInstruction for RegisterTokenInstruction<'keypair> {
let bank = Pubkey::find_program_address(
&[
self.group.as_ref(),
b"TokenBank".as_ref(),
b"Bank".as_ref(),
&self.token_index.to_le_bytes(),
],
&program_id,
@ -396,7 +396,7 @@ impl<'keypair> ClientInstruction for RegisterTokenInstruction<'keypair> {
let vault = Pubkey::find_program_address(
&[
self.group.as_ref(),
b"TokenVault".as_ref(),
b"Vault".as_ref(),
&self.token_index.to_le_bytes(),
],
&program_id,
@ -412,7 +412,7 @@ impl<'keypair> ClientInstruction for RegisterTokenInstruction<'keypair> {
)
.0;
let oracle = Pubkey::find_program_address(
&[b"stub_oracle".as_ref(), self.mint.as_ref()],
&[b"StubOracle".as_ref(), self.mint.as_ref()],
&program_id,
)
.0;
@ -462,7 +462,7 @@ impl<'keypair> ClientInstruction for SetStubOracle<'keypair> {
};
let oracle = Pubkey::find_program_address(
&[b"stub_oracle".as_ref(), self.mint.as_ref()],
&[b"StubOracle".as_ref(), self.mint.as_ref()],
&program_id,
)
.0;
@ -497,7 +497,7 @@ impl<'keypair> ClientInstruction for CreateStubOracle<'keypair> {
};
let oracle = Pubkey::find_program_address(
&[b"stub_oracle".as_ref(), self.mint.as_ref()],
&[b"StubOracle".as_ref(), self.mint.as_ref()],
&program_id,
)
.0;
@ -534,7 +534,7 @@ impl<'keypair> ClientInstruction for CreateGroupInstruction<'keypair> {
let instruction = Self::Instruction {};
let group = Pubkey::find_program_address(
&[b"group".as_ref(), self.admin.pubkey().as_ref()],
&[b"Group".as_ref(), self.admin.pubkey().as_ref()],
&program_id,
)
.0;
@ -578,7 +578,7 @@ impl<'keypair> ClientInstruction for CreateAccountInstruction<'keypair> {
let account = Pubkey::find_program_address(
&[
self.group.as_ref(),
b"account".as_ref(),
b"MangoAccount".as_ref(),
self.owner.pubkey().as_ref(),
&self.account_num.to_le_bytes(),
],
@ -631,7 +631,7 @@ impl<'keypair> ClientInstruction for RegisterSerumMarketInstruction<'keypair> {
let serum_market = Pubkey::find_program_address(
&[
self.group.as_ref(),
b"serum".as_ref(),
b"SerumMarket".as_ref(),
self.serum_market_external.as_ref(),
],
&program_id,