1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Return Promise from removeFromAddressBook thunk (#8451)

`removeFromAddressBook` returned a thunk that didn't return a Promise,
despite doing async work. It now returns a Promise.

The callers were updated to `await` the completion of this operation.
This commit is contained in:
Mark Stacey 2020-04-29 09:36:10 -03:00 committed by GitHub
parent e20ca4668e
commit 7302a14341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -49,8 +49,8 @@ export default class EditContact extends PureComponent {
<Button
type="link"
className="settings-page__address-book-button"
onClick={() => {
removeFromAddressBook(chainId, address)
onClick={async () => {
await removeFromAddressBook(chainId, address)
history.push(listRoute)
}}
>
@ -115,7 +115,7 @@ export default class EditContact extends PureComponent {
if (this.state.newAddress !== '' && this.state.newAddress !== address) {
// if the user makes a valid change to the address field, remove the original address
if (isValidAddress(this.state.newAddress)) {
removeFromAddressBook(chainId, address)
await removeFromAddressBook(chainId, address)
await addToAddressBook(this.state.newAddress, this.state.newName || name, this.state.newMemo || memo)
setAccountLabel(this.state.newAddress, this.state.newName || name)
history.push(listRoute)

View File

@ -1551,8 +1551,8 @@ export function addToAddressBook (recipient, nickname = '', memo = '') {
export function removeFromAddressBook (chainId, addressToRemove) {
log.debug(`background.removeFromAddressBook`)
return () => {
background.removeFromAddressBook(chainId, checksumAddress(addressToRemove))
return async () => {
await promisifiedBackground.removeFromAddressBook(chainId, checksumAddress(addressToRemove))
}
}