From 9831d6c0ec449367243b32c83658a12640bfb088 Mon Sep 17 00:00:00 2001 From: Sewmina Date: Sat, 7 Jun 2025 04:54:14 +0000 Subject: [PATCH] prod --- src/shared.ts | 10 ++++++++++ src/solana.ts | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/shared.ts b/src/shared.ts index 982f094..174ce92 100644 --- a/src/shared.ts +++ b/src/shared.ts @@ -34,4 +34,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 bfb8c2c..3bb2e88 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"); @@ -73,6 +73,8 @@ export async function close(bet:string, winner:string, uid:string, loser:string) const winner_referree_wallet = await GetReferreeWallet(uid); 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({ betVault: bet, @@ -89,6 +91,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;