@exodus/web3-ethereum-utils 4.4.0 → 4.5.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.
package/lib/signatures.js CHANGED
@@ -1,7 +1,6 @@
1
- import { Common, Hardfork } from '@exodus/ethereumjs/common';
1
+ import { getEthereumJsTxByTransactionProps } from '@exodus/ethereum-lib';
2
2
  import { SignTypedDataVersion, personalSign, signTypedData as ethSigUtilSignTypedData, } from '@exodus/ethereumjs/eth-sig-util';
3
- import { FeeMarketEIP1559Transaction, Transaction as LegacyTransaction, } from '@exodus/ethereumjs/tx';
4
- const custom = Common.default?.custom || Common.custom;
3
+ import assert from 'minimalistic-assert';
5
4
  export function signMessage(message, privateKey) {
6
5
  return personalSign({ privateKey, data: message });
7
6
  }
@@ -9,15 +8,13 @@ export function signTypedData(typedData, privateKey, version = SignTypedDataVers
9
8
  return ethSigUtilSignTypedData({ privateKey, data: typedData, version });
10
9
  }
11
10
  export function signTransaction(transactionParams, privateKey) {
12
- const { chainId, ...transactionData } = transactionParams;
13
- const isEIP1559Enabled = !!transactionParams.maxFeePerGas;
14
- const transaction = isEIP1559Enabled
15
- ? FeeMarketEIP1559Transaction.fromTxData(transactionData, {
16
- common: custom({ chainId }, { hardfork: Hardfork.London }),
17
- })
18
- : LegacyTransaction.fromTxData(transactionData, {
19
- common: custom({ chainId }),
20
- });
11
+ const { chainId, ...transactionProps } = transactionParams;
12
+ assert(typeof chainId === 'number', 'signTransaction must be explicitly passed a chainId');
13
+ const transaction = getEthereumJsTxByTransactionProps({
14
+ chainId,
15
+ eip1559Enabled: Boolean(transactionProps.maxFeePerGas),
16
+ transactionProps,
17
+ });
21
18
  const signedTransaction = transaction.sign(privateKey);
22
19
  return signedTransaction.serialize();
23
20
  }
@@ -163,6 +163,17 @@ export const simulateTransactions = async ({ transactions, apiEndpoint, origin,
163
163
  errorMessage: error?.humanReadableError,
164
164
  };
165
165
  }
166
+ const { action } = response;
167
+ if (action === 'BLOCK') {
168
+ const warning = {
169
+ kind: 'MALICIOUS_ACTION',
170
+ severity: 'CRITICAL',
171
+ // We use a generic default message unless we find a known warning type below
172
+ // (TODO: add known warning types)
173
+ message: 'This dApp could be malicious. Do not proceed unless you are certain this is safe.',
174
+ };
175
+ simulationResult.warnings.push(warning);
176
+ }
166
177
  const noExpectedStateChangesDetected = Object.keys(expectedStateChanges).length === 0;
167
178
  // This is a self-send transaction, adding a zero "transfer" so that the UI can display it.
168
179
  if (noExpectedStateChangesDetected) {
@@ -1,6 +1,10 @@
1
1
  import type { EthTransaction } from './types.js';
2
2
  import type { ApprovalBalanceChange } from '@exodus/web3-types';
3
- export declare function getTransactionId(serializedTransaction: Buffer, isEIP1559Transaction?: boolean): string;
3
+ export declare function getTransactionId({ chainId, serializedTransaction, }: {
4
+ chainId: number;
5
+ serializedTransaction: Buffer;
6
+ eip1559Enabled?: boolean;
7
+ }): string;
4
8
  export declare function getDisplayDetails(willApprove: ApprovalBalanceChange[]): {
5
9
  title: string;
6
10
  };
@@ -1,10 +1,10 @@
1
- import { FeeMarketEIP1559Transaction, Transaction as LegacyTransaction, } from '@exodus/ethereumjs/tx';
1
+ import { getEthereumJsTxByTransactionBuffer } from '@exodus/ethereum-lib';
2
2
  import SolidityContract from '@exodus/solidity-contract';
3
- export function getTransactionId(serializedTransaction, isEIP1559Transaction = false) {
4
- const Transaction = isEIP1559Transaction
5
- ? FeeMarketEIP1559Transaction
6
- : LegacyTransaction;
7
- const transaction = Transaction.fromSerializedTx(serializedTransaction);
3
+ export function getTransactionId({ chainId, serializedTransaction, }) {
4
+ const transaction = getEthereumJsTxByTransactionBuffer({
5
+ chainId,
6
+ transactionBuffer: serializedTransaction,
7
+ });
8
8
  return `0x${transaction.hash().toString('hex')}`;
9
9
  }
10
10
  export function getDisplayDetails(willApprove) {
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": "4.4.0",
4
+ "version": "4.5.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -34,10 +34,11 @@
34
34
  "test": "run -T exodus-test --jest --esbuild"
35
35
  },
36
36
  "devDependencies": {
37
- "@exodus/web3-types": "1.57.1"
37
+ "@exodus/web3-types": "1.59.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@exodus/basic-utils": "^3.0.1",
41
+ "@exodus/ethereum-lib": "^5.18.1",
41
42
  "@exodus/ethereumjs": "^1.5.0",
42
43
  "@exodus/solidity-contract": "^1.2.1",
43
44
  "@exodus/web3-utils": "^1.50.1",
@@ -48,5 +49,5 @@
48
49
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Aweb3-ethereum-utils"
49
50
  },
50
51
  "homepage": "https://github.com/ExodusMovement/assets/tree/master/web3/web3-ethereum-utils",
51
- "gitHead": "45be970be70f9211b8a6489566c352f4caeb82dc"
52
+ "gitHead": "f6ea2714c95f2e7ec71ffecdc589726b7974511e"
52
53
  }