@exodus/web3-ethereum-utils 3.29.1 → 3.30.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.
|
@@ -21,12 +21,12 @@ export const createSimulateTransactions = ({ apiEndpoint, headers }) => async ({
|
|
|
21
21
|
return simulationResult;
|
|
22
22
|
}
|
|
23
23
|
await simulateTransactions({
|
|
24
|
+
asset,
|
|
24
25
|
transactions,
|
|
25
26
|
apiEndpoint: overrideApiEndpoint || apiEndpoint,
|
|
26
27
|
origin,
|
|
27
28
|
simulationResult,
|
|
28
29
|
headers,
|
|
29
|
-
assetName: asset.name,
|
|
30
30
|
});
|
|
31
31
|
simulationResult.displayDetails = getDisplayDetails(simulationResult.balanceChanges.willApprove);
|
|
32
32
|
return simulationResult;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { EthAggregatedTransactionSimulationResult, EthSimulateTransactionParams } from '../types.js';
|
|
2
2
|
import type { CreateSimulateTransactionsParams } from '@exodus/web3-types';
|
|
3
|
-
declare type SimulateTransactionParams = Required<Pick<CreateSimulateTransactionsParams, 'apiEndpoint'>> & Required<Pick<EthSimulateTransactionParams, 'transactions' | 'origin'>> & {
|
|
3
|
+
declare type SimulateTransactionParams = Required<Pick<CreateSimulateTransactionsParams, 'apiEndpoint'>> & Required<Pick<EthSimulateTransactionParams, 'asset' | 'transactions' | 'origin'>> & {
|
|
4
4
|
simulationResult: EthAggregatedTransactionSimulationResult;
|
|
5
5
|
headers?: Record<string, string>;
|
|
6
|
-
assetName: string;
|
|
7
6
|
};
|
|
8
|
-
export declare const simulateTransactions: ({ transactions, apiEndpoint, origin, simulationResult, headers,
|
|
7
|
+
export declare const simulateTransactions: ({ transactions, apiEndpoint, origin, simulationResult, headers, asset, }: SimulateTransactionParams) => Promise<void>;
|
|
9
8
|
export {};
|
|
@@ -105,14 +105,14 @@ const simulationResultHasAssets = (expectedStateChanges) => {
|
|
|
105
105
|
}
|
|
106
106
|
return true;
|
|
107
107
|
};
|
|
108
|
-
export const simulateTransactions = async ({ transactions, apiEndpoint, origin, simulationResult, headers,
|
|
108
|
+
export const simulateTransactions = async ({ transactions, apiEndpoint, origin, simulationResult, headers, asset, }) => {
|
|
109
109
|
const userAddress = transactions[0].from;
|
|
110
110
|
const payload = convertTransactionToApiPayload(transactions, origin);
|
|
111
|
-
if (!Object.hasOwnProperty.call(BLOWFISH_EVM_CHAINS,
|
|
111
|
+
if (!Object.hasOwnProperty.call(BLOWFISH_EVM_CHAINS, asset.name)) {
|
|
112
112
|
// ToDo: accept a logger dep and log the error
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
const { network, chain } = BLOWFISH_EVM_CHAINS[
|
|
115
|
+
const { network, chain } = BLOWFISH_EVM_CHAINS[asset.name];
|
|
116
116
|
const response = await makeSimulationAPICall({
|
|
117
117
|
url: apiEndpoint,
|
|
118
118
|
chain,
|
|
@@ -129,6 +129,18 @@ export const simulateTransactions = async ({ transactions, apiEndpoint, origin,
|
|
|
129
129
|
// ToDo: consider pushing an error to the "warnings" list
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
+
const noExpectedStateChangesDetected = Object.keys(expectedStateChanges).length === 0;
|
|
133
|
+
// This is a self-send transaction, adding a zero "transfer" so that the UI can display it.
|
|
134
|
+
if (noExpectedStateChangesDetected) {
|
|
135
|
+
simulationResult.balanceChanges.willSend.push({
|
|
136
|
+
balance: createCurrency({
|
|
137
|
+
amount: 0,
|
|
138
|
+
symbol: asset.displayTicker,
|
|
139
|
+
denominator: asset.currency.defaultUnit.power,
|
|
140
|
+
}),
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
132
144
|
const userExpectedChanges = Object.keys(expectedStateChanges).reduce((prev, address) => {
|
|
133
145
|
if (userAddress.toLowerCase() !== address.toLowerCase()) {
|
|
134
146
|
return prev;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/web3-ethereum-utils",
|
|
3
3
|
"description": "Web3 Ethereum utils.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.30.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"@exodus/web3-utils": "^1.45.0",
|
|
37
37
|
"@metamask/eth-sig-util": "^4.0.1"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "96fc062090ba251a05e619e49fb812ecb0f3ae60"
|
|
40
40
|
}
|