Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/server/blockchain/Web3Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -371,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
Expand All @@ -390,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(
Expand Down Expand Up @@ -424,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) {
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.

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,
Expand Down
Loading