@@ -7,10 +7,11 @@ import EncryptedStorage from 'react-native-encrypted-storage';
7
7
import { ProviderMnemonicBaseOptions } from './types' ;
8
8
9
9
import { ITEM_KEYS , WalletType } from '../../constants' ;
10
+ import { Multichain } from '../../services/multichain' ;
10
11
import { compressPublicKey } from '../../utils' ;
11
12
import { getMnemonic } from '../../utils/mnemonic/get-mnemonic' ;
12
13
import { ProviderBase } from '../base-provider' ;
13
- import { ProviderBaseOptions , ProviderInterface } from '../types' ;
14
+ import { NETWORK_TYPE , ProviderBaseOptions , ProviderInterface } from '../types' ;
14
15
15
16
export class ProviderMnemonicBase
16
17
extends ProviderBase < ProviderMnemonicBaseOptions >
@@ -27,6 +28,7 @@ export class ProviderMnemonicBase
27
28
mnemonic === null
28
29
? ( await generateEntropy ( 16 ) ) . toString ( 'hex' )
29
30
: mnemonicToEntropy ( mnemonic ) ;
31
+
30
32
const seed = await mnemonicToSeed ( entropyToMnemonic ( entropy ) ) ;
31
33
32
34
const privateData = await encryptShare (
@@ -117,7 +119,7 @@ export class ProviderMnemonicBase
117
119
}
118
120
119
121
async getAccountInfo ( hdPath : string ) {
120
- let resp = { publicKey : '' , address : '' } ;
122
+ let resp = { publicKey : '' , address : '' , tronAddress : '' } ;
121
123
try {
122
124
const share = await getMnemonic (
123
125
this . _options . account ,
@@ -130,17 +132,22 @@ export class ProviderMnemonicBase
130
132
131
133
const seed = await ProviderMnemonicBase . shareToSeed ( share ) ;
132
134
133
- const privateKey = await derive ( seed , hdPath ) ;
135
+ const ethPrivateKey = await derive ( seed , hdPath ) ;
134
136
135
- if ( ! privateKey ) {
137
+ if ( ! ethPrivateKey ) {
136
138
throw new Error ( 'private_key_not_found' ) ;
137
139
}
138
140
139
- const account = await accountInfo ( privateKey ) ;
141
+ const account = await accountInfo ( ethPrivateKey ) ;
140
142
141
143
resp = {
142
144
publicKey : compressPublicKey ( account . publicKey ) ,
143
145
address : account . address ,
146
+ tronAddress : await Multichain . generateAddress (
147
+ NETWORK_TYPE . TRON ,
148
+ hdPath ,
149
+ await this . getMnemonicPhrase ( ) ,
150
+ ) ,
144
151
} ;
145
152
this . emit ( 'getPublicKeyForHDPath' , true ) ;
146
153
} catch ( e ) {
0 commit comments