-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EthereumScraperSwapFindProvider: fix non matching attributes
- Loading branch information
Showing
1 changed file
with
11 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
@@ -17,6 +17,14 @@ export default class EthereumScraperSwapFindProvider extends Provider { | |
}) | ||
} | ||
|
||
normalizeTransactionResponse (tx) { | ||
const normalizedTx = normalizeTransactionObject(formatEthResponse(tx)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
monokh
Author
Collaborator
|
||
if (normalizedTx.contractAddress) { | ||
normalizedTx.contractAddress = normalizedTx.contractAddress.toLowerCase() | ||
} | ||
return normalizedTx | ||
} | ||
|
||
async findAddressTransaction (address, predicate) { | ||
address = ensure0x(addressToString(address)) | ||
|
||
|
@@ -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 | ||
|
@monokh We don't need this here. Can you please remove
normalizeTransactionObject
,formatEthResponse
from here and just docontractAddress.toLowerCase()
?