add/join tourneys

This commit is contained in:
Sewmina Dilshan 2024-11-12 20:50:53 +05:30
parent 98969ccb2e
commit e210afd83e
4 changed files with 19 additions and 6 deletions

View File

@ -5,3 +5,6 @@ pub const ID: &str = "";
#[constant] #[constant]
pub const DATA_REGISTRY_SEED:&[u8; 9] = b"sales_reg"; pub const DATA_REGISTRY_SEED:&[u8; 9] = b"sales_reg";
#[constant]
pub const TOURNAMENT_SEED:&[u8; 10] = b"tournament";

View File

@ -1,6 +1,6 @@
use anchor_lang::prelude::*; use anchor_lang::prelude::*;
use crate::{error::CustomErrors, DataRegistry, Tournament, DATA_REGISTRY_SEED}; use crate::{error::CustomErrors, DataRegistry, Tournament, DATA_REGISTRY_SEED, TOURNAMENT_SEED};
pub fn handler(ctx:Context<AddTournament>, id:u64, start_time:String)->Result<()>{ pub fn handler(ctx:Context<AddTournament>, id:u64, start_time:String)->Result<()>{
@ -28,7 +28,7 @@ pub struct AddTournament<'info>{
init, init,
payer= payer, payer= payer,
space = Tournament::INIT_SPACE, space = Tournament::INIT_SPACE,
seeds = [b"tournament",id.to_le_bytes().as_ref()], seeds = [TOURNAMENT_SEED,id.to_le_bytes().as_ref()],
bump bump
)] )]
pub tournament_account: Account<'info,Tournament>, pub tournament_account: Account<'info,Tournament>,

View File

@ -1,5 +1,5 @@
use anchor_lang::{prelude::*, solana_program::native_token::LAMPORTS_PER_SOL}; use anchor_lang::{prelude::*, solana_program::native_token::LAMPORTS_PER_SOL};
use crate::{DataRegistry,Tournament, DATA_REGISTRY_SEED}; use crate::{DataRegistry,Tournament, DATA_REGISTRY_SEED, TOURNAMENT_SEED};
use anchor_spl::{associated_token::AssociatedToken, token_interface::{transfer_checked, Mint, TokenAccount, TokenInterface, TransferChecked}}; use anchor_spl::{associated_token::AssociatedToken, token_interface::{transfer_checked, Mint, TokenAccount, TokenInterface, TransferChecked}};
@ -47,7 +47,7 @@ pub struct JoinTorunament<'info>{
#[account( #[account(
mut, mut,
seeds = [b"Tournament", id.to_le_bytes().as_ref()], seeds = [TOURNAMENT_SEED,id.to_le_bytes().as_ref()],
bump bump
)] )]
pub tournament_account: Account<'info, Tournament>, pub tournament_account: Account<'info, Tournament>,

View File

@ -287,7 +287,7 @@
{ {
"kind": "const", "kind": "const",
"value": [ "value": [
84, 116,
111, 111,
117, 117,
114, 114,
@ -699,6 +699,16 @@
"name": "ID", "name": "ID",
"type": "string", "type": "string",
"value": "\"\"" "value": "\"\""
},
{
"name": "TOURNAMENT_SEED",
"type": {
"array": [
"u8",
10
]
},
"value": "[116, 111, 117, 114, 110, 97, 109, 101, 110, 116]"
} }
] ]
} }