type fixes

This commit is contained in:
hueso
2026-01-23 14:08:06 -03:00
parent 0432329d41
commit fcc34a83d5
3 changed files with 113 additions and 13 deletions

View File

@@ -1,3 +1,4 @@
import PrimusNetwork from '@primuslabs/network-core-sdk';
import dotenv from 'dotenv';
import express, { Request, Response } from 'express';
import cors from 'cors';
@@ -105,7 +106,7 @@ class BBPay {
}
}
class Register extends BBPay {
class BBRegister extends BBPay {
public async post(req: Request, res: Response): Promise<void> {
log('Registering participant...');
const data = req.body;
@@ -141,7 +142,7 @@ class Register extends BBPay {
}
}
class Request extends BBPay {
class BBRequest extends BBPay {
public async post(req: Request, res: Response): Promise<void> {
log('Creating request...');
const data = req.body;
@@ -185,7 +186,7 @@ class Request extends BBPay {
}
}
class Release extends BBPay {
class BBRelease extends BBPay {
public async get(req: Request, res: Response): Promise<void> {
const numeroSolicitacao = req.params.numeroSolicitacao;
log(`Releasing request ${numeroSolicitacao}...`);
@@ -232,15 +233,15 @@ class Release extends BBPay {
ethers.utils.hexZeroPad(pixTimestamp,32),
]);
const signable = ethers.utils.keccak256(packed);
const wallet = new Wallet(process.env.PRIVATE_KEY);
const wallet = new Wallet(process.env.PRIVATE_KEY as string);
const signature = await wallet.signMessage(signable);
log('Request released successfully.');
res.json({
pixTarget: `${chainID}-${numeroParticipante}`,
amount: valorSolicitacao.toString(),
pixTimestamp: `0x${pixTimestamp.toString('hex')}`,
signature: `0x${signature}`,
pixTimestamp: pixTimestamp,
signature: signature,
});
} catch (error) {
log('Internal server error:', error);
@@ -251,7 +252,7 @@ class Release extends BBPay {
// (CPF, nome, conta) -> participantID
// should be called before deposit
const register = new Register();
const register = new BBRegister();
app.post('/register', async (req: Request, res: Response) => {
await register.init();
await register.post(req, res);
@@ -259,7 +260,7 @@ app.post('/register', async (req: Request, res: Response) => {
// (amount,pixtarget) -> requestID, QRcodeText
// should be called after lock
const request = new Request();
const request = new BBRequest();
app.post('/request', async (req: Request, res: Response) => {
await request.init();
await request.post(req, res);
@@ -267,7 +268,7 @@ app.post('/request', async (req: Request, res: Response) => {
// (requestID) -> sig(pixTarget, amount, pixTimestamp)
// should be called before release
const release = new Release();
const release = new BBRelease();
app.get('/release/:numeroSolicitacao', async (req: Request, res: Response) => {
await release.init();
await release.get(req, res);
@@ -282,4 +283,4 @@ if (process.env.DEBUG) {
server.listen(process.env.PORT || 5000, () => {
log(`Server running on port ${process.env.PORT || 5000}`);
});
}
}