Skip to content

Commit

Permalink
EthereumScraperSwapFindProvider: fix non matching attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
monokh committed Jan 20, 2020
1 parent 93d66e6 commit aba489b
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'
import Provider from '@liquality/provider'
import { ensure0x } from '@liquality/ethereum-utils'
import { ensure0x, normalizeTransactionObject, formatEthResponse } from '@liquality/ethereum-utils'
import { addressToString } from '@liquality/utils'

import { version } from '../package.json'
Expand All @@ -17,6 +17,14 @@ export default class EthereumScraperSwapFindProvider extends Provider {
})
}

normalizeTransactionResponse (tx) {
const normalizedTx = normalizeTransactionObject(formatEthResponse(tx))

This comment has been minimized.

Copy link
@harshjv

harshjv Jan 21, 2020

Member

@monokh We don't need this here. Can you please remove normalizeTransactionObject, formatEthResponse from here and just do contractAddress.toLowerCase()?

This comment has been minimized.

Copy link
@monokh

monokh Jan 21, 2020

Author Collaborator

We need it. Transactions returned from the scraper api are in an eth rpc format. Transactions returned from and processed by the CAL should be in the normalised format.

if (normalizedTx.contractAddress) {
normalizedTx.contractAddress = normalizedTx.contractAddress.toLowerCase()
}
return normalizedTx
}

async findAddressTransaction (address, predicate) {
address = ensure0x(addressToString(address))

Expand All @@ -33,7 +41,8 @@ export default class EthereumScraperSwapFindProvider extends Provider {
const transactions = response.data.data.txs
if (transactions.length === 0) return

const tx = transactions.find(predicate)
const normalizedTransactions = transactions.map(this.normalizeTransactionResponse)
const tx = normalizedTransactions.find(predicate)
if (tx) return tx

if (transactions.length < limit) return
Expand Down

0 comments on commit aba489b

Please sign in to comment.