-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
area-UIRelating to the user interface.Relating to the user interface.area-signTypedDataneeds-reproductiontype-bugSomething isn't workingSomething isn't working
Description
This is quite a crucial issue with user interaction as we cannot reasonably expect a user, after unlocking his account, to close and re-open the MetaMask plugin screen.
- Expected Behavior: Whilst the MetaMask plugin screen is open, either the page itself transitions to the signature request or the signature request pop-up shows.
- Actual Behavior: If MetaMask is open when the request is sent, the request does not show unless I close and re-open the MetaMask screen.
- Browser Used: Google Chrome although I believe this is irrelevant.
- Operating System Used: Windows 10 but likewise irrelevant.
Code Example (Ensure your account is locked):
const msgParams = [
{
type: 'string',
name: 'Authorization Request',
value: 'test'
}
];
if (typeof window.web3 !== 'undefined' && typeof window.web3.currentProvider !== 'undefined') {
let localWeb3 = new Web3(window.web3.currentProvider);
window.web3.eth.getAccounts((err, accounts) => {
if (!accounts[0]) {
watchAccountUnlock();
} else {
localWeb3.eth.defaultAccount = accounts[0];
requestSignature();
}
});
}
function watchAccountUnlock() {
const toClear = setInterval(() => {
window.web3.eth.getAccounts((err, accounts) => {
if (accounts[0] !== localWeb3.eth.defaultAccount) {
localWeb3.eth.defaultAccount = accounts[0];
requestSignature();
clearInterval(toClear);
}
});
},500);
}
function requestSignature() {
localWeb3.currentProvider.sendAsync({
method: 'eth_signTypedData',
params: [msgParams, localWeb3.eth.defaultAccount],
from: localWeb3.eth.defaultAccount,
}, (err, result) => {
if (err) return console.error(err)
if (result.error) {
// User denied signature
}
const signature = result.result;
alert(signature);
});
}JithinKS97
Metadata
Metadata
Assignees
Labels
area-UIRelating to the user interface.Relating to the user interface.area-signTypedDataneeds-reproductiontype-bugSomething isn't workingSomething isn't working