@exodus/web3-ethereum 1.4.6 → 1.5.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,6 +2,7 @@ import { AssetNotSupportedError, InvalidInputError, UnauthorizedError, UserRejec
2
2
  import { getTransactionId, signMessage, signTransaction, signTypedData, } from '@exodus/web3-ethereum-utils';
3
3
  import { SignTypedDataVersion } from '@metamask/eth-sig-util';
4
4
  import { parseAndValidateTypedData } from './parseAndValidateTypedData.js';
5
+ import { simulateTransaction } from '../simulation/index.js';
5
6
  // See: https://eips.ethereum.org/EIPS/eip-2255.
6
7
  const ETH_ACCOUNTS_PERMISSION = 'eth_accounts';
7
8
  const PROXIED_METHODS = [
@@ -47,7 +48,7 @@ version) {
47
48
  return typedData.toString();
48
49
  }
49
50
  export function exposeHandlers(rpc, deps) {
50
- const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getAddress, getPrivateKey, getEstimatedGas, getFeeData, getNonce, sendRawTransaction, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = () => true, } = deps;
51
+ const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getAddress, getPrivateKey, getEstimatedGas, getFeeData, getNonce, sendRawTransaction, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = () => true, asset, } = deps;
51
52
  const network = `evm:${chainId}`;
52
53
  async function assertTrusted() {
53
54
  const trusted = await isTrusted();
@@ -107,7 +108,8 @@ export function exposeHandlers(rpc, deps) {
107
108
  await assertTrusted();
108
109
  const preparedTransaction = await prepareTransaction(transaction);
109
110
  validateTransaction(preparedTransaction);
110
- await approve(approveTransactions, network, [preparedTransaction]);
111
+ const simulatedChanges = await simulateTransaction(asset, preparedTransaction);
112
+ await approve(approveTransactions, network, simulatedChanges);
111
113
  const privateKey = await getPrivateKey();
112
114
  const signedTransaction = signTransaction({ ...preparedTransaction, chainId }, privateKey);
113
115
  const isEIP1559Enabled = !!preparedTransaction.maxFeePerGas;
@@ -1,18 +1,10 @@
1
+ import type { Asset } from '@exodus/web3-types';
2
+ export { Asset };
1
3
  export interface CurrencyParams {
2
4
  amount: string;
3
5
  symbol: string;
4
6
  denominator: number;
5
7
  }
6
- export interface Asset {
7
- name: string;
8
- displayTicker: string;
9
- currency: {
10
- defaultUnit: {
11
- power: number;
12
- };
13
- baseUnit: (args: unknown) => unknown;
14
- };
15
- }
16
8
  export interface EthBalanceChanges {
17
9
  willReceive: Array<EthBalanceChange>;
18
10
  willSend: Array<EthBalanceChange>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exodus/web3-ethereum",
3
3
  "description": "Apps connectivity library for EVM-compatible chains.",
4
- "version": "1.4.6",
4
+ "version": "1.5.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -33,22 +33,22 @@
33
33
  "dependencies": {
34
34
  "@exodus/currency": "^2.1.2",
35
35
  "@exodus/ethereum-api": "^3.2.4",
36
- "@exodus/web3-constants": "^1.14.0",
36
+ "@exodus/web3-constants": "^1.15.0",
37
37
  "@exodus/web3-ethereum-utils": "^1.8.0",
38
- "@exodus/web3-provider": "^2.12.0",
39
- "@exodus/web3-rpc-handlers": "^0.7.0",
38
+ "@exodus/web3-provider": "^2.13.0",
39
+ "@exodus/web3-rpc-handlers": "^0.8.0",
40
40
  "eth-rpc-errors": "^4.0.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@exodus/assets": "^8.0.72",
44
44
  "@exodus/json-rpc": "^1.11.0",
45
45
  "@exodus/schemasafe": "^1.0.0",
46
- "@exodus/web3-types": "^1.10.0",
46
+ "@exodus/web3-types": "^1.11.0",
47
47
  "@exodus/web3-validation": "^1.29.2",
48
48
  "@wallet-standard/base": "^1.0.1"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@exodus/assets": "^8.0.72"
52
52
  },
53
- "gitHead": "4d9d6eed59fbe201c1e6f2abb4b50f1f336bc690"
53
+ "gitHead": "4a0c077d0175fe3c6a35e2f9a459f8cad214e8f6"
54
54
  }