Skip to content

feat(wallets): add get_wallet_names rpc#2202

Merged
shamardy merged 11 commits intodevfrom
feat-get-wallet-rpc
Sep 25, 2024
Merged

feat(wallets): add get_wallet_names rpc#2202
shamardy merged 11 commits intodevfrom
feat-get-wallet-rpc

Conversation

@shamardy
Copy link
Copy Markdown
Collaborator

@shamardy shamardy commented Aug 28, 2024

This PR introduces the get_wallet_names RPC method, which allows clients to retrieve information about all wallet names and the currently active one.

  • get_wallet_names Method: 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.

Copy link
Copy Markdown

@laruh laruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have question

Comment on lines +540 to +542
let activated_wallet = ctx.wallet_name.ok_or(GetWalletsError::Internal(
"`wallet_name` not initialized yet!".to_string(),
))?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, exactly

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator Author

@shamardy shamardy Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment here 704305d

CharlVS
CharlVS previously approved these changes Aug 30, 2024
Copy link
Copy Markdown

@CharlVS CharlVS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

image

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.

@shamardy
Copy link
Copy Markdown
Collaborator Author

shamardy commented Aug 30, 2024

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

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..

@CharlVS
Copy link
Copy Markdown

CharlVS commented Aug 30, 2024

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

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.

Copy link
Copy Markdown

@laruh laruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All is good, just one question/suggestion and one note

laruh
laruh previously approved these changes Sep 17, 2024
Copy link
Copy Markdown

@laruh laruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@onur-ozkan
Copy link
Copy Markdown

get_wallet_names Method: 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.

What happens when we connect to an external wallet?

Copy link
Copy Markdown

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance for adding test coverage for this implementation?

Comment on lines +540 to +542
let activated_wallet = ctx.wallet_name.ok_or(GetWalletsError::Internal(
"`wallet_name` not initialized yet!".to_string(),
))?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
mariocynicys previously approved these changes Sep 18, 2024
Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only some nits, LGTM otherwise!

@shamardy
Copy link
Copy Markdown
Collaborator Author

shamardy commented Sep 19, 2024

What happens when we connect to an external wallet?

@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

@shamardy
Copy link
Copy Markdown
Collaborator Author

Any chance for adding test coverage for this implementation?

Sure, will try to add some tests.

@shamardy shamardy dismissed stale reviews from mariocynicys and laruh via 704305d September 19, 2024 01:24
@shamardy
Copy link
Copy Markdown
Collaborator Author

Any chance for adding test coverage for this implementation?

Tests added here 1a7c003

Copy link
Copy Markdown

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work... just small notes

borngraced
borngraced previously approved these changes Sep 24, 2024
Copy link
Copy Markdown

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welldone!

onur-ozkan
onur-ozkan previously approved these changes Sep 25, 2024
Copy link
Copy Markdown

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor notes. LGTM

@shamardy shamardy dismissed stale reviews from onur-ozkan and borngraced via 4e46c35 September 25, 2024 12:37
@shamardy shamardy merged commit ab23c11 into dev Sep 25, 2024
@shamardy shamardy deleted the feat-get-wallet-rpc branch September 25, 2024 17:05
dimxy pushed a commit that referenced this pull request Oct 4, 2024
* 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)
dimxy pushed a commit that referenced this pull request Oct 4, 2024
* 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)
dimxy pushed a commit that referenced this pull request Oct 17, 2024
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants