init
This commit is contained in:
commit
da3d51c0a5
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
*.swp
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
tmp
|
||||
|
||||
# Build
|
||||
public/css/main.css
|
||||
|
||||
# Coverage reports
|
||||
coverage
|
||||
|
||||
# API keys and secrets
|
||||
.env
|
||||
|
||||
# Dependency directory
|
||||
node_modules
|
||||
bower_components
|
||||
|
||||
# Editors
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# OS metadata
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
dist/**/*
|
||||
|
||||
# ignore yarn.lock
|
||||
yarn.lock
|
||||
11
eslint.config.mjs
Normal file
11
eslint.config.mjs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import globals from "globals";
|
||||
import pluginJs from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
|
||||
export default [
|
||||
{files: ["**/*.{js,mjs,cjs,ts}"]},
|
||||
{languageOptions: { globals: globals.browser }},
|
||||
pluginJs.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
];
|
||||
2611
package-lock.json
generated
Normal file
2611
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
package.json
Normal file
31
package.json
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "ticket_store",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"init": "ts-node src/init.ts",
|
||||
"tourney_add": "ts-node src/add_tournament.ts",
|
||||
"tourney_join": "ts-node src/join_tournament.ts",
|
||||
"purchase": "ts-node src/purchase.ts",
|
||||
"get": "ts-node src/get.ts",
|
||||
"send": "ts-node src/send_tickets_to_vault.ts",
|
||||
"build": "tsc"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.13.0",
|
||||
"eslint": "^9.13.0",
|
||||
"globals": "^15.11.0",
|
||||
"typescript": "^5.6.3",
|
||||
"typescript-eslint": "^8.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@coral-xyz/anchor": "^0.30.1",
|
||||
"@solana/spl-token": "^0.4.9",
|
||||
"@solana/web3.js": "^1.95.4",
|
||||
"bs58": "^6.0.0"
|
||||
}
|
||||
}
|
||||
25
src/add_tournament.ts
Normal file
25
src/add_tournament.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { Connection, PublicKey, Keypair, clusterApiUrl, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
|
||||
import {createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync} from "@solana/spl-token";
|
||||
import { Tournaments } from "./tournaments";
|
||||
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
||||
import { clusterUrl, cocSk, ticketsMint, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, ticketsSk } from "./keys";
|
||||
const IDL = require('./tournaments.json');
|
||||
|
||||
Init();
|
||||
|
||||
|
||||
async function Init(){
|
||||
const keypair = Keypair.fromSecretKey(Uint8Array.from(cocSk));
|
||||
const connection = new Connection(clusterUrl);
|
||||
const provider = new AnchorProvider(connection, new Wallet(keypair));
|
||||
const program: Program<Tournaments> = new Program<Tournaments>(IDL, provider);
|
||||
|
||||
const tx =await program.methods.addTournament(new BN(2), "2024-12-01 08:00").rpc();
|
||||
|
||||
console.log(`Added new tourney, tx: ${tx}`);
|
||||
|
||||
const [sellers_reg_pda] = await PublicKey.findProgramAddress([Buffer.from("sales_reg")], program.programId);
|
||||
const reg_acc = await program.account.dataRegistry.fetch(sellers_reg_pda);
|
||||
|
||||
console.log(reg_acc);
|
||||
}
|
||||
39
src/get.ts
Normal file
39
src/get.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { Connection, PublicKey, Keypair, clusterApiUrl } from "@solana/web3.js";
|
||||
import { Tournaments } from "./tournaments";
|
||||
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
||||
import { ASSOCIATED_TOKEN_PROGRAM_ID, clusterUrl, cocSk, ticketsMint, TOKEN_PROGRAM_ID } from "./keys";
|
||||
import { getAssociatedTokenAddress, getAssociatedTokenAddressSync } from "@solana/spl-token";
|
||||
const IDL = require('./tournaments.json');
|
||||
|
||||
async function Init(){
|
||||
const keypair = Keypair.fromSecretKey(Uint8Array.from(cocSk));
|
||||
const connection = new Connection(clusterUrl);
|
||||
const provider = new AnchorProvider(connection, new Wallet(keypair));
|
||||
const program: Program<Tournaments> = new Program<Tournaments>(IDL, provider);
|
||||
console.log(program.programId);
|
||||
|
||||
const [sellers_reg_pda] = await PublicKey.findProgramAddress([Buffer.from("sales_reg")], program.programId);
|
||||
console.log(`Sellers Reg PDA: ${sellers_reg_pda}`);
|
||||
|
||||
const sellers_reg_acc = await program.account.dataRegistry.fetch(sellers_reg_pda);
|
||||
console.log(sellers_reg_acc);
|
||||
|
||||
sellers_reg_acc.tournamentIds.forEach(async (value)=>{
|
||||
const tourneyIdBuffer = (new BN(value)).toArrayLike(Buffer,'le',8);
|
||||
const [tourneyPda] = await PublicKey.findProgramAddressSync([Buffer.from("tournament"), tourneyIdBuffer], program.programId);
|
||||
const tourneyAcc = await program.account.tournament.fetch(tourneyPda);
|
||||
const tourneyObj = {
|
||||
id: value,
|
||||
pda: tourneyPda,
|
||||
start_time: tourneyAcc.startTime,
|
||||
participants: tourneyAcc.participants
|
||||
}
|
||||
console.log(`${tourneyPda}: \n${JSON.stringify(tourneyObj)}\n`);
|
||||
})
|
||||
|
||||
const vaultAddress= await getAssociatedTokenAddressSync(ticketsMint, sellers_reg_pda, true, TOKEN_PROGRAM_ID);
|
||||
console.log(`Vault:${vaultAddress}`);
|
||||
}
|
||||
|
||||
|
||||
Init();
|
||||
21
src/init.ts
Normal file
21
src/init.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Connection, PublicKey, Keypair, clusterApiUrl } from "@solana/web3.js";
|
||||
import { Tournaments } from "./tournaments";
|
||||
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
|
||||
import { clusterUrl, cocSk, ticketsMint, TOKEN_PROGRAM_ID } from "./keys";
|
||||
const IDL = require('./tournaments.json');
|
||||
|
||||
async function Init(){
|
||||
const keypair = Keypair.fromSecretKey(Uint8Array.from(cocSk));
|
||||
const connection = new Connection(clusterUrl);
|
||||
const provider = new AnchorProvider(connection, new Wallet(keypair));
|
||||
const program: Program<Tournaments> = new Program<Tournaments>(IDL, provider);
|
||||
console.log(program.programId);
|
||||
|
||||
await program.methods.initialize().accounts({
|
||||
mint:ticketsMint,
|
||||
tokenProgram: TOKEN_PROGRAM_ID,
|
||||
}).rpc();
|
||||
}
|
||||
|
||||
|
||||
Init();
|
||||
40
src/join_tournament.ts
Normal file
40
src/join_tournament.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
import { Connection, PublicKey, Keypair, clusterApiUrl, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
|
||||
import {createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync} from "@solana/spl-token";
|
||||
import { Tournaments } from "./tournaments";
|
||||
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
||||
import { clusterUrl, cocSk, ticketsMint, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, ticketsSk, testerSk } from "./keys";
|
||||
const IDL = require('./tournaments.json');
|
||||
|
||||
async function Init(){
|
||||
|
||||
const keypair = Keypair.fromSecretKey(Uint8Array.from(testerSk));
|
||||
const connection = new Connection(clusterUrl);
|
||||
const provider = new AnchorProvider(connection, new Wallet(keypair));
|
||||
const program: Program<Tournaments> = new Program<Tournaments>(IDL, provider);
|
||||
|
||||
const tester_ata = await getAssociatedTokenAddressSync(ticketsMint,keypair.publicKey, false, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID);
|
||||
const tester_ticket_balance = (await connection.getTokenAccountBalance(tester_ata)).value.uiAmount;
|
||||
|
||||
console.log(`${tester_ata}: ${tester_ticket_balance}`);
|
||||
|
||||
const tourneyId = new BN(2);
|
||||
const tourneyIdBuffer = tourneyId.toArrayLike(Buffer,'le',8);
|
||||
const [tourneyPda] = await PublicKey.findProgramAddressSync([Buffer.from("tournament"), tourneyIdBuffer], program.programId);
|
||||
console.log(`tourney PDA: ${tourneyPda}`);
|
||||
|
||||
await program.methods.joinTournament(tourneyId).accounts({
|
||||
mint: ticketsMint,
|
||||
tokenProgram: TOKEN_PROGRAM_ID,
|
||||
}).rpc();
|
||||
|
||||
console.log(`Joined tourney`);
|
||||
|
||||
|
||||
|
||||
const tourneyAcc = await program.account.tournament.fetch(tourneyPda);
|
||||
console.log(tourneyAcc);
|
||||
}
|
||||
|
||||
|
||||
Init();
|
||||
11
src/keys.ts
Normal file
11
src/keys.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { clusterApiUrl, PublicKey } from "@solana/web3.js";
|
||||
|
||||
export const cocSk = [202,150,67,41,155,133,176,172,9,100,150,190,239,37,69,73,18,16,76,65,164,197,99,134,240,151,112,65,61,122,95,41,9,44,6,237,108,123,86,90,144,27,1,160,101,95,239,35,53,91,195,220,22,214,2,84,132,37,20,236,133,242,104,197];
|
||||
export const testerSk = [0,86,239,216,67,18,45,223,17,96,119,58,187,90,175,61,72,117,44,13,224,255,64,74,222,14,50,134,240,250,14,212,13,59,115,13,19,107,33,227,1,184,184,96,20,214,181,23,53,244,82,197,36,189,83,82,134,211,83,200,67,14,143,90];
|
||||
export const ticketsSk = [229,133,46,6,15,114,88,149,178,253,116,33,217,111,94,244,105,170,38,6,63,11,240,208,100,188,213,19,214,172,25,104,13,66,62,178,5,210,60,27,205,73,155,208,220,115,21,71,229,90,136,12,171,103,219,77,230,84,214,49,107,123,186,61];
|
||||
|
||||
export const ticketsMint = new PublicKey("tktUDLZhFGb9VW9zDxZ7HYDFuBooEf8daZEvPbBY7at");
|
||||
export const clusterUrl = clusterApiUrl("devnet");
|
||||
// export const clusterUrl = "http://127.0.0.1:8899";
|
||||
export const TOKEN_PROGRAM_ID = new PublicKey('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb');
|
||||
export const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
|
||||
53
src/purchase.ts
Normal file
53
src/purchase.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { Connection, PublicKey, Keypair, clusterApiUrl } from "@solana/web3.js";
|
||||
import { Tournaments } from "./tournaments";
|
||||
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
||||
import { ASSOCIATED_TOKEN_PROGRAM_ID, clusterUrl, testerSk, ticketsMint, TOKEN_PROGRAM_ID } from "./keys";
|
||||
const IDL = require('./tournaments.json');
|
||||
|
||||
async function Init(){
|
||||
const keypair = Keypair.fromSecretKey(Uint8Array.from(testerSk));
|
||||
const connection = new Connection(clusterUrl);
|
||||
const provider = new AnchorProvider(connection, new Wallet(keypair));
|
||||
const program: Program<Tournaments> = new Program<Tournaments>(IDL, provider);
|
||||
|
||||
let solBalance = await connection.getBalance(keypair.publicKey);
|
||||
console.log(`Tester ${keypair.publicKey} has ${solBalance} SOL`);
|
||||
if(solBalance <= 1){
|
||||
console.log("Requesting airdrop due to insufficient funds");
|
||||
try{
|
||||
await connection.requestAirdrop(keypair.publicKey, 5);
|
||||
}catch{
|
||||
console.log("Airdrop failed");
|
||||
}
|
||||
solBalance = await connection.getBalance(keypair.publicKey);
|
||||
console.log(`Tester now has ${solBalance} SOL`);
|
||||
}
|
||||
let ticketsBalanceBefore = 0;
|
||||
const [buyerAta] = await PublicKey.findProgramAddress([keypair.publicKey.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), ticketsMint.toBuffer()], ASSOCIATED_TOKEN_PROGRAM_ID);
|
||||
try{
|
||||
console.log(`buyers ATA is: ${buyerAta.toBase58()}`);
|
||||
ticketsBalanceBefore = (await connection.getTokenAccountBalance(buyerAta)).value.uiAmount;
|
||||
console.log(`Tester has ${ticketsBalanceBefore} tickets already`);
|
||||
}catch{
|
||||
console.log("Tester doesn't even has an ATA for this token");
|
||||
}
|
||||
|
||||
const [sellers_reg_pda] = await PublicKey.findProgramAddress([Buffer.from("sales_reg")], program.programId);
|
||||
console.log(`Sellers Reg PDA: ${sellers_reg_pda}`);
|
||||
|
||||
const sellers_reg_acc = await program.account.dataRegistry.fetch(sellers_reg_pda);
|
||||
console.log(sellers_reg_acc);
|
||||
|
||||
const tx = await program.methods.purchaseTickets(new BN(1)).accounts({
|
||||
author: sellers_reg_acc.authority,
|
||||
mint: ticketsMint,
|
||||
tokenProgram: TOKEN_PROGRAM_ID,
|
||||
}).rpc();
|
||||
console.log(`purchase method called : ${tx}`)
|
||||
await connection.confirmTransaction(tx);
|
||||
const newTicketsBalance = (await connection.getTokenAccountBalance(buyerAta)).value.uiAmount;
|
||||
console.log(`Tester had ${ticketsBalanceBefore} tickets, now he has ${newTicketsBalance} tickets.`);
|
||||
}
|
||||
|
||||
|
||||
Init();
|
||||
49
src/send_tickets_to_vault.ts
Normal file
49
src/send_tickets_to_vault.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { PublicKey, Keypair, Transaction, Connection } from '@solana/web3.js';
|
||||
import { getAssociatedTokenAddress, createTransferCheckedInstruction } from '@solana/spl-token';
|
||||
import bs58 from 'bs58';
|
||||
import { TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, cocSk, clusterUrl, ticketsMint } from './keys'; // Assuming you have a shared file with a Connection instance.
|
||||
|
||||
const TICKETS_MINT = new PublicKey(ticketsMint); // Replace with your token mint address
|
||||
const RECIPIENT_PUBLIC_KEY = new PublicKey("GgFxur5VjNH2NgjaxMgPmwNhhCwQsTKwPujnShoEnVGQ"); // Recipient's address
|
||||
transferSPLTokens();
|
||||
async function transferSPLTokens() {
|
||||
// Initialize sender's Keypair
|
||||
const senderKeypair = Keypair.fromSecretKey(Uint8Array.from(cocSk));
|
||||
const decimals = 9;
|
||||
|
||||
const amount = 1000000000000;
|
||||
|
||||
const connection = new Connection(clusterUrl);
|
||||
|
||||
// Get sender's ATA (Associated Token Account) for the specified mint
|
||||
const senderAta = await getAssociatedTokenAddress(
|
||||
TICKETS_MINT,
|
||||
senderKeypair.publicKey,
|
||||
false,
|
||||
TOKEN_PROGRAM_ID,
|
||||
ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
);
|
||||
|
||||
|
||||
// Create the transfer instruction
|
||||
const transferInstruction = createTransferCheckedInstruction(
|
||||
senderAta, // Source ATA
|
||||
TICKETS_MINT, // Mint of the token
|
||||
RECIPIENT_PUBLIC_KEY, // Destination ATA
|
||||
senderKeypair.publicKey, // Owner of the source ATA
|
||||
amount, // Amount to transfer (in token's smallest units)
|
||||
decimals, // Decimals of the token
|
||||
[], // MultiSigners, if any
|
||||
TOKEN_PROGRAM_ID // Token program ID
|
||||
);
|
||||
|
||||
// Create and sign the transaction
|
||||
const transaction = new Transaction().add(transferInstruction);
|
||||
const txSignature = await connection.sendTransaction(transaction, [senderKeypair]);
|
||||
|
||||
console.log(`Transfer transaction signature: ${txSignature}`);
|
||||
|
||||
// Confirm the transaction
|
||||
await connection.confirmTransaction(txSignature, 'confirmed');
|
||||
console.log(`Transfer of ${amount} tokens to ${RECIPIENT_PUBLIC_KEY.toBase58()} confirmed.`);
|
||||
}
|
||||
25
src/test.ts
Normal file
25
src/test.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// import { Keypair } from "@solana/web3.js";
|
||||
// import bs58 from 'bs58';
|
||||
// const secretKey = "";
|
||||
// const keypair =Keypair.fromSecretKey(
|
||||
// bs58.decode(secretKey)
|
||||
// );
|
||||
// console.log(keypair.publicKey);
|
||||
|
||||
import { Connection, PublicKey, Keypair, clusterApiUrl, LAMPORTS_PER_SOL } from "@solana/web3.js";
|
||||
import { TicketStore } from "./ticket_store";
|
||||
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
|
||||
import { clusterUrl, cocSk } from "./keys";
|
||||
const IDL = require('./ticket_store.json');
|
||||
|
||||
async function Init(){
|
||||
const keypair = Keypair.fromSecretKey(Uint8Array.from(cocSk));
|
||||
const connection = new Connection(clusterUrl);
|
||||
|
||||
const minimumBalance= await connection.getMinimumBalanceForRentExemption(0);
|
||||
console.log(minimumBalance);
|
||||
console.log(minimumBalance/LAMPORTS_PER_SOL);
|
||||
}
|
||||
|
||||
|
||||
Init();
|
||||
714
src/tournaments.json
Normal file
714
src/tournaments.json
Normal file
|
|
@ -0,0 +1,714 @@
|
|||
{
|
||||
"address": "F5ECXfrZwMyWv5WusMJD7bYSRjEEXYLLPy6TN3XqQBPA",
|
||||
"metadata": {
|
||||
"name": "tournaments",
|
||||
"version": "0.1.0",
|
||||
"spec": "0.1.0",
|
||||
"description": "Created with Anchor"
|
||||
},
|
||||
"instructions": [
|
||||
{
|
||||
"name": "add_tournament",
|
||||
"discriminator": [
|
||||
86,
|
||||
126,
|
||||
171,
|
||||
66,
|
||||
224,
|
||||
148,
|
||||
167,
|
||||
201
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "payer",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "tournament_account",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
116,
|
||||
111,
|
||||
117,
|
||||
114,
|
||||
110,
|
||||
97,
|
||||
109,
|
||||
101,
|
||||
110,
|
||||
116
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "arg",
|
||||
"path": "id"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "data_registry",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
115,
|
||||
97,
|
||||
108,
|
||||
101,
|
||||
115,
|
||||
95,
|
||||
114,
|
||||
101,
|
||||
103
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "system_program",
|
||||
"address": "11111111111111111111111111111111"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
"name": "start_time",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "initialize",
|
||||
"discriminator": [
|
||||
175,
|
||||
175,
|
||||
109,
|
||||
31,
|
||||
13,
|
||||
152,
|
||||
155,
|
||||
237
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "signer",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "data_registry",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
115,
|
||||
97,
|
||||
108,
|
||||
101,
|
||||
115,
|
||||
95,
|
||||
114,
|
||||
101,
|
||||
103
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "mint"
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "data_registry"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "token_program"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "system_program",
|
||||
"address": "11111111111111111111111111111111"
|
||||
},
|
||||
{
|
||||
"name": "token_program"
|
||||
},
|
||||
{
|
||||
"name": "associated_token_program",
|
||||
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
||||
}
|
||||
],
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "join_tournament",
|
||||
"discriminator": [
|
||||
77,
|
||||
21,
|
||||
212,
|
||||
206,
|
||||
77,
|
||||
82,
|
||||
124,
|
||||
31
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "user",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "user_token_account",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "user"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "token_program"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tournament_account",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
116,
|
||||
111,
|
||||
117,
|
||||
114,
|
||||
110,
|
||||
97,
|
||||
109,
|
||||
101,
|
||||
110,
|
||||
116
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "arg",
|
||||
"path": "id"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "data_registry",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
115,
|
||||
97,
|
||||
108,
|
||||
101,
|
||||
115,
|
||||
95,
|
||||
114,
|
||||
101,
|
||||
103
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "mint"
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "data_registry"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "token_program"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "system_program",
|
||||
"address": "11111111111111111111111111111111"
|
||||
},
|
||||
{
|
||||
"name": "token_program"
|
||||
},
|
||||
{
|
||||
"name": "associated_token_program",
|
||||
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "u64"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "purchase_tickets",
|
||||
"discriminator": [
|
||||
146,
|
||||
121,
|
||||
85,
|
||||
207,
|
||||
182,
|
||||
70,
|
||||
169,
|
||||
155
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "buyer",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "mint"
|
||||
},
|
||||
{
|
||||
"name": "author",
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"name": "buyer_token_account",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "buyer"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "token_program"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "data_registry",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
115,
|
||||
97,
|
||||
108,
|
||||
101,
|
||||
115,
|
||||
95,
|
||||
114,
|
||||
101,
|
||||
103
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "data_registry"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "token_program"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "system_program",
|
||||
"address": "11111111111111111111111111111111"
|
||||
},
|
||||
{
|
||||
"name": "token_program"
|
||||
},
|
||||
{
|
||||
"name": "associated_token_program",
|
||||
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "u64"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "DataRegistry",
|
||||
"discriminator": [
|
||||
169,
|
||||
50,
|
||||
35,
|
||||
17,
|
||||
11,
|
||||
106,
|
||||
49,
|
||||
193
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Tournament",
|
||||
"discriminator": [
|
||||
175,
|
||||
139,
|
||||
119,
|
||||
242,
|
||||
115,
|
||||
194,
|
||||
57,
|
||||
92
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
{
|
||||
"code": 6000,
|
||||
"name": "CustomError",
|
||||
"msg": "Custom error message"
|
||||
},
|
||||
{
|
||||
"code": 6001,
|
||||
"name": "InsufficientFunds",
|
||||
"msg": "Insufficient funds to purchase a ticket, Recharge your wallet and try again"
|
||||
},
|
||||
{
|
||||
"code": 6002,
|
||||
"name": "Unauthorized",
|
||||
"msg": "Only the owner can perform this action"
|
||||
},
|
||||
{
|
||||
"code": 6003,
|
||||
"name": "ExistingTournament",
|
||||
"msg": "This tournament ID already exists, use a different one"
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"name": "DataRegistry",
|
||||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "sales_pda",
|
||||
"type": "pubkey"
|
||||
},
|
||||
{
|
||||
"name": "authority",
|
||||
"type": "pubkey"
|
||||
},
|
||||
{
|
||||
"name": "tournament_ids",
|
||||
"type": {
|
||||
"vec": "u64"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Tournament",
|
||||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
"name": "participants",
|
||||
"type": {
|
||||
"vec": "pubkey"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "start_time",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
{
|
||||
"name": "DATA_REGISTRY_SEED",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
9
|
||||
]
|
||||
},
|
||||
"value": "[115, 97, 108, 101, 115, 95, 114, 101, 103]"
|
||||
},
|
||||
{
|
||||
"name": "ID",
|
||||
"type": "string",
|
||||
"value": "\"\""
|
||||
},
|
||||
{
|
||||
"name": "TOURNAMENT_SEED",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
10
|
||||
]
|
||||
},
|
||||
"value": "[116, 111, 117, 114, 110, 97, 109, 101, 110, 116]"
|
||||
}
|
||||
]
|
||||
}
|
||||
721
src/tournaments.ts
Normal file
721
src/tournaments.ts
Normal file
|
|
@ -0,0 +1,721 @@
|
|||
/**
|
||||
* Program IDL in camelCase format in order to be used in JS/TS.
|
||||
*
|
||||
* Note that this is only a type helper and is not the actual IDL. The original
|
||||
* IDL can be found at `target/idl/tournaments.json`.
|
||||
*/
|
||||
export type Tournaments = {
|
||||
"address": "F5ECXfrZwMyWv5WusMJD7bYSRjEEXYLLPy6TN3XqQBPA",
|
||||
"metadata": {
|
||||
"name": "tournaments",
|
||||
"version": "0.1.0",
|
||||
"spec": "0.1.0",
|
||||
"description": "Created with Anchor"
|
||||
},
|
||||
"instructions": [
|
||||
{
|
||||
"name": "addTournament",
|
||||
"discriminator": [
|
||||
86,
|
||||
126,
|
||||
171,
|
||||
66,
|
||||
224,
|
||||
148,
|
||||
167,
|
||||
201
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "payer",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "tournamentAccount",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
116,
|
||||
111,
|
||||
117,
|
||||
114,
|
||||
110,
|
||||
97,
|
||||
109,
|
||||
101,
|
||||
110,
|
||||
116
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "arg",
|
||||
"path": "id"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataRegistry",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
115,
|
||||
97,
|
||||
108,
|
||||
101,
|
||||
115,
|
||||
95,
|
||||
114,
|
||||
101,
|
||||
103
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "systemProgram",
|
||||
"address": "11111111111111111111111111111111"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
"name": "startTime",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "initialize",
|
||||
"discriminator": [
|
||||
175,
|
||||
175,
|
||||
109,
|
||||
31,
|
||||
13,
|
||||
152,
|
||||
155,
|
||||
237
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "signer",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "dataRegistry",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
115,
|
||||
97,
|
||||
108,
|
||||
101,
|
||||
115,
|
||||
95,
|
||||
114,
|
||||
101,
|
||||
103
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "mint"
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "dataRegistry"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "tokenProgram"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "systemProgram",
|
||||
"address": "11111111111111111111111111111111"
|
||||
},
|
||||
{
|
||||
"name": "tokenProgram"
|
||||
},
|
||||
{
|
||||
"name": "associatedTokenProgram",
|
||||
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
||||
}
|
||||
],
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "joinTournament",
|
||||
"discriminator": [
|
||||
77,
|
||||
21,
|
||||
212,
|
||||
206,
|
||||
77,
|
||||
82,
|
||||
124,
|
||||
31
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "user",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "userTokenAccount",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "user"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "tokenProgram"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tournamentAccount",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
116,
|
||||
111,
|
||||
117,
|
||||
114,
|
||||
110,
|
||||
97,
|
||||
109,
|
||||
101,
|
||||
110,
|
||||
116
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "arg",
|
||||
"path": "id"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataRegistry",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
115,
|
||||
97,
|
||||
108,
|
||||
101,
|
||||
115,
|
||||
95,
|
||||
114,
|
||||
101,
|
||||
103
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "mint"
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "dataRegistry"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "tokenProgram"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "systemProgram",
|
||||
"address": "11111111111111111111111111111111"
|
||||
},
|
||||
{
|
||||
"name": "tokenProgram"
|
||||
},
|
||||
{
|
||||
"name": "associatedTokenProgram",
|
||||
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "u64"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "purchaseTickets",
|
||||
"discriminator": [
|
||||
146,
|
||||
121,
|
||||
85,
|
||||
207,
|
||||
182,
|
||||
70,
|
||||
169,
|
||||
155
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "buyer",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "mint"
|
||||
},
|
||||
{
|
||||
"name": "author",
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"name": "buyerTokenAccount",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "buyer"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "tokenProgram"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataRegistry",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
115,
|
||||
97,
|
||||
108,
|
||||
101,
|
||||
115,
|
||||
95,
|
||||
114,
|
||||
101,
|
||||
103
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "dataRegistry"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "tokenProgram"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "mint"
|
||||
}
|
||||
],
|
||||
"program": {
|
||||
"kind": "const",
|
||||
"value": [
|
||||
140,
|
||||
151,
|
||||
37,
|
||||
143,
|
||||
78,
|
||||
36,
|
||||
137,
|
||||
241,
|
||||
187,
|
||||
61,
|
||||
16,
|
||||
41,
|
||||
20,
|
||||
142,
|
||||
13,
|
||||
131,
|
||||
11,
|
||||
90,
|
||||
19,
|
||||
153,
|
||||
218,
|
||||
255,
|
||||
16,
|
||||
132,
|
||||
4,
|
||||
142,
|
||||
123,
|
||||
216,
|
||||
219,
|
||||
233,
|
||||
248,
|
||||
89
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "systemProgram",
|
||||
"address": "11111111111111111111111111111111"
|
||||
},
|
||||
{
|
||||
"name": "tokenProgram"
|
||||
},
|
||||
{
|
||||
"name": "associatedTokenProgram",
|
||||
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "u64"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "dataRegistry",
|
||||
"discriminator": [
|
||||
169,
|
||||
50,
|
||||
35,
|
||||
17,
|
||||
11,
|
||||
106,
|
||||
49,
|
||||
193
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "tournament",
|
||||
"discriminator": [
|
||||
175,
|
||||
139,
|
||||
119,
|
||||
242,
|
||||
115,
|
||||
194,
|
||||
57,
|
||||
92
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
{
|
||||
"code": 6000,
|
||||
"name": "customError",
|
||||
"msg": "Custom error message"
|
||||
},
|
||||
{
|
||||
"code": 6001,
|
||||
"name": "insufficientFunds",
|
||||
"msg": "Insufficient funds to purchase a ticket, Recharge your wallet and try again"
|
||||
},
|
||||
{
|
||||
"code": 6002,
|
||||
"name": "unauthorized",
|
||||
"msg": "Only the owner can perform this action"
|
||||
},
|
||||
{
|
||||
"code": 6003,
|
||||
"name": "existingTournament",
|
||||
"msg": "This tournament ID already exists, use a different one"
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"name": "dataRegistry",
|
||||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "salesPda",
|
||||
"type": "pubkey"
|
||||
},
|
||||
{
|
||||
"name": "authority",
|
||||
"type": "pubkey"
|
||||
},
|
||||
{
|
||||
"name": "tournamentIds",
|
||||
"type": {
|
||||
"vec": "u64"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tournament",
|
||||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
"name": "participants",
|
||||
"type": {
|
||||
"vec": "pubkey"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "startTime",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
{
|
||||
"name": "dataRegistrySeed",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
9
|
||||
]
|
||||
},
|
||||
"value": "[115, 97, 108, 101, 115, 95, 114, 101, 103]"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"type": "string",
|
||||
"value": "\"\""
|
||||
},
|
||||
{
|
||||
"name": "tournamentSeed",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
10
|
||||
]
|
||||
},
|
||||
"value": "[116, 111, 117, 114, 110, 97, 109, 101, 110, 116]"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
12
tsconfig.json
Normal file
12
tsconfig.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"rootDir": "./src",
|
||||
"target": "es6",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"lib": ["es2015"]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user