hedera-sdk-js
hedera-sdk-js copied to clipboard
Make `words` in `Mnemonic` a publicly visible field
Description
I used to be able to Mnemonic.generate() and access the mnemonic words directly like so ...
Mnemonic.generate().then((mnemonic) => {
const mnemonicPhrase = mnemonic.words; // 👈
// do stuff with `mnemonicPhrase`
})
... but it seems that the words property is now wrapped inside a _mnemonic property, so to have the above example work, I would have to do this:
Mnemonic.generate().then((mnemonic) => {
const mnemonicPhrase = mnemonic._mnemonic.words; // 👈
// do stuff with `mnemonicPhrase`
})
I don't think it's in best practice to access _-prefixed properties like that, so my temporary workaround has been to do ...
Mnemonic.generate().then((mnemonic) => {
const mnemonicPhrase = mnemonic.toString().split(' '); // 👈
// do stuff with `mnemonicPhrase`
})
... but that's pretty verbose and I think it would be very helpful and convenient to just be able to access the words property like in the first example.
Steps to reproduce
Mnemonic.generate().then((mnemonic) => {
// follow steps #2 and #3 in here
})
- Trying to access
mnemonic.wordsshouldn't work. - Trying to see what's inside
mnemonicviaconsole.log(mnemonic)and there should be a_mnemonicproperty that contains the desiredwordsproperty.
Additional context
No response
Hedera network
mainnet
Version
2.18.0
Operating system
No response