mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Use async/await for getRestrictedMethods (#9099)
This commit is contained in:
parent
2445c0b41b
commit
a7089193c8
@ -1,12 +1,11 @@
|
|||||||
export default function getRestrictedMethods ({ getIdentities, getKeyringAccounts }) {
|
export default function getRestrictedMethods ({ getIdentities, getKeyringAccounts }) {
|
||||||
return {
|
return {
|
||||||
'eth_accounts': {
|
'eth_accounts': {
|
||||||
method: (_, res, __, end) => {
|
method: async (_, res, __, end) => {
|
||||||
getKeyringAccounts()
|
try {
|
||||||
.then((accounts) => {
|
const accounts = await getKeyringAccounts()
|
||||||
const identities = getIdentities()
|
const identities = getIdentities()
|
||||||
res.result = accounts
|
res.result = accounts.sort((firstAddress, secondAddress) => {
|
||||||
.sort((firstAddress, secondAddress) => {
|
|
||||||
if (!identities[firstAddress]) {
|
if (!identities[firstAddress]) {
|
||||||
throw new Error(`Missing identity for address ${firstAddress}`)
|
throw new Error(`Missing identity for address ${firstAddress}`)
|
||||||
} else if (!identities[secondAddress]) {
|
} else if (!identities[secondAddress]) {
|
||||||
@ -22,13 +21,10 @@ export default function getRestrictedMethods ({ getIdentities, getKeyringAccount
|
|||||||
return identities[secondAddress].lastSelected - identities[firstAddress].lastSelected
|
return identities[secondAddress].lastSelected - identities[firstAddress].lastSelected
|
||||||
})
|
})
|
||||||
end()
|
end()
|
||||||
})
|
} catch (err) {
|
||||||
.catch(
|
|
||||||
(err) => {
|
|
||||||
res.error = err
|
res.error = err
|
||||||
end(err)
|
end(err)
|
||||||
},
|
}
|
||||||
)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user