Skip to content

Commit

Permalink
fix: correct recipient address (#5076) (#5085)
Browse files Browse the repository at this point in the history
Co-authored-by: paul-boegelsack <[email protected]>
  • Loading branch information
Tuditi and paul-boegelsack authored Nov 2, 2022
1 parent 45590a1 commit a873629
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/shared/components/ActivityRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
findAccountWithAddress,
findAccountWithAnyAddress,
findExternalAddress,
getIncomingFlag,
getInternalFlag,
getMilestoneMessageValue,
Expand Down Expand Up @@ -74,8 +75,9 @@
accountAlias = acc.alias
} else {
// We can't find the address in our accounts so just display the abbreviated address
const receiverAddress = findExternalAddress(receiverAddresses)
accountAlias = truncateString(
txPayload.data.essence.data.incoming ? receiverAddresses[0] : senderAddress,
txPayload.data.essence.data.incoming ? senderAddress : receiverAddress,
4,
3
)
Expand Down
12 changes: 12 additions & 0 deletions packages/shared/lib/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,18 @@ export const findAccountWithAnyAddress = (
}
}

export const findExternalAddress = (addresses: string[]): string => {
if (!addresses) {
return
}
const accounts = get(get(wallet).accounts)
const internalAddresses = accounts.flatMap((acc) => acc.addresses.map((addr) => addr.address))
const externalAddress = addresses.filter((add) => !internalAddresses.includes(add))
if (externalAddress.length > 0) {
return externalAddress[0]
}
}

/**
* Get the sync options for an account
* @param {boolean} isManualSync A boolean value indicating if a user (via the UI) invoked this function
Expand Down

0 comments on commit a873629

Please sign in to comment.