@exodus/ethereum-api 2.25.2 → 2.26.0
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.26.0",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@exodus/models": "^8.7.2"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "c7534c623d4c2abb024d2c983399130ddb3b434f"
|
|
38
38
|
}
|
|
@@ -23,10 +23,21 @@ async function getAssetSymbolFromContract(contractAddress) {
|
|
|
23
23
|
return assetSymbol
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async function prepareBalanceChanges(
|
|
26
|
+
async function prepareBalanceChanges(
|
|
27
|
+
internalTransactions,
|
|
28
|
+
balanceChanges,
|
|
29
|
+
transactionInput,
|
|
30
|
+
assetName = 'ethereum'
|
|
31
|
+
) {
|
|
32
|
+
const assetNameToSymbolMap = Object.create(null)
|
|
33
|
+
assetNameToSymbolMap['ethereum'] = 'ETH' // Refactor after blowfish integration
|
|
34
|
+
|
|
35
|
+
const asset = assets[assetName]
|
|
27
36
|
const preparedBalanceChanges = [...balanceChanges]
|
|
28
37
|
|
|
29
38
|
const decimals = Object.create(null)
|
|
39
|
+
decimals[assetNameToSymbolMap[asset.name]] = asset.currency.defaultUnit.power // Always have a default asset decimal in map for edge cases
|
|
40
|
+
|
|
30
41
|
const assetSymbols = Object.create(null)
|
|
31
42
|
let contractName
|
|
32
43
|
let isERC721 = false
|
|
@@ -115,7 +126,7 @@ async function tryToDecodeApprovalTransaction(transaction) {
|
|
|
115
126
|
}
|
|
116
127
|
}
|
|
117
128
|
|
|
118
|
-
export async function
|
|
129
|
+
export async function retrieveSideEffects({ transaction, assetName, shouldSimulate = true }) {
|
|
119
130
|
const willSend = []
|
|
120
131
|
const willReceive = []
|
|
121
132
|
|
|
@@ -124,6 +135,10 @@ export async function simulateAndRetrieveSideEffects(transaction) {
|
|
|
124
135
|
return { willApprove: approveTransactionData }
|
|
125
136
|
}
|
|
126
137
|
|
|
138
|
+
if (!shouldSimulate) {
|
|
139
|
+
return null
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
if (!transaction.to) throw new Error(`'to' field is missing in the TX object`)
|
|
128
143
|
|
|
129
144
|
const blocknativeTxObject = {
|
|
@@ -150,7 +165,8 @@ export async function simulateAndRetrieveSideEffects(transaction) {
|
|
|
150
165
|
const preparedBalanceChanges = await prepareBalanceChanges(
|
|
151
166
|
internalTransactions,
|
|
152
167
|
sender.balanceChanges,
|
|
153
|
-
transaction.data
|
|
168
|
+
transaction.data,
|
|
169
|
+
assetName
|
|
154
170
|
)
|
|
155
171
|
|
|
156
172
|
for (const balanceChange of preparedBalanceChanges) {
|