@exodus/ethereum-api 2.24.5 → 2.25.1
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": "2.
|
|
3
|
+
"version": "2.25.1",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@exodus/asset-lib": "^3.5.4",
|
|
18
18
|
"@exodus/crypto": "^1.0.0-rc.0",
|
|
19
|
-
"@exodus/ethereum-lib": "^2.
|
|
19
|
+
"@exodus/ethereum-lib": "^2.22.0",
|
|
20
20
|
"@exodus/ethereumjs-util": "^7.1.0-exodus.6",
|
|
21
21
|
"@exodus/fetch": "^1.2.1",
|
|
22
22
|
"@exodus/simple-retry": "^0.0.6",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@exodus/models": "^8.7.2"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "26582c94b07259d510c483a753fb0f696edf3957"
|
|
38
38
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import assets from '@exodus/assets'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
checkIsERC721InputData,
|
|
4
|
+
checkIsNFTInputData,
|
|
5
|
+
APPROVE_METHOD_ID,
|
|
6
|
+
} from '@exodus/ethereum-lib'
|
|
3
7
|
import SolidityContract from '@exodus/solidity-contract'
|
|
4
8
|
|
|
5
9
|
import { fetchTxPreview } from './fetch-tx-preview'
|
|
@@ -19,19 +23,29 @@ async function getAssetSymbolFromContract(contractAddress) {
|
|
|
19
23
|
return assetSymbol
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
async function prepareBalanceChanges(internalTransactions, balanceChanges) {
|
|
26
|
+
async function prepareBalanceChanges(internalTransactions, balanceChanges, transactionInput) {
|
|
23
27
|
const preparedBalanceChanges = [...balanceChanges]
|
|
24
28
|
|
|
25
29
|
const decimals = Object.create(null)
|
|
26
30
|
const assetSymbols = Object.create(null)
|
|
31
|
+
let contractName
|
|
32
|
+
let isERC721 = false
|
|
33
|
+
let isERC20 = false
|
|
27
34
|
|
|
28
35
|
if (internalTransactions && Array.isArray(internalTransactions)) {
|
|
29
36
|
for (const transaction of internalTransactions) {
|
|
30
|
-
const { contractCall } = transaction
|
|
37
|
+
const { contractCall, input } = transaction
|
|
31
38
|
|
|
32
39
|
if (!contractCall) continue
|
|
33
40
|
|
|
34
|
-
|
|
41
|
+
const { decimalValue } = contractCall
|
|
42
|
+
isERC721 =
|
|
43
|
+
checkIsNFTInputData(transactionInput) || (!decimalValue && checkIsERC721InputData(input))
|
|
44
|
+
isERC20 =
|
|
45
|
+
!isERC721 &&
|
|
46
|
+
(contractCall.methodName === 'transfer' || contractCall.methodName === 'transferFrom')
|
|
47
|
+
|
|
48
|
+
if (isERC20) {
|
|
35
49
|
const assetSymbol =
|
|
36
50
|
contractCall.contractAlias ||
|
|
37
51
|
(await getAssetSymbolFromContract(contractCall.contractAddress))
|
|
@@ -39,6 +53,10 @@ async function prepareBalanceChanges(internalTransactions, balanceChanges) {
|
|
|
39
53
|
assetSymbols[contractCall.contractAddress] = assetSymbol
|
|
40
54
|
decimals[assetSymbol] = contractCall.contractDecimals
|
|
41
55
|
}
|
|
56
|
+
|
|
57
|
+
if (isERC721) {
|
|
58
|
+
contractName = contractCall.contractName
|
|
59
|
+
}
|
|
42
60
|
}
|
|
43
61
|
}
|
|
44
62
|
|
|
@@ -51,12 +69,18 @@ async function prepareBalanceChanges(internalTransactions, balanceChanges) {
|
|
|
51
69
|
(await getAssetSymbolFromContract(asset.contractAddress))
|
|
52
70
|
}
|
|
53
71
|
|
|
72
|
+
if (isERC721) {
|
|
73
|
+
asset.type = 'erc721'
|
|
74
|
+
asset.title = contractName
|
|
75
|
+
continue
|
|
76
|
+
}
|
|
77
|
+
|
|
54
78
|
if (typeof decimals[asset.symbol] === 'number') {
|
|
55
79
|
asset.decimal = decimals[asset.symbol]
|
|
56
80
|
continue
|
|
57
81
|
}
|
|
58
82
|
|
|
59
|
-
if (
|
|
83
|
+
if (isERC20 && asset.contractAddress) {
|
|
60
84
|
const { decimals: assetDecimal } = await getERC20Params({
|
|
61
85
|
address: asset.contractAddress,
|
|
62
86
|
assetName: 'ethereum',
|
|
@@ -66,6 +90,7 @@ async function prepareBalanceChanges(internalTransactions, balanceChanges) {
|
|
|
66
90
|
asset.decimal = assetDecimal
|
|
67
91
|
}
|
|
68
92
|
}
|
|
93
|
+
|
|
69
94
|
return preparedBalanceChanges
|
|
70
95
|
}
|
|
71
96
|
|
|
@@ -124,7 +149,8 @@ export async function simulateAndRetrieveSideEffects(transaction) {
|
|
|
124
149
|
if (sender) {
|
|
125
150
|
const preparedBalanceChanges = await prepareBalanceChanges(
|
|
126
151
|
internalTransactions,
|
|
127
|
-
sender.balanceChanges
|
|
152
|
+
sender.balanceChanges,
|
|
153
|
+
transaction.data
|
|
128
154
|
)
|
|
129
155
|
|
|
130
156
|
for (const balanceChange of preparedBalanceChanges) {
|
|
@@ -140,6 +166,11 @@ export async function simulateAndRetrieveSideEffects(transaction) {
|
|
|
140
166
|
if (delta.startsWith('-')) {
|
|
141
167
|
willSend.push(account)
|
|
142
168
|
} else {
|
|
169
|
+
if (asset.type === 'erc721') {
|
|
170
|
+
account.nft = {
|
|
171
|
+
title: `${asset.title || asset.symbol} #${delta}`,
|
|
172
|
+
}
|
|
173
|
+
}
|
|
143
174
|
willReceive.push(account)
|
|
144
175
|
}
|
|
145
176
|
}
|