@exodus/ethereum-api 5.0.9 → 5.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.11",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@exodus/models": "^8.10.4"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "b34adcc696b2e7f67c8e556f3d0ed31cc481ed4d"
|
|
40
40
|
}
|
package/src/gas-estimation.js
CHANGED
|
@@ -63,7 +63,9 @@ export async function fetchGasLimit({
|
|
|
63
63
|
if (_isToken) {
|
|
64
64
|
// only create tx-input only if not pass tx-input to a token asset
|
|
65
65
|
if (txInput === '0x') {
|
|
66
|
-
txInput = ethUtil.bufferToHex(
|
|
66
|
+
txInput = ethUtil.bufferToHex(
|
|
67
|
+
asset.contract.transfer.build(toAddress.toLowerCase(), amount.toBaseString())
|
|
68
|
+
)
|
|
67
69
|
}
|
|
68
70
|
amount = asset.baseAsset.currency.ZERO
|
|
69
71
|
toAddress = asset.contract.address
|
|
@@ -23,6 +23,32 @@ async function getAssetSymbolFromContract(contractAddress) {
|
|
|
23
23
|
return assetSymbol
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// Sometimes ERC20 transfers happen with a proxy contract and Blocknative Preview API duplicates them.
|
|
27
|
+
// We consider transfers having the same type (ERC20), symbol, decimals number and the delta number (transfer amount)
|
|
28
|
+
// as duplicates and remove them.
|
|
29
|
+
export function maybeRemoveDuplicates(balanceChanges) {
|
|
30
|
+
// We didn't encounter duplicates in other cases so doing this check to limit the function impact.
|
|
31
|
+
if (balanceChanges.length !== 2) return balanceChanges
|
|
32
|
+
|
|
33
|
+
const uniqueBalanceChanges = []
|
|
34
|
+
const existingBalanceChangesSet = new Set()
|
|
35
|
+
for (const balanceChange of balanceChanges) {
|
|
36
|
+
const { asset: assetData, delta } = balanceChange
|
|
37
|
+
if (assetData.type !== 'erc20') {
|
|
38
|
+
uniqueBalanceChanges.push(balanceChange)
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const key = `${assetData.type}:${assetData.symbol}:${assetData.decimal}:${delta}`
|
|
43
|
+
if (existingBalanceChangesSet.has(key)) continue
|
|
44
|
+
|
|
45
|
+
existingBalanceChangesSet.add(key)
|
|
46
|
+
uniqueBalanceChanges.push(balanceChange)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return uniqueBalanceChanges
|
|
50
|
+
}
|
|
51
|
+
|
|
26
52
|
async function prepareBalanceChanges(
|
|
27
53
|
internalTransactions,
|
|
28
54
|
balanceChanges,
|
|
@@ -102,7 +128,7 @@ async function prepareBalanceChanges(
|
|
|
102
128
|
}
|
|
103
129
|
}
|
|
104
130
|
|
|
105
|
-
return preparedBalanceChanges
|
|
131
|
+
return maybeRemoveDuplicates(preparedBalanceChanges)
|
|
106
132
|
}
|
|
107
133
|
|
|
108
134
|
async function tryToDecodeApprovalTransaction(transaction) {
|