This commit is contained in:
Sewmina 2025-06-07 04:54:14 +00:00
parent d0610cf62d
commit 9831d6c0ec
2 changed files with 16 additions and 1 deletions

View File

@ -34,4 +34,14 @@ export function getRandomInt(max) {
} }
return winner_referree_wallet; 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);
}
} }

View File

@ -1,7 +1,7 @@
import { AnchorProvider, Wallet, Program } from "@coral-xyz/anchor"; import { AnchorProvider, Wallet, Program } from "@coral-xyz/anchor";
import { Keypair, Connection, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; import { Keypair, Connection, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
import { Bets } from "./bets"; 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"; import { log } from "./logging_help";
const IDL = require("./bets.json"); const IDL = require("./bets.json");
@ -73,6 +73,8 @@ export async function close(bet:string, winner:string, uid:string, loser:string)
const winner_referree_wallet = await GetReferreeWallet(uid); const winner_referree_wallet = await GetReferreeWallet(uid);
const loser_referree_wallet = await GetReferreeWallet(loser); const loser_referree_wallet = await GetReferreeWallet(loser);
const bet_acc = await program.account.betVault.fetch(bet);
const tx = await program.methods.deductFees(new PublicKey(winner), uid).accounts({ const tx = await program.methods.deductFees(new PublicKey(winner), uid).accounts({
betVault: bet, betVault: bet,
@ -89,6 +91,9 @@ export async function close(bet:string, winner:string, uid:string, loser:string)
winner: winner winner: winner
}).rpc(); }).rpc();
await connection.confirmTransaction(close_tx, 'confirmed'); 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"); log(`close tx: ${close_tx}`, "solana");
return tx; return tx;