sync
This commit is contained in:
parent
c0b46f2ecf
commit
4a46b7d7df
|
|
@ -5,10 +5,14 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"init": "ts-node src/init.ts",
|
"init": "ts-node src/init.ts",
|
||||||
"create": "ts-node src/create.ts",
|
"create": "ts-node src/create.ts",
|
||||||
|
"create_token": "ts-node src/create_token.ts",
|
||||||
"join": "ts-node src/join.ts",
|
"join": "ts-node src/join.ts",
|
||||||
|
"join_token": "ts-node src/join_token.ts",
|
||||||
"get": "ts-node src/get.ts",
|
"get": "ts-node src/get.ts",
|
||||||
"close": "ts-node src/close.ts",
|
"close": "ts-node src/close.ts",
|
||||||
|
"close_token": "ts-node src/close_token.ts",
|
||||||
"clear": "ts-node src/clear.ts",
|
"clear": "ts-node src/clear.ts",
|
||||||
|
"balance": "ts-node src/check_balance.ts",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|
|
||||||
857
src/bets.json
857
src/bets.json
|
|
@ -7,31 +7,6 @@
|
||||||
"description": "Created with Anchor"
|
"description": "Created with Anchor"
|
||||||
},
|
},
|
||||||
"instructions": [
|
"instructions": [
|
||||||
{
|
|
||||||
"name": "clear_bets_list",
|
|
||||||
"discriminator": [
|
|
||||||
128,
|
|
||||||
73,
|
|
||||||
20,
|
|
||||||
28,
|
|
||||||
69,
|
|
||||||
26,
|
|
||||||
247,
|
|
||||||
185
|
|
||||||
],
|
|
||||||
"accounts": [
|
|
||||||
{
|
|
||||||
"name": "bets_list",
|
|
||||||
"writable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "payer",
|
|
||||||
"writable": true,
|
|
||||||
"signer": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"args": []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "close_bet",
|
"name": "close_bet",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -78,6 +53,176 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "close_bet_token",
|
||||||
|
"discriminator": [
|
||||||
|
253,
|
||||||
|
179,
|
||||||
|
157,
|
||||||
|
65,
|
||||||
|
93,
|
||||||
|
13,
|
||||||
|
142,
|
||||||
|
130
|
||||||
|
],
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"name": "bets_list",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bet_vault",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "winner",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"writable": true,
|
||||||
|
"signer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_mint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_vault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "bet_vault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "winner_token_account",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "winner"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "winner",
|
||||||
|
"type": "pubkey"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userid",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "create_bet",
|
"name": "create_bet",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -158,6 +303,210 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "create_bet_token",
|
||||||
|
"discriminator": [
|
||||||
|
112,
|
||||||
|
150,
|
||||||
|
197,
|
||||||
|
85,
|
||||||
|
168,
|
||||||
|
49,
|
||||||
|
140,
|
||||||
|
199
|
||||||
|
],
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"writable": true,
|
||||||
|
"signer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_mint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bets_list",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bet_vault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "const",
|
||||||
|
"value": [
|
||||||
|
98,
|
||||||
|
101,
|
||||||
|
116,
|
||||||
|
95,
|
||||||
|
118,
|
||||||
|
97,
|
||||||
|
117,
|
||||||
|
108,
|
||||||
|
116
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "payer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "arg",
|
||||||
|
"path": "game_id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "arg",
|
||||||
|
"path": "_nonce"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer_token_account",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "payer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "token_vault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "bet_vault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "wager",
|
||||||
|
"type": "u64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "game_id",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "u64"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "deduct_fees",
|
"name": "deduct_fees",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -212,6 +561,298 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "deduct_fees_token",
|
||||||
|
"discriminator": [
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
60,
|
||||||
|
121,
|
||||||
|
30,
|
||||||
|
164,
|
||||||
|
148,
|
||||||
|
135
|
||||||
|
],
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"name": "bets_list",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bet_vault",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fee_wallet",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"writable": true,
|
||||||
|
"signer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "owner_referrer",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "joiner_referrer",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_mint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_vault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "bet_vault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "fee_wallet_token_account",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "fee_wallet"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "owner_referrer_token_account",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "owner_referrer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "joiner_referrer_token_account",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "joiner_referrer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "winner",
|
||||||
|
"type": "pubkey"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userid",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "initialize",
|
"name": "initialize",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -297,6 +938,168 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "join_bet_token",
|
||||||
|
"discriminator": [
|
||||||
|
166,
|
||||||
|
253,
|
||||||
|
62,
|
||||||
|
118,
|
||||||
|
163,
|
||||||
|
87,
|
||||||
|
166,
|
||||||
|
204
|
||||||
|
],
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"name": "bet_vault",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"writable": true,
|
||||||
|
"signer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "token_mint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer_token_account",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "payer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "token_vault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "bet_vault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_program"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "token_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": "user_id",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "game_id",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "refund_bet",
|
"name": "refund_bet",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -401,6 +1204,10 @@
|
||||||
"name": "joiner_id",
|
"name": "joiner_id",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "token_mint",
|
||||||
|
"type": "pubkey"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wager",
|
"name": "wager",
|
||||||
"type": "u64"
|
"type": "u64"
|
||||||
|
|
|
||||||
857
src/bets.ts
857
src/bets.ts
|
|
@ -13,31 +13,6 @@ export type Bets = {
|
||||||
"description": "Created with Anchor"
|
"description": "Created with Anchor"
|
||||||
},
|
},
|
||||||
"instructions": [
|
"instructions": [
|
||||||
{
|
|
||||||
"name": "clearBetsList",
|
|
||||||
"discriminator": [
|
|
||||||
128,
|
|
||||||
73,
|
|
||||||
20,
|
|
||||||
28,
|
|
||||||
69,
|
|
||||||
26,
|
|
||||||
247,
|
|
||||||
185
|
|
||||||
],
|
|
||||||
"accounts": [
|
|
||||||
{
|
|
||||||
"name": "betsList",
|
|
||||||
"writable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "payer",
|
|
||||||
"writable": true,
|
|
||||||
"signer": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"args": []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "closeBet",
|
"name": "closeBet",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -84,6 +59,176 @@ export type Bets = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "closeBetToken",
|
||||||
|
"discriminator": [
|
||||||
|
253,
|
||||||
|
179,
|
||||||
|
157,
|
||||||
|
65,
|
||||||
|
93,
|
||||||
|
13,
|
||||||
|
142,
|
||||||
|
130
|
||||||
|
],
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"name": "betsList",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "betVault",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "winner",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"writable": true,
|
||||||
|
"signer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tokenMint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tokenVault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "betVault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "winnerTokenAccount",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "winner"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "winner",
|
||||||
|
"type": "pubkey"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userid",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "createBet",
|
"name": "createBet",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -164,6 +309,210 @@ export type Bets = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "createBetToken",
|
||||||
|
"discriminator": [
|
||||||
|
112,
|
||||||
|
150,
|
||||||
|
197,
|
||||||
|
85,
|
||||||
|
168,
|
||||||
|
49,
|
||||||
|
140,
|
||||||
|
199
|
||||||
|
],
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"writable": true,
|
||||||
|
"signer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tokenMint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "betsList",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "betVault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "const",
|
||||||
|
"value": [
|
||||||
|
98,
|
||||||
|
101,
|
||||||
|
116,
|
||||||
|
95,
|
||||||
|
118,
|
||||||
|
97,
|
||||||
|
117,
|
||||||
|
108,
|
||||||
|
116
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "payer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "arg",
|
||||||
|
"path": "gameId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "arg",
|
||||||
|
"path": "nonce"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payerTokenAccount",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "payer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "tokenVault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "betVault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "wager",
|
||||||
|
"type": "u64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userId",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gameId",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "u64"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "deductFees",
|
"name": "deductFees",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -218,6 +567,298 @@ export type Bets = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "deductFeesToken",
|
||||||
|
"discriminator": [
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
60,
|
||||||
|
121,
|
||||||
|
30,
|
||||||
|
164,
|
||||||
|
148,
|
||||||
|
135
|
||||||
|
],
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"name": "betsList",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "betVault",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "feeWallet",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"writable": true,
|
||||||
|
"signer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ownerReferrer",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "joinerReferrer",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tokenMint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tokenVault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "betVault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "feeWalletTokenAccount",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "feeWallet"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "ownerReferrerTokenAccount",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "ownerReferrer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "joinerReferrerTokenAccount",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "joinerReferrer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "winner",
|
||||||
|
"type": "pubkey"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userid",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "initialize",
|
"name": "initialize",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -303,6 +944,168 @@ export type Bets = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "joinBetToken",
|
||||||
|
"discriminator": [
|
||||||
|
166,
|
||||||
|
253,
|
||||||
|
62,
|
||||||
|
118,
|
||||||
|
163,
|
||||||
|
87,
|
||||||
|
166,
|
||||||
|
204
|
||||||
|
],
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"name": "betVault",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"writable": true,
|
||||||
|
"signer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tokenMint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payerTokenAccount",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "payer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "tokenVault",
|
||||||
|
"writable": true,
|
||||||
|
"pda": {
|
||||||
|
"seeds": [
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "betVault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenProgram"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "account",
|
||||||
|
"path": "tokenMint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "userId",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gameId",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "refundBet",
|
"name": "refundBet",
|
||||||
"discriminator": [
|
"discriminator": [
|
||||||
|
|
@ -407,6 +1210,10 @@ export type Bets = {
|
||||||
"name": "joinerId",
|
"name": "joinerId",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "tokenMint",
|
||||||
|
"type": "pubkey"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wager",
|
"name": "wager",
|
||||||
"type": "u64"
|
"type": "u64"
|
||||||
|
|
|
||||||
49
src/check_balance.ts
Normal file
49
src/check_balance.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";
|
||||||
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, getAccount, getAssociatedTokenAddress } from "@solana/spl-token";
|
||||||
|
import { ATA_PROGRAM_ID, TOKEN_PROGRAM_ID, clusterUrl } from "./shared";
|
||||||
|
|
||||||
|
async function checkBalance() {
|
||||||
|
// Get command line arguments
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
if (args.length !== 2) {
|
||||||
|
console.log("Usage: ts-node check_balance.ts <token_mint_address> <wallet_address>");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [tokenMintStr, walletAddressStr] = args;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const tokenMint = new PublicKey(tokenMintStr);
|
||||||
|
const walletAddress = new PublicKey(walletAddressStr);
|
||||||
|
const connection = new Connection(clusterUrl);
|
||||||
|
|
||||||
|
// Get the associated token account address
|
||||||
|
const tokenAccount = await getAssociatedTokenAddress(
|
||||||
|
tokenMint,
|
||||||
|
walletAddress,
|
||||||
|
false,
|
||||||
|
TOKEN_PROGRAM_ID,
|
||||||
|
ATA_PROGRAM_ID
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`Token Account: ${tokenAccount.toString()}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Get the token account info
|
||||||
|
const accountInfo = await getAccount(connection, tokenAccount, "confirmed", TOKEN_PROGRAM_ID);
|
||||||
|
console.log(`Token Balance: ${accountInfo.amount}`);
|
||||||
|
console.log(`Token Account: ${tokenAccount.toString()}`);
|
||||||
|
} catch (error) {
|
||||||
|
if (error.message.includes("TokenAccountNotFoundError")) {
|
||||||
|
console.log("No token account found for this wallet and token mint");
|
||||||
|
} else {
|
||||||
|
console.error("Error fetching token balance:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Invalid public key:", error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkBalance();
|
||||||
152
src/close_token.ts
Normal file
152
src/close_token.ts
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
import { Connection, PublicKey, Keypair, clusterApiUrl, LAMPORTS_PER_SOL, SystemProgram, Transaction } from "@solana/web3.js";
|
||||||
|
import { Bets } from "./bets";
|
||||||
|
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
||||||
|
import { clusterUrl, cocSk, feeWallet, getRandomInt, testerSk, TOKEN_PROGRAM_ID, ATA_PROGRAM_ID } from "./shared";
|
||||||
|
import { getAssociatedTokenAddress, createAssociatedTokenAccountInstruction } from "@solana/spl-token";
|
||||||
|
const IDL = require('./bets.json');
|
||||||
|
|
||||||
|
async function close() {
|
||||||
|
const keypair = Keypair.fromSecretKey(Uint8Array.from(cocSk));
|
||||||
|
const cocKeypair = Keypair.fromSecretKey(Uint8Array.from(cocSk));
|
||||||
|
|
||||||
|
const connection = new Connection(clusterUrl, {
|
||||||
|
commitment: 'confirmed',
|
||||||
|
confirmTransactionInitialTimeout: 60000
|
||||||
|
});
|
||||||
|
const provider = new AnchorProvider(connection, new Wallet(keypair), {
|
||||||
|
commitment: 'confirmed',
|
||||||
|
preflightCommitment: 'confirmed',
|
||||||
|
});
|
||||||
|
const program: Program<Bets> = new Program<Bets>(IDL, provider);
|
||||||
|
|
||||||
|
let solBalance = (await connection.getBalance(keypair.publicKey)) / LAMPORTS_PER_SOL;
|
||||||
|
console.log(`Tester ${keypair.publicKey} has ${solBalance} SOL`);
|
||||||
|
|
||||||
|
const [bet_list_pda] = await PublicKey.findProgramAddress([Buffer.from("bets_list")], program.programId);
|
||||||
|
console.log(`Bets list PDA : ${bet_list_pda}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const bet_list = await program.account.betsList.fetch(bet_list_pda);
|
||||||
|
|
||||||
|
|
||||||
|
for (const bet of bet_list.bets) {
|
||||||
|
try {
|
||||||
|
const betAcc = await program.account.betVault.fetch(bet);
|
||||||
|
|
||||||
|
|
||||||
|
if (betAcc.tokenMint.toString() == "11111111111111111111111111111111") {
|
||||||
|
console.log("Token mint is default");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ownerRefferer = new PublicKey("BaTgUMPsk8fZoEMwig81Pw1KHmPpoYt31oiR5Qr2c8XR");
|
||||||
|
const joinerRefferer = feeWallet;
|
||||||
|
|
||||||
|
// Get the owner referrer's token account PDA
|
||||||
|
const ownerReferrerTokenAccount = await getAssociatedTokenAddress(betAcc.tokenMint, ownerRefferer, false, TOKEN_PROGRAM_ID, ATA_PROGRAM_ID);
|
||||||
|
|
||||||
|
// Check if the owner referrer's token account exists
|
||||||
|
const ownerReferrerTokenAccountInfo = await connection.getAccountInfo(ownerReferrerTokenAccount);
|
||||||
|
|
||||||
|
// If the token account doesn't exist, create it
|
||||||
|
if (!ownerReferrerTokenAccountInfo) {
|
||||||
|
console.log(`Creating token account for owner referrer: ${ownerReferrerTokenAccount}`);
|
||||||
|
const createOwnerAtaIx = createAssociatedTokenAccountInstruction(
|
||||||
|
keypair.publicKey, // payer
|
||||||
|
ownerReferrerTokenAccount, // ata
|
||||||
|
ownerRefferer, // owner
|
||||||
|
betAcc.tokenMint, // mint
|
||||||
|
TOKEN_PROGRAM_ID,
|
||||||
|
ATA_PROGRAM_ID
|
||||||
|
);
|
||||||
|
|
||||||
|
const createOwnerAtaTx = await connection.sendTransaction(new Transaction().add(createOwnerAtaIx), [keypair]);
|
||||||
|
await connection.confirmTransaction(createOwnerAtaTx);
|
||||||
|
console.log(`createOwnerAtaTx: ${createOwnerAtaTx}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const winner = betAcc.owner;
|
||||||
|
console.log(`Closing ${bet}`);
|
||||||
|
|
||||||
|
// Get the fee wallet's token account PDA
|
||||||
|
const feeWalletTokenAccount = await getAssociatedTokenAddress(betAcc.tokenMint, feeWallet, false, TOKEN_PROGRAM_ID, ATA_PROGRAM_ID);
|
||||||
|
|
||||||
|
|
||||||
|
// Check if the fee wallet's token account exists
|
||||||
|
const feeWalletTokenAccountInfo = await connection.getAccountInfo(feeWalletTokenAccount);
|
||||||
|
|
||||||
|
// If the token account doesn't exist, create it
|
||||||
|
if (!feeWalletTokenAccountInfo) {
|
||||||
|
console.log(`Creating token account for fee wallet: ${feeWalletTokenAccount}`);
|
||||||
|
const createAtaIx = createAssociatedTokenAccountInstruction(
|
||||||
|
keypair.publicKey, // payer
|
||||||
|
feeWalletTokenAccount, // ata
|
||||||
|
feeWallet, // owner
|
||||||
|
betAcc.tokenMint, // mint
|
||||||
|
TOKEN_PROGRAM_ID,
|
||||||
|
ATA_PROGRAM_ID
|
||||||
|
);
|
||||||
|
|
||||||
|
const createAtaTx = await connection.sendTransaction(new Transaction().add(createAtaIx), [keypair]);
|
||||||
|
await connection.confirmTransaction(createAtaTx);
|
||||||
|
console.log(`createAtaTx: ${createAtaTx}`);
|
||||||
|
|
||||||
|
const feeWalletTokenAccountInfo = await connection.getAccountInfo(feeWalletTokenAccount);
|
||||||
|
console.log(`feeWalletTokenAccountInfo: ${feeWalletTokenAccountInfo}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const feeTx = await program.methods.deductFeesToken(winner, betAcc.ownerId)
|
||||||
|
.accounts({
|
||||||
|
betsList: bet_list_pda,
|
||||||
|
betVault: bet,
|
||||||
|
feeWallet: feeWallet,
|
||||||
|
ownerReferrer: ownerRefferer,
|
||||||
|
joinerReferrer: joinerRefferer,
|
||||||
|
tokenMint: betAcc.tokenMint,
|
||||||
|
tokenProgram: TOKEN_PROGRAM_ID,
|
||||||
|
})
|
||||||
|
.rpc({
|
||||||
|
skipPreflight: false,
|
||||||
|
maxRetries: 3
|
||||||
|
});
|
||||||
|
await connection.confirmTransaction(feeTx);
|
||||||
|
console.log(`fee tx: ${feeTx}`);
|
||||||
|
|
||||||
|
|
||||||
|
const closeTx = await program.methods.closeBet(winner, betAcc.ownerId)
|
||||||
|
.accounts({
|
||||||
|
betVault: bet,
|
||||||
|
betsList: bet_list_pda,
|
||||||
|
winner: winner,
|
||||||
|
})
|
||||||
|
.rpc({
|
||||||
|
skipPreflight: false,
|
||||||
|
maxRetries: 3
|
||||||
|
});
|
||||||
|
console.log(`close tx: ${closeTx}`);
|
||||||
|
|
||||||
|
const confirmation = await connection.confirmTransaction(closeTx);
|
||||||
|
|
||||||
|
if (confirmation.value.err) {
|
||||||
|
console.error(`Transaction failed: ${confirmation.value.err}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`tx complete: ${closeTx}`);
|
||||||
|
solBalance = (await connection.getBalance(keypair.publicKey)) / LAMPORTS_PER_SOL;
|
||||||
|
console.log(`Tester ${keypair.publicKey} has ${solBalance} SOL`);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Error processing bet ${bet}:`, err);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching bet list:', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close().catch(err => {
|
||||||
|
console.error('Fatal error:', err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
68
src/create_token.ts
Normal file
68
src/create_token.ts
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
import { Connection, PublicKey, Keypair, clusterApiUrl, LAMPORTS_PER_SOL, SystemProgram, Transaction } from "@solana/web3.js";
|
||||||
|
import { Bets } from "./bets";
|
||||||
|
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
||||||
|
import { ATA_PROGRAM_ID, BET_TOKEN_MINT, clusterUrl, cocSk, getRandomInt, testerSk, TOKEN_PROGRAM_ID } from "./shared";
|
||||||
|
// import { createAssociatedTokenAccountInstruction, getAccount, getAssociatedTokenAddress } from "@solana/spl-token";
|
||||||
|
const IDL = require('./bets.json');
|
||||||
|
|
||||||
|
async function create() {
|
||||||
|
const keypair = Keypair.fromSecretKey(Uint8Array.from(testerSk));
|
||||||
|
const connection = new Connection(clusterUrl);
|
||||||
|
const provider = new AnchorProvider(connection, new Wallet(keypair));
|
||||||
|
const program: Program<Bets> = new Program<Bets>(IDL, provider);
|
||||||
|
|
||||||
|
// Check and request SOL balance if needed
|
||||||
|
let solBalance = (await connection.getBalance(keypair.publicKey)) / LAMPORTS_PER_SOL;
|
||||||
|
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`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get bets list PDA
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Find bet vault PDA
|
||||||
|
const [bet_vault_pda] = await PublicKey.findProgramAddress(
|
||||||
|
[
|
||||||
|
Buffer.from("bet_vault"),
|
||||||
|
keypair.publicKey.toBuffer(),
|
||||||
|
Buffer.from("tetris"),
|
||||||
|
new BN(nonce).toArrayLike(Buffer, "le", 8)
|
||||||
|
],
|
||||||
|
program.programId
|
||||||
|
);
|
||||||
|
|
||||||
|
const tokenMint = BET_TOKEN_MINT;
|
||||||
|
|
||||||
|
// Create the bet
|
||||||
|
const tx = await program.methods.createBetToken(
|
||||||
|
new BN(100000000),
|
||||||
|
"tester",
|
||||||
|
"tetris",
|
||||||
|
new BN(nonce)
|
||||||
|
).accounts({
|
||||||
|
betsList: bet_list_pda,
|
||||||
|
payer: keypair.publicKey,
|
||||||
|
tokenMint: tokenMint,
|
||||||
|
tokenProgram: TOKEN_PROGRAM_ID,
|
||||||
|
}).rpc();
|
||||||
|
|
||||||
|
console.log(`create tx : ${tx}`);
|
||||||
|
await connection.confirmTransaction(tx);
|
||||||
|
console.log(`tx complete`);
|
||||||
|
}
|
||||||
|
|
||||||
|
create();
|
||||||
20
src/get.ts
20
src/get.ts
|
|
@ -1,7 +1,8 @@
|
||||||
import { Connection, PublicKey, Keypair, clusterApiUrl, LAMPORTS_PER_SOL } from "@solana/web3.js";
|
import { Connection, PublicKey, Keypair, clusterApiUrl, LAMPORTS_PER_SOL, Account } from "@solana/web3.js";
|
||||||
import { Bets } from "./bets";
|
import { Bets } from "./bets";
|
||||||
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
||||||
import { clusterUrl, cocSk } from "./shared";
|
import { ATA_PROGRAM_ID, clusterUrl, cocSk, TOKEN_PROGRAM_ID } from "./shared";
|
||||||
|
import { getAccount, getAssociatedTokenAddress } from "@solana/spl-token";
|
||||||
const IDL = require('./bets.json');
|
const IDL = require('./bets.json');
|
||||||
|
|
||||||
async function get(){
|
async function get(){
|
||||||
|
|
@ -19,13 +20,24 @@ async function get(){
|
||||||
bet_list.bets.forEach(async bet =>{
|
bet_list.bets.forEach(async bet =>{
|
||||||
const betAcc = await program.account.betVault.fetch(bet);
|
const betAcc = await program.account.betVault.fetch(bet);
|
||||||
let solBalance = (await connection.getBalance(bet))/ LAMPORTS_PER_SOL;
|
let solBalance = (await connection.getBalance(bet))/ LAMPORTS_PER_SOL;
|
||||||
|
let tokenAccount: PublicKey;
|
||||||
|
let tokenBalance:bigint;
|
||||||
|
let isToken = betAcc.tokenMint.toString() != "11111111111111111111111111111111";
|
||||||
|
if(isToken){
|
||||||
|
console.log("Token mint is not default");
|
||||||
|
tokenAccount = await getAssociatedTokenAddress(betAcc.tokenMint, bet, true, TOKEN_PROGRAM_ID, ATA_PROGRAM_ID);
|
||||||
|
let tokenAccData = await getAccount(connection, tokenAccount, "confirmed", TOKEN_PROGRAM_ID);
|
||||||
|
tokenBalance = tokenAccData.amount;
|
||||||
|
}
|
||||||
console.log({
|
console.log({
|
||||||
game_id: betAcc.gameId,
|
game_id: betAcc.gameId,
|
||||||
owner: betAcc.owner + " : " + betAcc.ownerId,
|
owner: betAcc.owner + " : " + betAcc.ownerId,
|
||||||
joiner: betAcc.joiner + " : " + betAcc.joinerId,
|
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",
|
||||||
|
token_account: isToken ? tokenAccount.toString() : "N/A",
|
||||||
|
token_mint: isToken ? betAcc.tokenMint.toString() : "N/A",
|
||||||
|
token_balance: isToken ? tokenBalance : "N/A",
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
56
src/join_token.ts
Normal file
56
src/join_token.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
import { Connection, PublicKey, Keypair, clusterApiUrl, LAMPORTS_PER_SOL, SystemProgram } from "@solana/web3.js";
|
||||||
|
import { Bets } from "./bets";
|
||||||
|
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
||||||
|
import { clusterUrl, cocSk, feeWallet, getRandomInt, testerSk, TOKEN_PROGRAM_ID } from "./shared";
|
||||||
|
const IDL = require('./bets.json');
|
||||||
|
|
||||||
|
async function join(){
|
||||||
|
const keypair = Keypair.fromSecretKey(Uint8Array.from(testerSk));
|
||||||
|
const connection = new Connection(clusterUrl);
|
||||||
|
const provider = new AnchorProvider(connection, new Wallet(keypair));
|
||||||
|
const program:Program<Bets> = new Program<Bets>(IDL,provider);
|
||||||
|
|
||||||
|
let solBalance = (await connection.getBalance(keypair.publicKey))/ LAMPORTS_PER_SOL;
|
||||||
|
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`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [bet_list_pda] = await PublicKey.findProgramAddress([Buffer.from("bets_list")], program.programId);
|
||||||
|
console.log(`Bets list PDA : ${bet_list_pda}`);
|
||||||
|
const bet_list = await program.account.betsList.fetch(bet_list_pda);
|
||||||
|
for (const bet of bet_list.bets) {
|
||||||
|
const betAcc = await program.account.betVault.fetch(bet);
|
||||||
|
if(betAcc.tokenMint.toString() == "11111111111111111111111111111111"){
|
||||||
|
console.log(`Skipping ${bet} because it's a SOL bet`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (betAcc.joiner.toBase58() == SystemProgram.programId.toBase58()) {
|
||||||
|
console.log(`Joining ${bet}`);
|
||||||
|
const tx = await program.methods.joinBetToken("tester2","tetris").accounts({
|
||||||
|
betVault: bet,
|
||||||
|
tokenMint: betAcc.tokenMint,
|
||||||
|
tokenProgram: TOKEN_PROGRAM_ID,
|
||||||
|
payer: keypair.publicKey
|
||||||
|
}).rpc();
|
||||||
|
console.log(`tx: ${tx}`);
|
||||||
|
|
||||||
|
const hash = await connection.confirmTransaction(tx);
|
||||||
|
console.log(`tx complete: ${hash}`);
|
||||||
|
}else{
|
||||||
|
console.log(`${bet} is already filled`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
join();
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
import { clusterApiUrl, PublicKey } from "@solana/web3.js";
|
import { clusterApiUrl, PublicKey } from "@solana/web3.js";
|
||||||
export const clusterUrl = clusterApiUrl("mainnet-beta");
|
export const clusterUrl = clusterApiUrl("devnet");
|
||||||
|
|
||||||
|
export const ATA_PROGRAM_ID = new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
|
||||||
|
export const TOKEN_PROGRAM_ID = new PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
||||||
|
|
||||||
|
export const BET_TOKEN_MINT = new PublicKey("tktUDLZhFGb9VW9zDxZ7HYDFuBooEf8daZEvPbBY7at");
|
||||||
|
|
||||||
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 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 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 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];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user