@exodus/web3-ethereum-utils 3.32.0 → 3.33.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.
@@ -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,
@@ -41,6 +41,7 @@ const handleExpectedBalanceChange = (expectedBalanceChange, simulationResult, {
41
41
  const isNftTransfer = kind === 'ERC721_TRANSFER' ||
42
42
  (kind === 'ERC1155_TRANSFER' && !asset.decimals);
43
43
  const isNftTransferApproval = kind === 'ERC721_APPROVAL' ||
44
+ (kind === 'ERC721_APPROVAL_FOR_ALL' && !asset.decimals) ||
44
45
  (kind === 'ERC1155_APPROVAL_FOR_ALL' && !asset.decimals);
45
46
  const symbol = asset.symbol;
46
47
  const decimals = isNftTransfer || isNftTransferApproval ? 1 : asset.decimals;
@@ -59,15 +60,17 @@ const handleExpectedBalanceChange = (expectedBalanceChange, simulationResult, {
59
60
  kind === 'ERC1155_APPROVAL_FOR_ALL' ||
60
61
  kind === 'ERC721_APPROVAL') {
61
62
  const unitsToUse = symbol || asset.name || 'Units.';
63
+ const approvingBalance = createCurrency({
64
+ amount: data.amount.after,
65
+ symbol: unitsToUse,
66
+ denominator: decimals,
67
+ });
62
68
  willApprove.push({
63
69
  asset: asset_,
64
70
  spender: data.spender.address,
65
71
  unitName: unitsToUse,
66
- balance: createCurrency({
67
- amount: data.amount.after,
68
- symbol: unitsToUse,
69
- denominator: decimals,
70
- }),
72
+ balance: approvingBalance,
73
+ isMaxApproval: approvingBalance._number.gte(MAX_INT256_SOLIDITY),
71
74
  });
72
75
  return;
73
76
  }
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.32.0",
4
+ "version": "3.33.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -36,5 +36,5 @@
36
36
  "@exodus/web3-utils": "^1.46.0",
37
37
  "@metamask/eth-sig-util": "^4.0.1"
38
38
  },
39
- "gitHead": "c4feab67861d3cfc41f28be38f4d61a82e7d78d3"
39
+ "gitHead": "976ba0b2c94712cdaee10652bc905fac43265c26"
40
40
  }