You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A minor bug, but ethereum.selectedAddress isn't immediately changed on the accountsChanged event, which is different behaviour from the previous version. Calling ethereum.selectedAddress from within the callback will return the old account.
A small timeout in javascript will show the change happening.
ethereum.selectedAddress is marked as deprecated in the docs, but it is still available for now.
No big issue because the accounts value is correct, but it might cause issues in a case where the callback calls a function that internally uses selectedAccount.
To Reproduce (REQUIRED)
MetaMask with 2 accounts connected.
Take the following javascript logging:
window.ethereum.on("accountsChanged", function (accounts) {
if (accounts && accounts.length > 0) {
console.log('log1: ' + accounts[0] + ' - ' + ethereum.selectedAddress);
// wait for 1 millisecond to log again
window.setTimeout(function() {
console.log('log2: ' + accounts[0] + ' - ' + ethereum.selectedAddress);
}, 1);
}
})
log1 prints the accounts immediately after the event and log2 is identical with a small delay.
Describe the bug
A minor bug, but
ethereum.selectedAddress
isn't immediately changed on theaccountsChanged
event, which is different behaviour from the previous version. Callingethereum.selectedAddress
from within the callback will return the old account.A small timeout in javascript will show the change happening.
ethereum.selectedAddress
is marked as deprecated in the docs, but it is still available for now.No big issue because the accounts value is correct, but it might cause issues in a case where the callback calls a function that internally uses selectedAccount.
To Reproduce (REQUIRED)
MetaMask with 2 accounts connected.
Take the following javascript logging:
log1 prints the accounts immediately after the event and log2 is identical with a small delay.
MetaMask 8.0.4
log1: account1 - null
log2: account1 - account1
log1: account2 - account1
log2: account2 - account2
MetaMask 7.7.9
log1: account1 - account1
log2: account1 - account1
log1: account2 - account2
log2: account2 - account2
Browser details (please complete the following information):
The text was updated successfully, but these errors were encountered: