This commit is contained in:
Sewmina Dilshan 2025-04-04 20:23:56 +05:30
parent 0fb11d9009
commit 8b90e32645
4 changed files with 41 additions and 9 deletions

View File

@ -1,5 +1,5 @@
{ {
"address": "HxsDuhD7wcPxcMsrYdteMYxkffuwff8HoxhZ7NuFtM37", "address": "JAf3ZkQ469okXAzA6BKJeKBb9ZkCtZanULaUsapskoyn",
"metadata": { "metadata": {
"name": "bets", "name": "bets",
"version": "0.1.0", "version": "0.1.0",
@ -115,6 +115,10 @@
"name": "wager", "name": "wager",
"type": "u64" "type": "u64"
}, },
{
"name": "user_id",
"type": "string"
},
{ {
"name": "game_id", "name": "game_id",
"type": "string" "type": "string"
@ -200,6 +204,10 @@
} }
], ],
"args": [ "args": [
{
"name": "user_id",
"type": "string"
},
{ {
"name": "game_id", "name": "game_id",
"type": "string" "type": "string"
@ -238,8 +246,8 @@
"errors": [ "errors": [
{ {
"code": 6000, "code": 6000,
"name": "CustomError", "name": "BetNotFilled",
"msg": "Custom error message" "msg": "Bet is not filled yet!"
} }
], ],
"types": [ "types": [
@ -256,10 +264,18 @@
"name": "owner", "name": "owner",
"type": "pubkey" "type": "pubkey"
}, },
{
"name": "owner_id",
"type": "string"
},
{ {
"name": "joiner", "name": "joiner",
"type": "pubkey" "type": "pubkey"
}, },
{
"name": "joiner_id",
"type": "string"
},
{ {
"name": "wager", "name": "wager",
"type": "u64" "type": "u64"

View File

@ -5,7 +5,7 @@
* IDL can be found at `target/idl/bets.json`. * IDL can be found at `target/idl/bets.json`.
*/ */
export type Bets = { export type Bets = {
"address": "HxsDuhD7wcPxcMsrYdteMYxkffuwff8HoxhZ7NuFtM37", "address": "JAf3ZkQ469okXAzA6BKJeKBb9ZkCtZanULaUsapskoyn",
"metadata": { "metadata": {
"name": "bets", "name": "bets",
"version": "0.1.0", "version": "0.1.0",
@ -121,6 +121,10 @@ export type Bets = {
"name": "wager", "name": "wager",
"type": "u64" "type": "u64"
}, },
{
"name": "userId",
"type": "string"
},
{ {
"name": "gameId", "name": "gameId",
"type": "string" "type": "string"
@ -206,6 +210,10 @@ export type Bets = {
} }
], ],
"args": [ "args": [
{
"name": "userId",
"type": "string"
},
{ {
"name": "gameId", "name": "gameId",
"type": "string" "type": "string"
@ -244,8 +252,8 @@ export type Bets = {
"errors": [ "errors": [
{ {
"code": 6000, "code": 6000,
"name": "customError", "name": "betNotFilled",
"msg": "Custom error message" "msg": "Bet is not filled yet!"
} }
], ],
"types": [ "types": [
@ -262,10 +270,18 @@ export type Bets = {
"name": "owner", "name": "owner",
"type": "pubkey" "type": "pubkey"
}, },
{
"name": "ownerId",
"type": "string"
},
{ {
"name": "joiner", "name": "joiner",
"type": "pubkey" "type": "pubkey"
}, },
{
"name": "joinerId",
"type": "string"
},
{ {
"name": "wager", "name": "wager",
"type": "u64" "type": "u64"

View File

@ -26,7 +26,7 @@ async function create(){
const [bet_list_pda] = await PublicKey.findProgramAddress([Buffer.from("bets_list")], program.programId); const [bet_list_pda] = await PublicKey.findProgramAddress([Buffer.from("bets_list")], program.programId);
console.log(`Bets list PDA : ${bet_list_pda}`); console.log(`Bets list PDA : ${bet_list_pda}`);
const nonce = getRandomInt(100000000000); const nonce = getRandomInt(100000000000);
const tx = await program.methods.createBet(new BN(100000000), "tetris", new BN(nonce)).accounts({ const tx = await program.methods.createBet(new BN(100000000),"tester", "tetris", new BN(nonce)).accounts({
betsList: bet_list_pda, betsList: bet_list_pda,
}).rpc(); }).rpc();
console.log(`create tx : ${tx}`); console.log(`create tx : ${tx}`);

View File

@ -22,8 +22,8 @@ async function get(){
console.log({ console.log({
game_id: betAcc.gameId, game_id: betAcc.gameId,
owner: betAcc.owner, owner: betAcc.owner + " : " + betAcc.ownerId,
joiner: betAcc.joiner, joiner: betAcc.joiner + " : " + betAcc.joinerId,
wager: betAcc.wager.toNumber() + `: ${betAcc.wager.toNumber() / LAMPORTS_PER_SOL}SOL`, wager: betAcc.wager.toNumber() + `: ${betAcc.wager.toNumber() / LAMPORTS_PER_SOL}SOL`,
balance: solBalance + " SOL" balance: solBalance + " SOL"
}); });