@exodus/ethereum-lib 4.2.0 → 4.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-lib",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
"@exodus/solidity-contract": "^1.1.3",
|
|
41
41
|
"base-x": "^3.0.2",
|
|
42
42
|
"lodash": "^4.17.15",
|
|
43
|
+
"minimalistic-assert": "^1.0.1",
|
|
43
44
|
"ms": "^2.1.1",
|
|
44
45
|
"reselect": "~3.0.1"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "419d8b4d0d4f8617b8da97a5dd9d3e328a948ae6"
|
|
47
48
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import assert from 'minimalistic-assert'
|
|
1
2
|
import createEthereumJsTx from './create-ethereumjs-tx'
|
|
2
3
|
|
|
3
4
|
export const signHardwareFactory = ({ baseAssetName }) => async ({
|
|
@@ -29,14 +30,27 @@ async function signWithHardwareWallet({ baseAssetName, tx, hardwareDevice, accou
|
|
|
29
30
|
})
|
|
30
31
|
|
|
31
32
|
const { signature } = signatures[0]
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
assert(signature.length >= 65, `signature length should be 65 or more`)
|
|
34
|
+
const V_SIZE = signature.length - 64
|
|
35
|
+
let v = Number.parseInt(signature.slice(0, V_SIZE).toString('hex'), '16')
|
|
34
36
|
if (v === 0 || v === 1) {
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
+
// _processSignature for EIP1559 expects 27 or 28.
|
|
38
|
+
// hardware wallets on the other hand already precomputed the final v (0, 1).
|
|
39
|
+
const diff = 27
|
|
40
|
+
v += diff
|
|
41
|
+
} else if (tx.common.chainId !== undefined) {
|
|
42
|
+
// _processSignature for legacy transactions expects 27 or 28.
|
|
43
|
+
// hardware wallets on the other hand already precomputed the final v (chainId * 2 + 35 + parity).
|
|
44
|
+
const diff = tx.common
|
|
45
|
+
.chainIdBN()
|
|
46
|
+
.muln(2)
|
|
47
|
+
.addn(8)
|
|
48
|
+
.toNumber()
|
|
49
|
+
v -= diff
|
|
37
50
|
}
|
|
38
|
-
|
|
39
|
-
const
|
|
51
|
+
assert([27, 28].includes(v), `unexpected v-value, expected 27 or 28 but got ${v} `)
|
|
52
|
+
const r = signature.slice(V_SIZE, V_SIZE + 32)
|
|
53
|
+
const s = signature.slice(V_SIZE + 32, V_SIZE + 32 + 32)
|
|
40
54
|
|
|
41
55
|
return tx._processSignature(v, r, s)
|
|
42
56
|
}
|