Skip to content

Commit

Permalink
fix(server): fix backend issue (#992)
Browse files Browse the repository at this point in the history
fix(backend): fix backend issues
  • Loading branch information
Hemanthghs authored Dec 20, 2023
1 parent 8ea7b72 commit a3828ec
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions server/handler/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (h *Handler) GetTransactions(c echo.Context) error {

status := utils.GetStatus(c.QueryParam("status"))
var rows *sql.Rows
defer rows.Close()
if status == model.Pending {
rows, err = h.DB.Query(`SELECT t.id,t.multisig_address,t.status,t.created_at,t.last_updated,t.memo,t.signatures,t.messages,t.hash,t.err_msg,t.fee, m.threshold,
json_agg(jsonb_build_object('pubkey', p.pubkey, 'address', p.address, 'multisig_address',p.multisig_address)) AS pubkeys FROM transactions t JOIN multisig_accounts m ON t.multisig_address = m.address JOIN pubkeys p ON t.multisig_address = p.multisig_address WHERE t.multisig_address=$1 and t.status='PENDING' GROUP BY t.id, t.multisig_address, m.threshold, t.messages LIMIT $2 OFFSET $3`,
Expand All @@ -129,6 +128,7 @@ func (h *Handler) GetTransactions(c echo.Context) error {
Log: err.Error(),
})
}
defer rows.Close()

transactions := make([]schema.AllTransactionResult, 0)
for rows.Next() {
Expand Down Expand Up @@ -156,7 +156,6 @@ func (h *Handler) GetTransactions(c echo.Context) error {
}
transactions = append(transactions, transaction)
}
rows.Close()

return c.JSON(http.StatusOK, model.SuccessResponse{
Data: transactions,
Expand All @@ -181,7 +180,6 @@ func (h *Handler) GetAllMultisigTxns(c echo.Context) error {
Log: err.Error(),
})
}
defer multisigRows.Close()

transactions := make([]schema.AllTransactionResult, 0)

Expand All @@ -196,7 +194,6 @@ func (h *Handler) GetAllMultisigTxns(c echo.Context) error {
}

var rows *sql.Rows
defer rows.Close()
if status == "PENDING" {
rows, err = h.DB.Query(`SELECT t.id,t.multisig_address,t.status,t.created_at,t.last_updated,t.memo,t.signatures,t.messages,t.hash,t.err_msg,t.fee, m.threshold,
json_agg(jsonb_build_object('pubkey', p.pubkey, 'address', p.address, 'multisig_address',p.multisig_address)) AS pubkeys FROM transactions t JOIN multisig_accounts m ON t.multisig_address = m.address JOIN pubkeys p ON t.multisig_address = p.multisig_address WHERE t.multisig_address=$1 and t.status='PENDING' GROUP BY t.id, t.multisig_address, m.threshold, t.messages LIMIT $2 OFFSET $3`,
Expand Down Expand Up @@ -249,6 +246,7 @@ func (h *Handler) GetAllMultisigTxns(c echo.Context) error {
}
rows.Close()
}
defer multisigRows.Close()

return c.JSON(http.StatusOK, model.SuccessResponse{
Data: transactions,
Expand Down

0 comments on commit a3828ec

Please sign in to comment.