Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix erpc query #180

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions backend/internal/data/shutter_explorer.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions backend/internal/data/sql/queries/shutter_explorer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ SELECT tx_hash, EXTRACT(EPOCH FROM created_at)::BIGINT AS included_timestamp
FROM decrypted_tx
WHERE slot = $1 AND tx_status = 'shielded inclusion';

-- name: QueryFromTransactionDetails :one
-- name: QueryFromTransactionDetails :many
SELECT tx_hash as user_tx_hash, encrypted_tx_hash
FROM transaction_details
WHERE tx_hash = $1 OR encrypted_tx_hash = $1
ORDER BY submission_time DESC
LIMIT 1;
ORDER BY submission_time DESC;

-- name: QueryTransactionDetailsByTxHash :one
WITH prioritized_tx AS (
Expand Down
12 changes: 9 additions & 3 deletions backend/internal/usecase/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ func (uc *TransactionUsecase) QueryTransactionDetailsByTxHash(ctx context.Contex
return nil, &err
}
} else {
txHashBytes = common.HexToHash(erpcTX.EncryptedTxHash).Bytes()
if len(erpcTX) > 0 {
if txHash == erpcTX[0].EncryptedTxHash {
txHashBytes = common.HexToHash(erpcTX[0].EncryptedTxHash).Bytes()
} else {
txHashBytes = common.HexToHash(erpcTX[0].UserTxHash).Bytes()
}
}
}

tse, err := uc.observerDBQuery.QueryTransactionDetailsByTxHash(ctx, txHashBytes)
Expand Down Expand Up @@ -291,8 +297,8 @@ func (uc *TransactionUsecase) QueryTransactionDetailsByTxHash(ctx context.Contex
if len(tse.UserTxHash) > 0 {
userTxHash = "0x" + hex.EncodeToString(tse.UserTxHash)
} else {
if erpcTxErr == nil {
userTxHash = erpcTX.UserTxHash
if len(erpcTX) > 0 {
userTxHash = erpcTX[0].UserTxHash
}
}

Expand Down
Loading