Skip to content

refactor: remove incorrect address assignment in Web3Wallet initialization#520

Merged
blueogin merged 4 commits into
masterfrom
fix/default-wallet-address
Apr 14, 2026
Merged

refactor: remove incorrect address assignment in Web3Wallet initialization#520
blueogin merged 4 commits into
masterfrom
fix/default-wallet-address

Conversation

@blueogin
Copy link
Copy Markdown
Collaborator

@blueogin blueogin commented Mar 30, 2026

Description

Remove incorrect default address assignment in web3Wallet initialization

About # (link your issue here)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request (for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

Summary by Sourcery

Bug Fixes:

  • Prevent Web3Wallet from automatically assigning its primary address to the first derived or KMS-provided address during initialization, avoiding incorrect address state.

Copy link
Copy Markdown
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 left some high level feedback:

  • Now that this.address is no longer set in the KMS and mnemonic paths, verify whether the class still needs a separate address property at all and either remove it entirely or make addresses[0] the single source of truth to avoid inconsistent state.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that `this.address` is no longer set in the KMS and mnemonic paths, verify whether the class still needs a separate `address` property at all and either remove it entirely or make `addresses[0]` the single source of truth to avoid inconsistent state.

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.

Comment thread src/server/blockchain/Web3Wallet.js Outdated
this.address = this.filledAddresses[0]
this.proxyContract = new this.web3.eth.Contract(AdminWalletABI, adminWalletAddress, { from: this.address })

if (this.conf.topAdminsOnStartup) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes but now after calling topadmins there could be more admin accounts that are available.
previously the topadmins was called before searching for valid admin accounts

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.

I don’t think that scenario is possible.
topAdmins simply gets this.conf.numberOfAdminWalletAccounts and doesn’t rely on the filtered admin account array (this.filledAddress).
Because of that, the change shouldn’t be related to the set of available admin accounts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The scenario is happening by design.
The first step selects addresses into filledAddresses, those that have a balance. If they dont have a balance they wont be selected.
After topadmins they can now have a balance.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@blueogin ping

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.

Ah got it, I will initialize this.filledAddresses after topAdmin.

Copy link
Copy Markdown
Collaborator Author

@blueogin blueogin Apr 14, 2026

Choose a reason for hiding this comment

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

I have updated the logic
You can review now @sirpy

@blueogin blueogin requested a review from sirpy April 14, 2026 12:08
Comment thread src/server/blockchain/Web3Wallet.js
@blueogin blueogin merged commit a850c5d into master Apr 14, 2026
10 checks passed
@blueogin blueogin deleted the fix/default-wallet-address branch April 14, 2026 15:02
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.

3 participants