prod
This commit is contained in:
parent
d0610cf62d
commit
9831d6c0ec
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user