Skip to content

Commit d32cffb

Browse files
committed
Improve giving scholarship
1 parent 4ae5da0 commit d32cffb

File tree

1 file changed

+8
-31
lines changed
  • apps/nextjs/app/api/check-crossword

1 file changed

+8
-31
lines changed

apps/nextjs/app/api/check-crossword/route.ts

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import LearnTGVaultsAbi from '@/abis/LearnTGVaults.json'
2020
import { newKyselyPostgresql } from '@/.config/kysely.config.ts'
2121
import type { CourseUsuario, DB, GuideUsuario, Usuario } from '@/db/db.d.ts'
2222
import { updateUserAndCoursePoints } from '@/lib/scores'
23+
import { callWriteFun } from '@/lib/crypto'
2324

2425
interface WordPlacement {
2526
word: string
@@ -303,43 +304,19 @@ export async function POST(req: NextRequest) {
303304
retMessage += msg[locale].atLeast50
304305
} else if (canSubmit) {
305306
try {
306-
const encodedData = encodeFunctionData({
307-
abi: LearnTGVaultsAbi,
308-
functionName: 'submitGuideResult',
309-
args: [
307+
let tx: Address = await callWriteFun(
308+
publicClient,
309+
account,
310+
contract.write.submitGuideResult,
311+
[
310312
courseIdArg,
311313
guideIdArg,
312314
walletAddress as Address,
313315
mistakesInCW.length == 0,
314316
usuario.profilescore || 0,
315317
],
316-
})
317-
console.log('encodedData=', encodedData)
318-
let txData = encodedData
319-
console.log('txData=', txData)
320-
const tx = await walletClient.sendTransaction({
321-
account,
322-
to: contract.address,
323-
data: txData as Hex,
324-
})
325-
console.log('tx=', tx)
326-
try {
327-
const receipt = await publicClient.waitForTransactionReceipt({
328-
hash: tx,
329-
confirmations: 2,
330-
timeout: 2_000,
331-
})
332-
// waitForTransactionReceipt has not worked anytime
333-
// Control has not reach this point, but we leave it
334-
// to give some time for the transaction to settel before
335-
// querying the contract
336-
console.log(`Receipt: ${receipt}`)
337-
338-
} catch (e) {
339-
console.error(
340-
`*waitForTransactionReceipt(${tx}) didnt work, continuing`,
341-
)
342-
}
318+
0
319+
)
343320
// VERIFICAR Y GUARDAR MONTO
344321
const statusArray: any = await contract.read.getStudentGuideStatus([
345322
courseIdArg,

0 commit comments

Comments
 (0)