done
This commit is contained in:
parent
0fb11d9009
commit
8b90e32645
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"address": "HxsDuhD7wcPxcMsrYdteMYxkffuwff8HoxhZ7NuFtM37",
|
||||
"address": "JAf3ZkQ469okXAzA6BKJeKBb9ZkCtZanULaUsapskoyn",
|
||||
"metadata": {
|
||||
"name": "bets",
|
||||
"version": "0.1.0",
|
||||
|
|
@ -115,6 +115,10 @@
|
|||
"name": "wager",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
"name": "user_id",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "game_id",
|
||||
"type": "string"
|
||||
|
|
@ -200,6 +204,10 @@
|
|||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "user_id",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "game_id",
|
||||
"type": "string"
|
||||
|
|
@ -238,8 +246,8 @@
|
|||
"errors": [
|
||||
{
|
||||
"code": 6000,
|
||||
"name": "CustomError",
|
||||
"msg": "Custom error message"
|
||||
"name": "BetNotFilled",
|
||||
"msg": "Bet is not filled yet!"
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
|
|
@ -256,10 +264,18 @@
|
|||
"name": "owner",
|
||||
"type": "pubkey"
|
||||
},
|
||||
{
|
||||
"name": "owner_id",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "joiner",
|
||||
"type": "pubkey"
|
||||
},
|
||||
{
|
||||
"name": "joiner_id",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "wager",
|
||||
"type": "u64"
|
||||
|
|
|
|||
22
src/bets.ts
22
src/bets.ts
|
|
@ -5,7 +5,7 @@
|
|||
* IDL can be found at `target/idl/bets.json`.
|
||||
*/
|
||||
export type Bets = {
|
||||
"address": "HxsDuhD7wcPxcMsrYdteMYxkffuwff8HoxhZ7NuFtM37",
|
||||
"address": "JAf3ZkQ469okXAzA6BKJeKBb9ZkCtZanULaUsapskoyn",
|
||||
"metadata": {
|
||||
"name": "bets",
|
||||
"version": "0.1.0",
|
||||
|
|
@ -121,6 +121,10 @@ export type Bets = {
|
|||
"name": "wager",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
"name": "userId",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "gameId",
|
||||
"type": "string"
|
||||
|
|
@ -206,6 +210,10 @@ export type Bets = {
|
|||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "userId",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "gameId",
|
||||
"type": "string"
|
||||
|
|
@ -244,8 +252,8 @@ export type Bets = {
|
|||
"errors": [
|
||||
{
|
||||
"code": 6000,
|
||||
"name": "customError",
|
||||
"msg": "Custom error message"
|
||||
"name": "betNotFilled",
|
||||
"msg": "Bet is not filled yet!"
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
|
|
@ -262,10 +270,18 @@ export type Bets = {
|
|||
"name": "owner",
|
||||
"type": "pubkey"
|
||||
},
|
||||
{
|
||||
"name": "ownerId",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "joiner",
|
||||
"type": "pubkey"
|
||||
},
|
||||
{
|
||||
"name": "joinerId",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "wager",
|
||||
"type": "u64"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ async function create(){
|
|||
const [bet_list_pda] = await PublicKey.findProgramAddress([Buffer.from("bets_list")], program.programId);
|
||||
console.log(`Bets list PDA : ${bet_list_pda}`);
|
||||
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,
|
||||
}).rpc();
|
||||
console.log(`create tx : ${tx}`);
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ async function get(){
|
|||
|
||||
console.log({
|
||||
game_id: betAcc.gameId,
|
||||
owner: betAcc.owner,
|
||||
joiner: betAcc.joiner,
|
||||
owner: betAcc.owner + " : " + betAcc.ownerId,
|
||||
joiner: betAcc.joiner + " : " + betAcc.joinerId,
|
||||
wager: betAcc.wager.toNumber() + `: ${betAcc.wager.toNumber() / LAMPORTS_PER_SOL}SOL`,
|
||||
balance: solBalance + " SOL"
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user