File tree Expand file tree Collapse file tree
polymath-ui/src/components/EthNetworkWrapper Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ interface Ethereum extends HttpProvider {
1414 networkVersion : string ;
1515 _metamask ?: {
1616 isApproved : ( ) => Promise < boolean > ;
17+ isUnlocked : ( ) => Promise < boolean > ;
1718 } ;
1819 enable ( ) : Promise < any > ;
1920}
@@ -117,14 +118,10 @@ export async function getCurrentAddress() {
117118 const support = getBrowserSupport ( ) ;
118119
119120 if ( isModern ( win ) ) {
120- // Special check for Metamask to know if it is locked or not
121121 if ( win . ethereum . _metamask ) {
122- const isApproved = await win . ethereum . _metamask . isApproved ( ) ;
123- if ( isApproved ) {
124- accounts = await web3 . eth . getAccounts ( ) ;
125- if ( ! accounts . length ) {
126- throw new PolymathError ( { code : ErrorCodes . WalletIsLocked } ) ;
127- }
122+ const isUnlocked = await win . ethereum . _metamask . isUnlocked ( ) ;
123+ if ( ! isUnlocked ) {
124+ throw new PolymathError ( { code : ErrorCodes . WalletIsLocked } ) ;
128125 }
129126 }
130127 await enableWallet ( ) ;
Original file line number Diff line number Diff line change @@ -149,11 +149,11 @@ export const init = (networks: Array<string>) => async (dispatch: Function) => {
149149 if (
150150 ! accounts . length &&
151151 newProviderInjected &&
152- window . ethereum . _metamask . isApproved
152+ window . ethereum . _metamask . isUnlocked // compatibility check on the MM version
153153 ) {
154- const isMetamaskApproved = await window . ethereum . _metamask . isApproved ( ) ;
154+ const isMetamaskUnlocked = await window . ethereum . _metamask . isUnlocked ( ) ;
155155
156- if ( ! isMetamaskApproved ) {
156+ if ( isMetamaskUnlocked ) {
157157 dispatch ( requestAuthorization ( ) ) ;
158158 return dispatch ( fail ( ERROR_ACCESS_REQUESTED ) ) ;
159159 }
You can’t perform that action at this time.
0 commit comments