diff --git a/src/bets.json b/src/bets.json index 7612362..11d6c3a 100644 --- a/src/bets.json +++ b/src/bets.json @@ -22,7 +22,25 @@ "accounts": [ { "name": "bets_list", - "writable": true + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 101, + 116, + 115, + 95, + 108, + 105, + 115, + 116 + ] + } + ] + } }, { "name": "payer", @@ -78,6 +96,218 @@ } ] }, + { + "name": "close_bet_token", + "discriminator": [ + 253, + 179, + 157, + 65, + 93, + 13, + 142, + 130 + ], + "accounts": [ + { + "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": "arg", + "path": "owner" + }, + { + "kind": "arg", + "path": "game_id" + }, + { + "kind": "arg", + "path": "nonce" + } + ] + } + }, + { + "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": "arg", + "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": "owner", + "type": "pubkey" + }, + { + "name": "game_id", + "type": "string" + }, + { + "name": "nonce", + "type": "u64" + } + ] + }, { "name": "create_bet", "discriminator": [ @@ -158,6 +388,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", "discriminator": [ @@ -212,6 +646,340 @@ } ] }, + { + "name": "deduct_fees_token", + "discriminator": [ + 92, + 93, + 60, + 121, + 30, + 164, + 148, + 135 + ], + "accounts": [ + { + "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": "arg", + "path": "owner" + }, + { + "kind": "arg", + "path": "game_id" + }, + { + "kind": "arg", + "path": "nonce" + } + ] + } + }, + { + "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": "owner", + "type": "pubkey" + }, + { + "name": "game_id", + "type": "string" + }, + { + "name": "nonce", + "type": "u64" + } + ] + }, { "name": "initialize", "discriminator": [ @@ -297,6 +1065,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", "discriminator": [ @@ -381,6 +1311,10 @@ "type": { "kind": "struct", "fields": [ + { + "name": "nonce", + "type": "u64" + }, { "name": "game_id", "type": "string" @@ -401,6 +1335,10 @@ "name": "joiner_id", "type": "string" }, + { + "name": "token_mint", + "type": "pubkey" + }, { "name": "wager", "type": "u64" diff --git a/src/bets.ts b/src/bets.ts index 5a885a5..fa77285 100644 --- a/src/bets.ts +++ b/src/bets.ts @@ -28,7 +28,25 @@ export type Bets = { "accounts": [ { "name": "betsList", - "writable": true + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 101, + 116, + 115, + 95, + 108, + 105, + 115, + 116 + ] + } + ] + } }, { "name": "payer", @@ -84,6 +102,218 @@ export type Bets = { } ] }, + { + "name": "closeBetToken", + "discriminator": [ + 253, + 179, + 157, + 65, + 93, + 13, + 142, + 130 + ], + "accounts": [ + { + "name": "betsList", + "writable": true + }, + { + "name": "betVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "owner" + }, + { + "kind": "arg", + "path": "gameId" + }, + { + "kind": "arg", + "path": "nonce" + } + ] + } + }, + { + "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": "arg", + "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": "owner", + "type": "pubkey" + }, + { + "name": "gameId", + "type": "string" + }, + { + "name": "nonce", + "type": "u64" + } + ] + }, { "name": "createBet", "discriminator": [ @@ -164,6 +394,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", "discriminator": [ @@ -218,6 +652,340 @@ export type Bets = { } ] }, + { + "name": "deductFeesToken", + "discriminator": [ + 92, + 93, + 60, + 121, + 30, + 164, + 148, + 135 + ], + "accounts": [ + { + "name": "betsList", + "writable": true + }, + { + "name": "betVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "owner" + }, + { + "kind": "arg", + "path": "gameId" + }, + { + "kind": "arg", + "path": "nonce" + } + ] + } + }, + { + "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": "owner", + "type": "pubkey" + }, + { + "name": "gameId", + "type": "string" + }, + { + "name": "nonce", + "type": "u64" + } + ] + }, { "name": "initialize", "discriminator": [ @@ -303,6 +1071,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", "discriminator": [ @@ -387,6 +1317,10 @@ export type Bets = { "type": { "kind": "struct", "fields": [ + { + "name": "nonce", + "type": "u64" + }, { "name": "gameId", "type": "string" @@ -407,6 +1341,10 @@ export type Bets = { "name": "joinerId", "type": "string" }, + { + "name": "tokenMint", + "type": "pubkey" + }, { "name": "wager", "type": "u64" diff --git a/src/shared.ts b/src/shared.ts index fa5c94a..6ff9358 100644 --- a/src/shared.ts +++ b/src/shared.ts @@ -41,4 +41,14 @@ export function getRandomInt(max) { } return winner_referree_wallet; + } + + export async function add_new_activity(type:string, owner_id:string, joiner_id:string, game:string, amount:number ){ + try{ + + await fetch(`${duelfiApiUrl}add_activity.php?type=${type}&owner_id=${owner_id}&joiner_id=${joiner_id}&game=${game}&amount=${amount}`) + + }catch(error){ + console.error("Error adding new activity:", error); + } } \ No newline at end of file diff --git a/src/solana.ts b/src/solana.ts index f2efe73..d41d9e9 100644 --- a/src/solana.ts +++ b/src/solana.ts @@ -1,7 +1,7 @@ import { AnchorProvider, Wallet, Program } from "@coral-xyz/anchor"; import { Keypair, Connection, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; import { Bets } from "./bets"; -import { testerSk, cocSk, clusterUrl, duelfiApiUrl, feeWallet, GetReferreeWallet } from "./shared"; +import { testerSk, cocSk, clusterUrl, duelfiApiUrl, feeWallet, GetReferreeWallet, add_new_activity } from "./shared"; import { log } from "./logging_help"; const IDL = require("./bets.json"); @@ -88,6 +88,8 @@ export async function close(bet:string, winner:string, uid:string, loser:string) log(`winner referree wallet: ${winner_referree_wallet}: ${winner_referree_balance} SOL`, bet); log(`loser referree wallet: ${loser_referree_wallet}: ${loser_referree_balance} SOL`, bet); + const bet_acc = await program.account.betVault.fetch(bet); + const tx = await program.methods.deductFees(new PublicKey(winner), uid).accounts({ betVault: bet, betsList: bet_list_pda, @@ -103,6 +105,9 @@ export async function close(bet:string, winner:string, uid:string, loser:string) winner: winner }).rpc(); await connection.confirmTransaction(close_tx, 'confirmed'); + //if(!process.env.USE_DEVNET){ + add_new_activity("won", uid, loser, bet_acc.gameId, bet_acc.wager.toNumber() / LAMPORTS_PER_SOL); + // } log(`close tx: ${close_tx}`, "solana"); return tx;