Skip to content

Conversation

@sirpy
Copy link
Contributor

@sirpy sirpy commented Feb 9, 2026

Description

Add method to check isConnected
use that method only for gas topping related

Summary by Sourcery

Use Identity contract whitelisting to determine wallet connection status and apply it to gas-topping eligibility checks.

New Features:

  • Add an isConnected method to Web3Wallet and MultiWallet to determine if an address is whitelisted in the Identity contract.

Bug Fixes:

  • Restrict gas top-up and related verification checks to accounts that are connected/whitelisted instead of only using the previous verification check.

Copy link
Contributor Author

@sirpy sirpy left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • In Web3Wallet.isConnected, the error log message still says 'Error isVerified', which is misleading now that this is a separate method; update the message to reference isConnected instead.
  • In MultiWallet.isConnected, consider short-circuiting on the first wallet that returns true instead of awaiting Promise.all, so you don't wait for all providers when an early one already confirms connectivity.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `Web3Wallet.isConnected`, the error log message still says `'Error isVerified'`, which is misleading now that this is a separate method; update the message to reference `isConnected` instead.
- In `MultiWallet.isConnected`, consider short-circuiting on the first wallet that returns `true` instead of awaiting `Promise.all`, so you don't wait for all providers when an early one already confirms connectivity.

## Individual Comments

### Comment 1
<location> `src/server/blockchain/Web3Wallet.js:650-654` </location>
<code_context>
+   * @param {string} address
+   * @returns {Promise<boolean>}
+   */
+  async isConnected(address: string): Promise<boolean> {
+    const { log } = this
+
+    const tx: string = await this.identityContract.methods
+      .getWhitelistedRoot(address)
+      .call()
+      .catch(e => {
+        log.error('Error isVerified', e.message, e)
+        throw e
+      })
</code_context>

<issue_to_address>
**issue (typo):** Log message refers to `isVerified` while the function is `isConnected`, which can be confusing when debugging.

In the catch block, the log still says `Error isVerified`, likely from a previous method. Please update it to reference `isConnected` so logs remain clear and distinguishable if both methods are present.

```suggestion
      .call()
      .catch(e => {
        log.error('Error isConnected', e.message, e)
        throw e
      })
```
</issue_to_address>

### Comment 2
<location> `src/server/blockchain/MultiWallet.js:122-124` </location>
<code_context>
     return this.mainWallet.isVerified(account)
   }

+  async isConnected(account) {
+    return (await Promise.all(this.wallets.map(wallet => wallet.isConnected(account)))).find(_ => _)
+  }
+
</code_context>

<issue_to_address>
**suggestion:** The return value of `isConnected` can be `true` or `undefined`, not strictly `boolean`, and could be made clearer and more idiomatic.

Since each `wallet.isConnected` returns a boolean, `.find(_ => _)` yields `true` or `undefined`. That’s fine for truthy checks but unintuitive for an `isConnected` method that callers will expect to return a boolean. You could make this explicit with:

```js
async isConnected(account) {
  const results = await Promise.all(
    this.wallets.map(wallet => wallet.isConnected(account))
  )
  return results.some(Boolean)
}
```

This preserves the intended semantics while guaranteeing a `boolean` return type.

```suggestion
  async isConnected(account) {
    const results = await Promise.all(
      this.wallets.map(wallet => wallet.isConnected(account))
    )
    return results.some(Boolean)
  }
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sirpy sirpy linked an issue Feb 9, 2026 that may be closed by this pull request
1 task
sirpy and others added 2 commits February 9, 2026 10:56
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@sirpy sirpy merged commit 9986a90 into master Feb 12, 2026
26 of 30 checks passed
@sirpy sirpy deleted the feat/use-getWhitelistedRoot branch February 12, 2026 09:26
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.

Faucet: isWhitelist should be replaced with getWhitelistRoot

1 participant