@exodus/web3-ethereum-utils 3.31.2 → 3.33.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.
@@ -1,3 +1,4 @@
1
+ import BN from 'bn.js';
1
2
  interface BlowfishEvmChain {
2
3
  [key: string]: {
3
4
  network: string;
@@ -5,4 +6,5 @@ interface BlowfishEvmChain {
5
6
  };
6
7
  }
7
8
  export declare const BLOWFISH_EVM_CHAINS: BlowfishEvmChain;
9
+ export declare const MAX_INT256_SOLIDITY: BN;
8
10
  export {};
@@ -1,3 +1,4 @@
1
+ import BN from 'bn.js';
1
2
  export const BLOWFISH_EVM_CHAINS = {
2
3
  ethereum: {
3
4
  network: 'ethereum',
@@ -24,3 +25,5 @@ export const BLOWFISH_EVM_CHAINS = {
24
25
  chain: 'mainnet',
25
26
  },
26
27
  };
28
+ // The maximum signed integer 2\^255 - 1 represented in BN.
29
+ export const MAX_INT256_SOLIDITY = new BN(2).pow(new BN(255)).subn(1);
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { pick } from '@exodus/basic-utils';
6
6
  import { createCurrency, makeSimulationAPICall } from '@exodus/web3-utils';
7
- import { BLOWFISH_EVM_CHAINS } from './common.js';
7
+ import { BLOWFISH_EVM_CHAINS, MAX_INT256_SOLIDITY } from './common.js';
8
8
  const convertTransactionToApiPayload = (transactions, origin) => ({
9
9
  txObjects: transactions.map((transaction) => ({
10
10
  from: transaction.from,
@@ -59,15 +59,17 @@ const handleExpectedBalanceChange = (expectedBalanceChange, simulationResult, {
59
59
  kind === 'ERC1155_APPROVAL_FOR_ALL' ||
60
60
  kind === 'ERC721_APPROVAL') {
61
61
  const unitsToUse = symbol || asset.name || 'Units.';
62
+ const approvingBalance = createCurrency({
63
+ amount: data.amount.after,
64
+ symbol: unitsToUse,
65
+ denominator: decimals,
66
+ });
62
67
  willApprove.push({
63
68
  asset: asset_,
64
69
  spender: data.spender.address,
65
70
  unitName: unitsToUse,
66
- balance: createCurrency({
67
- amount: data.amount.after,
68
- symbol: unitsToUse,
69
- denominator: decimals,
70
- }),
71
+ balance: approvingBalance,
72
+ isMaxApproval: approvingBalance._number.gte(MAX_INT256_SOLIDITY),
71
73
  });
72
74
  return;
73
75
  }
@@ -136,6 +138,7 @@ export const simulateTransactions = async ({ transactions, apiEndpoint, origin,
136
138
  if (!response) {
137
139
  return successDefaultResult;
138
140
  }
141
+ simulationResult.metadata.simulatedLocally = false;
139
142
  const { expectedStateChanges = {}, error } = response.simulationResults.aggregated;
140
143
  if (error) {
141
144
  // ToDo: accept a logger dep and log the error
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.31.2",
4
+ "version": "3.33.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -33,8 +33,8 @@
33
33
  "@exodus/basic-utils": "^2.5.1",
34
34
  "@exodus/ethereumjs-common": "^2.4.0-exodus.6",
35
35
  "@exodus/ethereumjs-tx": "^3.3.0-exodus.6",
36
- "@exodus/web3-utils": "^1.45.0",
36
+ "@exodus/web3-utils": "^1.46.0",
37
37
  "@metamask/eth-sig-util": "^4.0.1"
38
38
  },
39
- "gitHead": "5a85c94903861c5afdc9099e6a0d62293b3874e7"
39
+ "gitHead": "67abb1cb9aebbc851508e80cdb5540110b36e31c"
40
40
  }