@exodus/web3-ethereum-utils 3.24.0 → 3.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.
@@ -2,8 +2,8 @@
2
2
  This utility makes an API call to a simulation service, parses the response and mutates the supplied "simulationResult" object
3
3
  with the according balance changes.
4
4
  */
5
+ import { pick } from '@exodus/basic-utils';
5
6
  import { createCurrency, makeSimulationAPICall } from '@exodus/web3-utils';
6
- import { pick } from 'lodash';
7
7
  export const BLOWFISH_EVM_CHAINS = {
8
8
  ethereum: {
9
9
  network: 'ethereum',
@@ -62,8 +62,10 @@ const handleExpectedBalanceChange = (expectedBalanceChange, simulationResult, {
62
62
  // ERC1155 is a multi-token standard (https://eips.ethereum.org/EIPS/eip-1155) and can be used for NFTs as well.
63
63
  const isNftTransfer = kind === 'ERC721_TRANSFER' ||
64
64
  (kind === 'ERC1155_TRANSFER' && !asset.decimals);
65
+ const isNftTransferApproval = kind === 'ERC721_APPROVAL' ||
66
+ (kind === 'ERC1155_APPROVAL_FOR_ALL' && !asset.decimals);
65
67
  const symbol = asset.symbol;
66
- const decimals = isNftTransfer ? 1 : asset.decimals;
68
+ const decimals = isNftTransfer || isNftTransferApproval ? 1 : asset.decimals;
67
69
  const asset_ = pick(asset, [
68
70
  'address',
69
71
  'imageUrl',
@@ -71,20 +73,21 @@ const handleExpectedBalanceChange = (expectedBalanceChange, simulationResult, {
71
73
  'symbol',
72
74
  'verified',
73
75
  ]);
74
- if (isNftTransfer) {
76
+ if (isNftTransfer || isNftTransferApproval) {
75
77
  asset_.imageUrl = data?.metadata?.rawImageUrl;
76
78
  }
77
79
  if (kind === 'ERC20_APPROVAL' ||
78
80
  kind === 'ERC721_APPROVAL_FOR_ALL' ||
79
81
  kind === 'ERC1155_APPROVAL_FOR_ALL' ||
80
82
  kind === 'ERC721_APPROVAL') {
83
+ const unitsToUse = symbol || asset.name || 'Units.';
81
84
  willApprove.push({
82
85
  asset: asset_,
83
86
  spender: data.spender.address,
84
- unitName: symbol,
87
+ unitName: unitsToUse,
85
88
  balance: createCurrency({
86
89
  amount: data.amount.after,
87
- symbol: symbol,
90
+ symbol: unitsToUse,
88
91
  denominator: decimals,
89
92
  }),
90
93
  });
@@ -99,7 +102,7 @@ const handleExpectedBalanceChange = (expectedBalanceChange, simulationResult, {
99
102
  asset: asset_,
100
103
  balance,
101
104
  };
102
- if (isNftTransfer) {
105
+ if (isNftTransfer || isNftTransferApproval) {
103
106
  const tokenId = data.tokenId;
104
107
  const compositeId = `${asset.address}/${tokenId}`;
105
108
  balanceChange.nft = {
package/lib/types.d.ts CHANGED
@@ -34,6 +34,7 @@ export declare type EthWalletWatchAssetOptions = {
34
34
  symbol?: string;
35
35
  decimals?: number;
36
36
  image?: string;
37
+ chainId?: number;
37
38
  };
38
39
  export interface EthWalletWatchAsset {
39
40
  type: string;
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.24.0",
4
+ "version": "3.26.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -26,15 +26,14 @@
26
26
  "build": "yarn clean && run -T tsc"
27
27
  },
28
28
  "devDependencies": {
29
- "@exodus/web3-types": "0.0.0",
30
- "@types/lodash": "^4"
29
+ "@exodus/web3-types": "0.0.0"
31
30
  },
32
31
  "dependencies": {
32
+ "@exodus/basic-utils": "^2.5.1",
33
33
  "@exodus/ethereumjs-common": "^2.4.0-exodus.6",
34
34
  "@exodus/ethereumjs-tx": "^3.3.0-exodus.6",
35
35
  "@exodus/web3-utils": "^1.43.0",
36
- "@metamask/eth-sig-util": "^4.0.1",
37
- "lodash": "^4.17.21"
36
+ "@metamask/eth-sig-util": "^4.0.1"
38
37
  },
39
- "gitHead": "2907aa869e958d805f8652dec0b577fc84235632"
38
+ "gitHead": "72b174eaf91aa9efd0cf1e1ddf0db78d30069671"
40
39
  }