@exodus/ethereum-lib 5.5.0 → 5.6.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,15 @@
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.6.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.5.0...@exodus/ethereum-lib@5.6.0) (2024-10-04)
7
+
8
+
9
+ ### Features
10
+
11
+ * **ethereum-lib:** use 'sig,rec' keychain enc ([#4155](https://github.com/ExodusMovement/assets/issues/4155)) ([d928541](https://github.com/ExodusMovement/assets/commit/d92854184bd26380192a224564b6dca924504975))
12
+
13
+
14
+
6
15
  ## [5.5.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.4.0...@exodus/ethereum-lib@5.5.0) (2024-09-13)
7
16
 
8
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "5.5.0",
3
+ "version": "5.6.0",
4
4
  "description": "Ethereum Library",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -27,7 +27,7 @@
27
27
  "@exodus/ethereumjs-common": "^2.4.0-exodus.6",
28
28
  "@exodus/ethereumjs-tx": "^3.3.0-exodus.7",
29
29
  "@exodus/ethereumjs-util": "^7.1.0-exodus.7",
30
- "@exodus/key-utils": "^3.1.0",
30
+ "@exodus/key-utils": "^3.7.0",
31
31
  "@exodus/models": "^12.0.1",
32
32
  "@exodus/solidity-contract": "^1.1.3",
33
33
  "@metamask/eth-sig-util": "^4.0.1",
@@ -42,7 +42,7 @@
42
42
  "@exodus/assets": "^11.0.0",
43
43
  "@exodus/bitcoin-meta": "^2.0.0",
44
44
  "@exodus/bsc-meta": "^2.0.0",
45
- "@exodus/elliptic": "^6.5.4-precomputed",
45
+ "@exodus/crypto": "^1.0.0-rc.13",
46
46
  "@exodus/ethereumclassic-meta": "^2.0.0",
47
47
  "@exodus/fantommainnet-meta": "^2.0.0",
48
48
  "@exodus/matic-meta": "^2.0.0"
@@ -54,5 +54,5 @@
54
54
  "type": "git",
55
55
  "url": "git+https://github.com/ExodusMovement/assets.git"
56
56
  },
57
- "gitHead": "476cff14cc4c30ee72c85b3d265055771b48c1d1"
57
+ "gitHead": "a20bb277d8dfa3d3137d35ee8fa45333f9dd91d3"
58
58
  }
@@ -1,6 +1,5 @@
1
- import { hashPersonalMessage, toBuffer } from '@exodus/ethereumjs-util'
1
+ import { hashPersonalMessage } from '@exodus/ethereumjs-util'
2
2
  import {
3
- concatSig,
4
3
  personalSign,
5
4
  signTypedData,
6
5
  SignTypedDataVersion,
@@ -56,19 +55,10 @@ export const signMessage = async ({ privateKey, message }) => {
56
55
  }
57
56
  }
58
57
 
59
- /**
60
- * @typedef {import('bn.js').BN} BN
61
- * @typedef {{r: BN, s: BN, recoverParam: number}} Signature
62
- * @typedef {{
63
- * sign: ({ data: Buffer, ecOptions?: { canonical?: boolean }, enc?: string }) => Promise<Signature | Buffer>
64
- * getPublicKey: () => Promise<Buffer>
65
- * }} Signer
66
- */
67
-
68
58
  /**
69
59
  * @param {object} params
70
60
  * @param {{rawMessage: Buffer, EIP712Message: any}} params.message
71
- * @param {Signer} signer
61
+ * @param {object} signer
72
62
  * @returns {Promise<string>}
73
63
  */
74
64
  export async function signMessageWithSigner({ message, signer }) {
@@ -79,20 +69,14 @@ export async function signMessageWithSigner({ message, signer }) {
79
69
  ? getEIP712MessageHash(EIP712Message)
80
70
  : hashPersonalMessage(rawMessage)
81
71
 
82
- const sig = await signer.sign({
72
+ const { signature, recovery } = await signer.sign({
83
73
  data: msgHash,
84
- ecOptions: { canonical: true },
85
- enc: 'raw',
74
+ enc: 'sig,rec',
86
75
  signatureType: 'ecdsa',
87
76
  })
88
77
 
89
- return hex0xStringToBuffer(
90
- concatSig(
91
- toBuffer(normalizeRecoveryParam(sig.recoveryParam, { includeBase: true })),
92
- sig.r.toBuffer(),
93
- sig.s.toBuffer()
94
- )
95
- )
78
+ const recoveryNormalized = normalizeRecoveryParam(recovery, { includeBase: true })
79
+ return Buffer.concat([signature, new Uint8Array([recoveryNormalized])])
96
80
  }
97
81
 
98
82
  function getEIP712MessageHash(message) {
@@ -11,14 +11,12 @@ export async function signUnsignedTxWithSigner(unsignedTx, signer) {
11
11
  const tx = createEthereumJsTx(unsignedTx)
12
12
 
13
13
  const ethSigner = async (data) => {
14
- // temporarily support both function and object
15
- const sig = await (typeof signer === 'function'
16
- ? signer({ data, ecOptions: { canonical: true }, enc: 'raw', signatureType: 'ecdsa' })
17
- : signer.sign({ data, ecOptions: { canonical: true }, enc: 'raw', signatureType: 'ecdsa' }))
18
- const signature = new Uint8Array(64)
19
- signature.set(sig.r.toArrayLike(Uint8Array, 'be', 32), 0)
20
- signature.set(sig.s.toArrayLike(Uint8Array, 'be', 32), 32)
21
- return { signature, recid: sig.recoveryParam }
14
+ const { signature, recovery } = await signer.sign({
15
+ data,
16
+ enc: 'sig,rec',
17
+ signatureType: 'ecdsa',
18
+ })
19
+ return { signature, recid: recovery }
22
20
  }
23
21
 
24
22
  const signedTx = await tx.signWithSigner(ethSigner)
@@ -1,13 +1,10 @@
1
1
  import { FeeMarketEIP1559Transaction, Transaction } from '@exodus/ethereumjs-tx'
2
2
  import * as ethUtil from '@exodus/ethereumjs-util'
3
3
  import baseX from 'base-x'
4
- import lodash from 'lodash'
5
4
 
6
5
  // eslint-disable-next-line @exodus/import/no-deprecated
7
6
  import { ETHEREUM_LIKE_NO_HISTORY_ASSET_NAMES } from '../constants.js'
8
7
 
9
- const { uniq } = lodash
10
-
11
8
  export { default as calculateExtraEth } from './calculate-extra-eth.js'
12
9
 
13
10
  const base10 = baseX('0123456789')
@@ -175,5 +172,5 @@ export const getAssetAddresses = (asset) => {
175
172
  ...(asset.addresses?.previous || []), // asset in wallets:
176
173
  ...(asset.contract?.previous || []), // asset in @exodus/assets-base:
177
174
  ]
178
- return uniq(addresses.filter((a) => a && typeof a === 'string'))
175
+ return [...new Set(addresses.filter((a) => a && typeof a === 'string'))]
179
176
  }