-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
60 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
packages/shared/lib/core/wallet/utils/outputs/getRecipientAddressFromOutput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { AddressUnlockCondition, CommonOutput } from '@iota/wallet/out/types' | ||
import { UNLOCK_CONDITION_ADDRESS } from '../../constants' | ||
import { Output } from '../../types' | ||
import { getBech32AddressFromAddressTypes } from '../getBech32AddressFromAddressTypes' | ||
|
||
export function getRecipientAddressFromOutput(output: Output): string { | ||
export function getRecipientAddressFromOutput(output: CommonOutput): string | undefined { | ||
for (const unlockCondition of output.unlockConditions) { | ||
if (unlockCondition.type === UNLOCK_CONDITION_ADDRESS) { | ||
return getBech32AddressFromAddressTypes(unlockCondition.address) | ||
const addressUnlockCondition = unlockCondition as AddressUnlockCondition | ||
return getBech32AddressFromAddressTypes(addressUnlockCondition.address) | ||
} | ||
} | ||
} |
9 changes: 6 additions & 3 deletions
9
packages/shared/lib/core/wallet/utils/outputs/getRecipientFromOutput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { getRecipientAddressFromOutput } from './getRecipientAddressFromOutput' | ||
import { Output, Subject } from '../../types' | ||
import { Subject } from '../../types' | ||
import { getSubjectFromAddress } from '../getSubjectFromAddress' | ||
import { CommonOutput } from '@iota/wallet' | ||
|
||
export function getRecipientFromOutput(output: Output): Subject { | ||
export function getRecipientFromOutput(output: CommonOutput): Subject | undefined { | ||
const recipientAddress = getRecipientAddressFromOutput(output) | ||
return getSubjectFromAddress(recipientAddress) | ||
if (recipientAddress) { | ||
return getSubjectFromAddress(recipientAddress) | ||
} | ||
} |
13 changes: 10 additions & 3 deletions
13
packages/shared/lib/core/wallet/utils/outputs/getSenderFromOutput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
import { Output, Subject } from '../../types' | ||
import { Subject } from '../../types' | ||
import { getBech32AddressFromAddressTypes } from '../getBech32AddressFromAddressTypes' | ||
import { UNLOCK_CONDITION_EXPIRATION, UNLOCK_CONDITION_STORAGE_DEPOSIT_RETURN } from '@core/wallet/constants' | ||
import { getSubjectFromAddress } from '../getSubjectFromAddress' | ||
import { CommonOutput, ExpirationUnlockCondition, StorageDepositReturnUnlockCondition } from '@iota/wallet' | ||
|
||
export function getSenderFromOutput(output: Output): Subject | undefined { | ||
export function getSenderFromOutput(output: CommonOutput): Subject | undefined { | ||
for (const unlockCondition of output.unlockConditions) { | ||
if ( | ||
unlockCondition?.type === UNLOCK_CONDITION_STORAGE_DEPOSIT_RETURN || | ||
unlockCondition?.type === UNLOCK_CONDITION_EXPIRATION | ||
) { | ||
return getSubjectFromAddress(getBech32AddressFromAddressTypes(unlockCondition?.returnAddress)) | ||
const storageOrExpirationUnlockCondition = unlockCondition as | ||
| StorageDepositReturnUnlockCondition | ||
| ExpirationUnlockCondition | ||
const address = getBech32AddressFromAddressTypes(storageOrExpirationUnlockCondition?.returnAddress) | ||
if (address) { | ||
return getSubjectFromAddress(address) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
packages/shared/lib/core/wallet/utils/transactions/getSenderFromTransaction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters