-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetPrivateKey.ts
110 lines (100 loc) · 2.74 KB
/
getPrivateKey.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* eslint-disable no-console */
import { CHAIN, Aptos, Cosmos, Ethereum, Eth2, Near, Solana, Sui, Ton } from '@dsrv/kms';
/* Aptos getPrivateKey */
export const getAptosPrivateKey = (mnemonic: string): string => {
const aptosPrivateKey = Aptos.getPrivateKey({
mnemonic,
path: { type: CHAIN.APTOS, account: 0, index: 0 },
});
return aptosPrivateKey;
};
/* Cosmos getPrivateKey */
export const getCosmosPrivateKey = (mnemonic: string): string => {
const cosmosPrivateKey = Cosmos.getPrivateKey({
mnemonic,
path: { type: CHAIN.COSMOS, account: 0, index: 0 },
});
return cosmosPrivateKey;
};
/* Ethereum getPrivateKey */
export const getEthereumPrivateKey = (mnemonic: string): string => {
const ethereumPrivateKey = Ethereum.getPrivateKey({
mnemonic,
path: { type: CHAIN.ETHEREUM, account: 0, index: 0 },
});
return ethereumPrivateKey;
};
/* Celo getPrivateKey */
export const getCeloPrivateKey = (mnemonic: string): string => {
const celoPrivateKey = Ethereum.getPrivateKey({
mnemonic,
path: { type: CHAIN.ETHEREUM, account: 0, index: 0 },
});
return celoPrivateKey;
};
/* Eth2 getPrivateKey (withdrawal) */
export const getEth2PrivateKeyWithdrawal = (mnemonic: string): string => {
const eth2PrivateKeyWithdrawal = Eth2.getPrivateKey(
{
mnemonic,
path: {
type: CHAIN.ETHEREUM,
account: 0,
index: 0,
},
},
{
keyType: 'withdrawal',
},
);
return eth2PrivateKeyWithdrawal;
};
/* Eth2 getPrivateKey (signing) */
export const getEth2PrivateKeySign = (mnemonic: string): string => {
const eth2PrivateKeySign = Eth2.getPrivateKey(
{
mnemonic,
path: {
type: CHAIN.ETHEREUM,
account: 0,
index: 0,
},
},
{
keyType: 'signing',
},
);
return eth2PrivateKeySign;
};
/* Near getPrivateKey */
export const getNearPrivateKey = (mnemonic: string): string => {
const nearPrivateKey = Near.getPrivateKey({
mnemonic,
path: { type: CHAIN.NEAR, account: 0, index: 1 },
});
return nearPrivateKey;
};
/* Solana getPrivateKey */
export const getSolanaPrivateKey = (mnemonic: string): string => {
const solanaPrivateKey = Solana.getPrivateKey({
mnemonic,
path: { type: CHAIN.SOLANA, account: 0, index: 0 },
});
return solanaPrivateKey;
};
/* Sui getPrivateKey */
export const getSuiPrivateKey = (mnemonic: string): string => {
const suiPrivateKey = Sui.getPrivateKey({
mnemonic,
path: { type: CHAIN.SUI, account: 0, index: 0 },
});
return suiPrivateKey;
};
/* Sui getPrivateKey */
export const getTonPrivateKey = (mnemonic: string): string => {
const tonPrivateKey = Ton.getPrivateKey({
mnemonic,
path: { type: CHAIN.TON, account: 0, index: 0 },
});
return tonPrivateKey;
};