@exodus/ethereum-lib 5.10.2 → 5.12.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.12.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.11.0...@exodus/ethereum-lib@5.12.0) (2025-06-11)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat: ethereum api use balances and nonces data (#5727)
13
+
14
+
15
+
16
+ ## [5.11.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.10.2...@exodus/ethereum-lib@5.11.0) (2025-05-29)
17
+
18
+
19
+ ### Features
20
+
21
+
22
+ * feat: import eth-sig-util sign-typed-data, with fixes (#5716)
23
+
24
+ * feat: unify ethereum signMessage with signMessageWithSigner (#5709)
25
+
26
+
27
+
6
28
  ## [5.10.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.10.1...@exodus/ethereum-lib@5.10.2) (2025-04-29)
7
29
 
8
30
  **Note:** Version bump only for package @exodus/ethereum-lib
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "5.10.2",
3
+ "version": "5.12.0",
4
4
  "description": "Ethereum utils, such as for cryptography, address encoding/decoding, transaction building, etc.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@exodus/basic-utils": "^3.0.1",
25
+ "@exodus/crypto": "^1.0.0-rc.18",
25
26
  "@exodus/currency": "^6.0.1",
26
- "@exodus/ethereumjs": "^1.2.0",
27
+ "@exodus/ethereumjs": "^1.5.0",
27
28
  "@exodus/key-utils": "^3.7.0",
28
- "@exodus/models": "^12.0.1",
29
+ "@exodus/models": "^12.13.0",
29
30
  "@exodus/solidity-contract": "^1.1.3",
30
- "@metamask/eth-sig-util": "^4.0.1",
31
31
  "base-x": "^3.0.2",
32
32
  "lodash": "^4.17.15",
33
33
  "minimalistic-assert": "^1.0.1",
@@ -38,7 +38,6 @@
38
38
  "@exodus/assets": "^11.0.0",
39
39
  "@exodus/bitcoin-meta": "^2.0.0",
40
40
  "@exodus/bsc-meta": "^2.0.0",
41
- "@exodus/crypto": "^1.0.0-rc.13",
42
41
  "@exodus/ethereum-meta": "^2.5.0",
43
42
  "@exodus/ethereumclassic-meta": "^2.0.0",
44
43
  "@exodus/fantommainnet-meta": "^2.0.0",
@@ -51,5 +50,5 @@
51
50
  "type": "git",
52
51
  "url": "git+https://github.com/ExodusMovement/assets.git"
53
52
  },
54
- "gitHead": "63620ef41b7f48c835371ee03ca6443193460fe7"
53
+ "gitHead": "2172464a34a03cb2c2401f80db89d4609cb0528f"
55
54
  }
@@ -1,11 +1,10 @@
1
- import { hashPersonalMessage } from '@exodus/ethereumjs/util'
1
+ import { ecdsaSignHash } from '@exodus/crypto/secp256k1'
2
2
  import {
3
- personalSign,
4
- signTypedData,
5
3
  SignTypedDataVersion,
6
4
  TypedDataUtils,
7
5
  typedSignatureHash,
8
- } from '@metamask/eth-sig-util'
6
+ } from '@exodus/ethereumjs/eth-sig-util'
7
+ import { hashPersonalMessage } from '@exodus/ethereumjs/util'
9
8
  import assert from 'minimalistic-assert'
10
9
 
11
10
  import { normalizeRecoveryParam } from './utils/ecdsa.js'
@@ -19,41 +18,19 @@ function hex0xStringToBuffer(hex) {
19
18
  return Buffer.from(hexWithLeadingZeros, 'hex')
20
19
  }
21
20
 
22
- /**
23
- * Converts a buffer to the 0xhex encoded value
24
- * @param {Buffer} buf the buffer to convert to 0xHEXSTRING
25
- * @returns the hex-encoded value prepended with 0x
26
- */
27
- function bufferToHex0xString(buf) {
28
- if (!Buffer.isBuffer(buf)) {
29
- throw new TypeError('expected a buffer')
30
- }
31
-
32
- const hex = buf.toString('hex')
33
-
34
- if (typeof hex !== 'string') {
35
- throw new TypeError('expected hex string')
36
- }
37
-
38
- return '0x' + hex
39
- }
40
-
41
- export const signMessage = async ({ privateKey, message }) => {
42
- const { rawMessage, EIP712Message } = message
43
-
44
- // Exclusive OR (XOR)
45
- assert(!!rawMessage !== !!EIP712Message, 'Need either rawMessage or EIP712Message')
46
-
47
- if (rawMessage) {
48
- return hex0xStringToBuffer(personalSign({ privateKey, data: bufferToHex0xString(rawMessage) }))
49
- }
50
-
51
- if (EIP712Message) {
52
- const version = Array.isArray(EIP712Message) ? SignTypedDataVersion.V1 : SignTypedDataVersion.V4
53
-
54
- return hex0xStringToBuffer(signTypedData({ privateKey, data: EIP712Message, version }))
55
- }
56
- }
21
+ export const signMessage = async ({ privateKey, message }) =>
22
+ signMessageWithSigner({
23
+ message,
24
+ signer: {
25
+ sign: async ({ data }) =>
26
+ ecdsaSignHash({
27
+ hash: data,
28
+ privateKey,
29
+ recovery: true,
30
+ extraEntropy: null, // TODO: can we flip this to true?
31
+ }),
32
+ },
33
+ })
57
34
 
58
35
  /**
59
36
  * @param {object} params