New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: import wallet account via mnemonic #233
Conversation
@@ -190,6 +190,49 @@ proc addWalletPrivateKey*(name: string, privateKey: string, password: string) | |||
trace "task sent event to host", event=eventEnc, task | |||
asyncSpawn chanSendToHost.send(eventEnc.safe) | |||
|
|||
proc addWalletSeed*(name: string, mnemonic: string, password: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Styling: consider removing superfluous string type specifiers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this?
proc addWalletSeed*(name, mnemonic, password, bip39Passphrase: string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I just wanted to make sure I understood you correctly. I often forget to take advantage of that shortcut, thanks for the tip!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I myself noticed it in other parts of @emizzle 's code, so all kudos are his :) Didn't think it's possible in Nim.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After trying to make this change, I remember now why I didn't do this perviously for tasks. When combining same-typed parameters in the signature of a task proc, the compiler barfs with this error:
/Users/emizzle/repos/status-im/nim-status/examples/chat/client/tasks.nim(193, 37) Error: initialization not allowed here
I really don't know why, but I'm assuming it has something to do with the task
macro.
examples/chat/client/tasks.nim
Outdated
|
||
let | ||
walletAccount = walletAccountResult.get | ||
walletName = if walletAccount.name.isNone: "" else: walletAccount.name.get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an overloaded Option.get
with a default parameter: https://nim-lang.org/docs/options.html#get,Option[T],T
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, great look! Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
0633c98
to
ff3eb50
Compare
Closes: #224. Allows a user to import a wallet account via 12-word mnemonic seed. The account is first imported in the account generator. Then a wallet account is derived at the root wallet path (m/44'/60’/0’/0/0) from the master key of the mnemonic. This account is then stored in the Accounts table of the user’s db.
ff3eb50
to
5c49188
Compare
Closes: #224.
Allows a user to import a wallet account via 12-word mnemonic seed.
The account is first imported in the account generator. Then a wallet account is derived at the root wallet path (m/44'/60’/0’/0/0) from the master key of the mnemonic. This account is then stored in the Accounts table of the user’s db.