Bug: incoming transactions do not load if it fails to fetch gas for a transaction (#1321)

* check if gas returned values are valid when loading token info for incoming tx

* Fix generateBatchRequests

Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
This commit is contained in:
Mikhail Mikheev 2020-09-04 18:25:25 +04:00 committed by GitHub
parent bfed9679f7
commit 372d27f5a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,8 +10,9 @@ import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3'
* @param {array<{ args: [any], method: string, type: 'eth'|undefined } | string>} args.methods - methods to be called
* @returns {Promise<[*]>}
*/
const generateBatchRequests = ({ abi, address, batch = new web3.BatchRequest() , context, methods }: any): any => {
const generateBatchRequests = ({ abi, address, batch, context, methods }: any): any => {
const contractInstance: any = new web3.eth.Contract(abi, address)
const localBatch = new web3.BatchRequest()
const values = methods.map((methodObject) => {
let method, type, args = []
@ -39,14 +40,14 @@ const generateBatchRequests = ({ abi, address, batch = new web3.BatchRequest() ,
request = contractInstance.methods[method](...args).call.request(resolver)
}
batch.add(request)
batch ? batch.add(request) : localBatch.add(request)
} catch (e) {
resolve(null)
}
})
})
batch.execute()
!batch && localBatch.execute()
const returnValues = context ? [context, ...values] : values