Skip to content

Commit

Permalink
add comment to explain why test wallet revokeKey
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored Oct 3, 2024
1 parent f614cae commit 318abdb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/content/keyAutoAdd/testWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ const getAccounts: Run<Account[]> = async (_, { setNotificationSize }) => {
* The test wallet associates key with an account. If the same key is associated
* with a different account (user disconnected and changed account), revoke from
* there first.
*
* Why? Say, user connected once to `USD -> Addr#1`. Then disconnected. The key
* is still there in wallet added to `USD -> Addr#1` account. If now user wants
* to connect `EUR -> Addr#2` account, the extension still has the same key. So
* adding it again will throw an `internal server error`. But we'll continue
* getting `invalid_client` if we try to connect without the key added to new
* address. That's why we first revoke existing key (by ID) if any (from any
* existing account/address). It's a test-wallet specific thing.
*/
const revokeExistingKey: Run<void> = async ({ keyId }, { skip, output }) => {
const accounts = output(getAccounts);
Expand Down

0 comments on commit 318abdb

Please sign in to comment.