@exodus/solana-lib 1.6.5 → 1.6.6
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 +3 -2
- package/src/index.js +1 -0
- package/src/key-identifier.js +36 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-lib",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"description": "Exodus internal Solana low-level library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@exodus/asset-lib": "^3.7.1",
|
|
17
17
|
"@exodus/buffer-layout": "^1.2.0-exodus1",
|
|
18
|
+
"@exodus/key-utils": "^3.1.0",
|
|
18
19
|
"@exodus/models": "^8.10.4",
|
|
19
20
|
"@exodus/solana-meta": "^1.0.2",
|
|
20
21
|
"@exodus/solana-spl-token": "0.1.8-exodus.1",
|
|
@@ -26,5 +27,5 @@
|
|
|
26
27
|
"lodash": "^4.17.11",
|
|
27
28
|
"tweetnacl": "^1.0.3"
|
|
28
29
|
},
|
|
29
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "752eba9b060c07db518f06c154d905378bcb7b3c"
|
|
30
31
|
}
|
package/src/index.js
CHANGED
|
@@ -14,5 +14,6 @@ export {
|
|
|
14
14
|
} from './vendor'
|
|
15
15
|
export { default as Transaction } from './transaction'
|
|
16
16
|
export { U64 } from './helpers/spl-token'
|
|
17
|
+
export { default as createGetKeyIdentifier } from './key-identifier'
|
|
17
18
|
export { default as getTransactionStrategy } from './helpers/transaction-strategy'
|
|
18
19
|
export { default as VersionedTransaction } from './versioned-transaction'
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import assert from 'minimalistic-assert'
|
|
2
|
+
import { createGetKeyIdentifier, unhardenDerivationIndex } from '@exodus/key-utils'
|
|
3
|
+
|
|
4
|
+
export default ({ bip44, assetName, keyType } = {}) => (params = {}) => {
|
|
5
|
+
assert(typeof bip44 === 'number', 'bip44 must be a number')
|
|
6
|
+
|
|
7
|
+
const { compatibilityMode, purpose, accountIndex = 0, addressIndex = 0 } = params
|
|
8
|
+
const unhardenedBip44 = unhardenDerivationIndex(bip44)
|
|
9
|
+
|
|
10
|
+
switch (compatibilityMode) {
|
|
11
|
+
case 'phantom':
|
|
12
|
+
// Phantom doesn't use chainIndex (normal vs change address)
|
|
13
|
+
return {
|
|
14
|
+
assetName,
|
|
15
|
+
derivationAlgorithm: 'SLIP10',
|
|
16
|
+
derivationPath: `m/${purpose}'/${unhardenedBip44}'/${accountIndex}'/${addressIndex}'`,
|
|
17
|
+
keyType,
|
|
18
|
+
}
|
|
19
|
+
case 'trust':
|
|
20
|
+
return {
|
|
21
|
+
assetName,
|
|
22
|
+
derivationAlgorithm: 'SLIP10',
|
|
23
|
+
derivationPath: `m/${purpose}'/${unhardenedBip44}'/${accountIndex}'`,
|
|
24
|
+
keyType,
|
|
25
|
+
}
|
|
26
|
+
case 'mathwallet':
|
|
27
|
+
return {
|
|
28
|
+
assetName,
|
|
29
|
+
derivationAlgorithm: 'BIP32',
|
|
30
|
+
derivationPath: `m/${purpose}'/${unhardenedBip44}'/${accountIndex}'/${addressIndex}`,
|
|
31
|
+
keyType,
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
return createGetKeyIdentifier({ bip44, assetName, keyType })(params)
|
|
35
|
+
}
|
|
36
|
+
}
|