feat(wallets): add get_wallet_names rpc#2202
Conversation
| let activated_wallet = ctx.wallet_name.ok_or(GetWalletsError::Internal( | ||
| "`wallet_name` not initialized yet!".to_string(), | ||
| ))?; |
There was a problem hiding this comment.
could you explain please, how you get Ok result in non-login mode with null activated_wallet, if you return Err when wallet_name None?
No-Login Mode Response from pr info
{
"mmrpc": "2.0",
"result": {
"wallet_names": ["Test 1", "Test 2"],
"activated_wallet": null
},
"id": null
}
There was a problem hiding this comment.
There was a problem hiding this comment.
I just ran into the same issue :) Maybe we should make it more explicit with some helpful comments?
(Unresolving the topic to make it visible - feel free to re-resolve the topic once you see it)
There was a problem hiding this comment.
Thanks. I've implemented it into the KDF Flutter SDK and confirmed it's working and fits the GUI's needs.
The only point I want to make you aware of, @shamardy, is that I have to do a workaround where I spin up and a non-auth instance so that I can query the list of wallets and then stop, and (attempt to) restart it when user tries to sign in.
Long-term, it would be ideal if we can change auth states using RPCs while KDF is already running.
The SDK example app above provides basic wallet functionality with 0 GUI storage for authentication or seed generation. I will share a demo site link.
I thought we already do that in komodo wallet GUI (web). AFAIK, web GUI starts in no-login mode so that any user can see orderbooks, etc.. |
We're starting fresh for the Frontend SDK. There's a lot of things that aren't ideal with the current GUI project KDF integration. One pain point in particular for the above is it's unreliable/messy to sift through the logs to parse for exceptions we need to throw in the GUI. At least with an RPC, we will know the result as soon as it's determined, and a response payload would be easier and more reliable for parsing in the UI. This isn't urgent or something that has to be addressed now since the latered SDK architecture means it can be addressed without major refactoring in the future. |
laruh
left a comment
There was a problem hiding this comment.
All is good, just one question/suggestion and one note
What happens when we connect to an external wallet? |
onur-ozkan
left a comment
There was a problem hiding this comment.
Any chance for adding test coverage for this implementation?
| let activated_wallet = ctx.wallet_name.ok_or(GetWalletsError::Internal( | ||
| "`wallet_name` not initialized yet!".to_string(), | ||
| ))?; |
There was a problem hiding this comment.
I just ran into the same issue :) Maybe we should make it more explicit with some helpful comments?
(Unresolving the topic to make it visible - feel free to re-resolve the topic once you see it)
mariocynicys
left a comment
There was a problem hiding this comment.
Only some nits, LGTM otherwise!
@onur-ozkan External wallet connection is done through coins activation as these wallets are coin dependant. This PR is for wallet names related to KDF mnemonic or passphrase that we init KDF with. I guess we can add an option in another PR to start mm2 using an external wallet and delay crypto ctx initialization until it's needed for certain coins. It will be a big refactor but will make komodo wallet as a Dapp (e.g. Keplr integration) much smoother and will lead to better UX. Edit: Opened issue for this #2225 |
Sure, will try to add some tests. |
Tests added here 1a7c003 |
…stems_with_extension` into a single `list_files_by_extension` function
4e46c35
* dev: fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
* dev: fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
* dev: fix(cosmos): fix tx broadcasting error (#2238) chore(solana): remove solana implementation (#2239) chore(cli): remove leftover subcommands from help message (#2235) fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
This PR introduces the
get_wallet_namesRPC method, which allows clients to retrieve information about all wallet names and the currently active one.get_wallet_namesMethod: Retrieves all wallet names and the active wallet's name if there is an active one. If there is no active wallet (no-login mode), it returns null for the active wallet's name.Example Request and Responses:
Request:
{ "userpass": "{{userpass}}", "mmrpc": "2.0", "method": "get_wallet_names" }No-Login Mode Response:
{ "mmrpc": "2.0", "result": { "wallet_names": ["Test 1", "Test 2"], "activated_wallet": null }, "id": null }Activated Wallet Response:
{ "mmrpc": "2.0", "result": { "wallet_names": ["Test 1", "Test 2"], "activated_wallet": "Test 1" }, "id": null }To Test: @KomodoPlatform/qa
Example request and responses are above, I already tested this and @CharlVS probably did too, so it's not a high priority.