Problem: For a user who has installed MetaMask and opened the Voting DApp for the first time in the current browser's session, the DApp asks permissions to get access to the list of accounts in MetaMask. But the app doesn't need to know the list of user's accounts until validator's Voting Key is really needed for some operation.
Solution: call window.ethereum.enable only when DApp requires Voting Key to take some action which supposes transaction signing (when the user gives their vote for a ballot, finalizes a ballot, or goes to New Ballot page).
Note that some logic in the current implementation depends on the current votingKey and miningKey (e.g., contractsStore.getBallotsLimits uses the miningKey), so after the user clicks Connect in the above window, the current DApp's page should be reloaded to retrieve the data which depend on the keys.
Problem: For a user who has installed MetaMask and opened the Voting DApp for the first time in the current browser's session, the DApp asks permissions to get access to the list of accounts in MetaMask. But the app doesn't need to know the list of user's accounts until validator's
Voting Key
is really needed for some operation.Solution: call
window.ethereum.enable
only when DApp requiresVoting Key
to take some action which supposes transaction signing (when the user gives their vote for a ballot, finalizes a ballot, or goes toNew Ballot
page).Note that some logic in the current implementation depends on the current
votingKey
andminingKey
(e.g.,contractsStore.getBallotsLimits
uses theminingKey
), so after the user clicksConnect
in the above window, the current DApp's page should be reloaded to retrieve the data which depend on the keys.