From ffc94f95adc8acffa4d21f054260f8acdd445ec1 Mon Sep 17 00:00:00 2001 From: adjoly Date: Wed, 30 Jul 2025 16:10:13 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20fixed?= =?UTF-8?q?=20random=20skill=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/scoreStore/addTx.js | 9 +++++---- src/api/scoreStore/getTx.js | 9 +++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/api/scoreStore/addTx.js b/src/api/scoreStore/addTx.js index d1640bb..ab9ae96 100644 --- a/src/api/scoreStore/addTx.js +++ b/src/api/scoreStore/addTx.js @@ -11,13 +11,14 @@ import { callAddScore, callLastId } from "../../utils/scoreStore_contract.js"; export async function addTx(request, reply, fastify) { try { const id = await callLastId(); - /** @type ContractTransactionResponse */ - const tx = await callAddScore(request.body.p1, request.body.p2, request.body.p1Score, request.body.p2Score); + const tx = callAddScore(request.body.p1, request.body.p2, request.body.p1Score, request.body.p2Score); - scoreDB.addTx(id, tx.hash); + tx.then(tx => { + scoreDB.addTx(id, tx.hash); + }); return reply.code(200).send({ - tx: tx.hash + id: id }); } catch (err) { fastify.log.error(err); diff --git a/src/api/scoreStore/getTx.js b/src/api/scoreStore/getTx.js index ffd8363..f932a0a 100644 --- a/src/api/scoreStore/getTx.js +++ b/src/api/scoreStore/getTx.js @@ -13,10 +13,15 @@ export async function getTx(request, reply, fastify) { try { const tx = scoreDB.getTx(request.params.id); - const score = callGetScore(request.params.id); + const score = await callGetScore(request.params.id); return reply.code(200).send({ - score: score, + score: { + p1: score.p1, + p2: score.p2, + p1Score: Number(score.p1Score), + p2Score: Number(score.p2Score) + }, tx: tx }); } catch (err) {