From 7bc68f46b00ec27e7cb1a7d96983007346f012fd Mon Sep 17 00:00:00 2001 From: blueogin Date: Mon, 30 Mar 2026 11:36:33 -0400 Subject: [PATCH 1/2] refactor: remove redundant address assignment in Web3Wallet initialization --- src/server/blockchain/Web3Wallet.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/server/blockchain/Web3Wallet.js b/src/server/blockchain/Web3Wallet.js index 6f6aba8f..89bf9f71 100644 --- a/src/server/blockchain/Web3Wallet.js +++ b/src/server/blockchain/Web3Wallet.js @@ -316,7 +316,6 @@ export class Web3Wallet { const keyId = this.kmsWallet.getKeyId(address) this.addKMSWallet(address, keyId) }) - this.address = addresses[0] log.info('WalletInit: Initialized by KMS keys:', { addresses, keyIds: kmsKeyIds, @@ -340,8 +339,6 @@ export class Web3Wallet { this.addWallet(account) } - this.address = this.addresses[0] - log.info('WalletInit: Initialized by mnemonic:', { address: this.addresses }) } else if (this.conf.privateKey) { // Fallback to private key if mnemonic is not configured From 7c24f6b9a56893f5fd9f243abdeabaf021624566 Mon Sep 17 00:00:00 2001 From: blueogin Date: Mon, 30 Mar 2026 11:44:30 -0400 Subject: [PATCH 2/2] refactor: adjust Web3Wallet initialization to bind admin wallet address after selection --- src/server/blockchain/Web3Wallet.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/server/blockchain/Web3Wallet.js b/src/server/blockchain/Web3Wallet.js index 89bf9f71..9960f7a0 100644 --- a/src/server/blockchain/Web3Wallet.js +++ b/src/server/blockchain/Web3Wallet.js @@ -368,7 +368,8 @@ export class Web3Wallet { const adminWalletContractBalance = await this.web3.eth.getBalance(adminWalletAddress) log.info(`WalletInit: AdminWallet contract balance`, { adminWalletContractBalance, adminWalletAddress }) - this.proxyContract = new this.web3.eth.Contract(AdminWalletABI, adminWalletAddress, { from: this.address }) + // Initialize without `from` first, then re-bind after selecting a valid admin wallet. + this.proxyContract = new this.web3.eth.Contract(AdminWalletABI, adminWalletAddress) const maxAdminBalance = await this.proxyContract.methods.adminToppingAmount().call() const minAdminBalance = parseInt(web3Utils.fromWei(maxAdminBalance, 'gwei')) / 2 @@ -387,13 +388,6 @@ export class Web3Wallet { log.info('WalletInit: Initialized wallet queue manager') - if (this.conf.topAdminsOnStartup) { - log.info('WalletInit: calling topAdmins...') - await this.topAdmins(this.conf.numberOfAdminWalletAccounts).catch(e => { - log.warn('WalletInit: topAdmins failed', { e, errMessage: e.message }) - }) - } - log.info('Initializing adminwallet addresses', { addresses: this.addresses }) await Promise.all( @@ -421,6 +415,14 @@ export class Web3Wallet { } this.address = this.filledAddresses[0] + this.proxyContract = new this.web3.eth.Contract(AdminWalletABI, adminWalletAddress, { from: this.address }) + + if (this.conf.topAdminsOnStartup) { + log.info('WalletInit: calling topAdmins...') + await this.topAdmins(this.conf.numberOfAdminWalletAccounts).catch(e => { + log.warn('WalletInit: topAdmins failed', { e, errMessage: e.message }) + }) + } this.identityContract = new this.web3.eth.Contract( IdentityABI.abi,