Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
validate input for receipt resolver. issue #3266 and #3275
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshultz committed Sep 7, 2019
1 parent 481e0a9 commit 2cb76ca
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/graphql/src/resolvers/web3/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ import get from 'lodash/get'
// import memoize from 'lodash/memoize'

export async function getTransactionReceipt(id) {
const rawReceipt = await contracts.web3.eth.getTransactionReceipt(id)
if (!id || typeof id !== 'string' || ![66, 64].includes(id.length)) {
console.warn('Invalid transaction hash')
return null
}

let rawReceipt

try {
rawReceipt = await contracts.web3.eth.getTransactionReceipt(id)
} catch (err) {
console.error('Failed to fetch receipt')
console.error(err)
}

// Note: Check on the both receipt and receipt.blockNumber since Parity returns
// a receipt with no blockNumber if transaction is not yet mined (Geth does not).
Expand Down

0 comments on commit 2cb76ca

Please sign in to comment.