@exodus/ethereum-api 3.2.6 → 3.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "3.2.6",
3
+ "version": "3.3.0",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -15,10 +15,12 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@exodus/asset-lib": "^3.7.1",
18
+ "@exodus/bip32": "^1.0.0",
18
19
  "@exodus/crypto": "^1.0.0-rc.0",
19
20
  "@exodus/ethereum-lib": "^2.24.1",
20
21
  "@exodus/ethereumjs-util": "^7.1.0-exodus.6",
21
22
  "@exodus/fetch": "^1.2.1",
23
+ "@exodus/key-utils": "^1.0.0",
22
24
  "@exodus/simple-retry": "^0.0.6",
23
25
  "@exodus/solidity-contract": "^1.1.3",
24
26
  "bn.js": "^5.2.1",
@@ -35,5 +37,5 @@
35
37
  "devDependencies": {
36
38
  "@exodus/models": "^8.10.4"
37
39
  },
38
- "gitHead": "7946545f70f53529e2d73a027ca5020d0c895800"
40
+ "gitHead": "05e33402ff22c430d96e76bef07191d60743496c"
39
41
  }
package/src/index.js CHANGED
@@ -9,3 +9,4 @@ export * from './tx-log'
9
9
  export * from './get-balances'
10
10
  export * from './staking'
11
11
  export * from './simulate-tx'
12
+ export { default as createGetKeyIdentifier } from './key-identifier'
@@ -0,0 +1,35 @@
1
+ import assert from 'minimalistic-assert'
2
+ import { assertKeyIdentifierParameters, unhardenDerivationIndex } from '@exodus/key-utils'
3
+
4
+ function createGetKeyIdentifier({ bip44, allowMetaMaskCompat = false }) {
5
+ return (partialParams) => {
6
+ const params = {
7
+ purpose: 44,
8
+ chainIndex: 0,
9
+ accountIndex: 0,
10
+ addressIndex: 0,
11
+ ...partialParams,
12
+ }
13
+ assertKeyIdentifierParameters(params)
14
+
15
+ const { accountIndex, compatibilityMode, addressIndex } = params
16
+ const unhardenedBip44 = unhardenDerivationIndex(bip44)
17
+ const isMetaMask = allowMetaMaskCompat && compatibilityMode === 'metamask'
18
+
19
+ if (isMetaMask) {
20
+ assert(addressIndex === 0, 'MetaMask compatibility does not support setting an addressIndex')
21
+ }
22
+ // MetaMasks bumps addressIndex instead of accountIndex
23
+ const pathMetaMask = `m/44'/${unhardenedBip44}'/0'/0/${accountIndex}`
24
+ const pathExodus = `m/44'/${unhardenedBip44}'/${accountIndex}'/0/${addressIndex}`
25
+ const derivationPath = isMetaMask ? pathMetaMask : pathExodus
26
+
27
+ return {
28
+ derivationAlgorithm: 'BIP32',
29
+ derivationPath,
30
+ keyType: 'secp256k1',
31
+ }
32
+ }
33
+ }
34
+
35
+ export default createGetKeyIdentifier
@@ -1,3 +1,5 @@
1
+ import { fetch } from '@exodus/fetch'
2
+
1
3
  const ETHEREUM_TX_PREVIEW_API = 'https://simulation.a.exodus.io/simulate'
2
4
 
3
5
  export async function fetchTxPreview(transaction) {