Skip to content

Commit

Permalink
chore: adds optional chaining where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro committed Aug 30, 2023
1 parent 9b10340 commit 77e26f7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
},
{
key: localize('general.immutableIssuer'),
value: $selectedAccount.depositAddress,
value: $selectedAccount?.depositAddress,
},
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
items={[
{
key: localize('general.transactionTime'),
value: activity.time ? getFormattedTimeStamp(activity.time) : undefined,
value: activity?.time ? getFormattedTimeStamp(activity?.time) : undefined,
},
{
key: localize('general.amountConsolidatedInputs'),
value: activity.amountConsolidatedInputs ? String(activity.amountConsolidatedInputs) : undefined,
value: activity?.amountConsolidatedInputs ? String(activity?.amountConsolidatedInputs) : undefined,
},
]}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
export let activity: Activity
$: expirationTime = getFormattedTimeStamp(activity.asyncData?.expirationDate)
$: claimedTime = getFormattedTimeStamp(activity.asyncData?.claimedDate)
$: expirationTime = getFormattedTimeStamp(activity?.asyncData?.expirationDate)
$: claimedTime = getFormattedTimeStamp(activity?.asyncData?.claimedDate)
$: hasStorageDeposit =
activity.storageDeposit || (activity.storageDeposit === 0 && activity.giftedStorageDeposit === 0)
$: gasLimit = activity.parsedLayer2Metadata?.gasLimit
activity?.storageDeposit || (activity?.storageDeposit === 0 && activity?.giftedStorageDeposit === 0)
$: gasLimit = activity?.parsedLayer2Metadata?.gasLimit
$: formattedTransactionTime = getFormattedTimeStamp(activity.time)
$: formattedTimelockDate = getFormattedTimeStamp(activity.asyncData?.timelockDate)
$: formattedStorageDeposit = formatTokenAmountPrecise(activity.storageDeposit ?? 0, getBaseToken())
$: formattedGiftedStorageDeposit = formatTokenAmountPrecise(activity.giftedStorageDeposit ?? 0, getBaseToken())
$: formattedSurplus = formatTokenAmountPrecise(activity.surplus ?? 0, getBaseToken())
$: formattedTransactionTime = getFormattedTimeStamp(activity?.time)
$: formattedTimelockDate = getFormattedTimeStamp(activity?.asyncData?.timelockDate)
$: formattedStorageDeposit = formatTokenAmountPrecise(activity?.storageDeposit ?? 0, getBaseToken())
$: formattedGiftedStorageDeposit = formatTokenAmountPrecise(activity?.giftedStorageDeposit ?? 0, getBaseToken())
$: formattedSurplus = formatTokenAmountPrecise(activity?.surplus ?? 0, getBaseToken())
$: formattedGasLimit = formatTokenAmountPrecise(Number(gasLimit ?? 0), getBaseToken())
</script>

Expand All @@ -34,50 +34,50 @@
},
{
key: localize('general.tag'),
value: activity.tag,
tooltip: localize(`tooltips.transactionDetails.${activity.direction}.tag`),
value: activity?.tag,
tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.tag`),
},
{
key: localize('general.metadata'),
value: activity.metadata,
tooltip: localize(`tooltips.transactionDetails.${activity.direction}.metadata`),
value: activity?.metadata,
tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.metadata`),
},
{
key: localize('general.storageDeposit'),
value: hasStorageDeposit ? formattedStorageDeposit : undefined,
tooltip: localize(`tooltips.transactionDetails.${activity.direction}.storageDeposit`),
tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.storageDeposit`),
},
{
key: localize('general.surplus'),
value: activity.surplus ? formattedSurplus : undefined,
value: activity?.surplus ? formattedSurplus : undefined,
},
{
key: localize('general.giftedStorageDeposit'),
value: activity.giftedStorageDeposit ? formattedGiftedStorageDeposit : undefined,
tooltip: localize(`tooltips.transactionDetails.${activity.direction}.giftedStorageDeposit`),
value: activity?.giftedStorageDeposit ? formattedGiftedStorageDeposit : undefined,
tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.giftedStorageDeposit`),
},
{
key: localize('general.gasLimit'),
value: gasLimit ? formattedGasLimit : undefined,
tooltip: localize(`tooltips.transactionDetails.${activity.direction}.gasLimit`),
tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.gasLimit`),
},
{
key: localize('general.expirationTime'),
value: expirationTime,
tooltip: localize(`tooltips.transactionDetails.${activity.direction}.expirationTime`),
tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.expirationTime`),
},
{
key: localize('general.timelockDate'),
value: activity.asyncData?.timelockDate ? formattedTimelockDate : undefined,
tooltip: localize(`tooltips.transactionDetails.${activity.direction}.timelockDate`),
value: activity?.asyncData?.timelockDate ? formattedTimelockDate : undefined,
tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.timelockDate`),
},
{
key: localize('general.claimedTime'),
value: claimedTime,
},
{
key: localize(activity.asyncData?.isClaiming ? 'general.claimingIn' : 'general.claimedIn'),
value: activity.asyncData?.claimingTransactionId,
key: localize(activity?.asyncData?.isClaiming ? 'general.claimingIn' : 'general.claimedIn'),
value: activity?.asyncData?.claimingTransactionId,
copyable: true,
truncate: { firstCharCount: 12, endCharCount: 12 },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
export let activity: GovernanceActivity
$: formattedTransactionTime = getFormattedTimeStamp(activity.time)
$: formattedTransactionTime = getFormattedTimeStamp(activity?.time)
$: isNewVotingPower =
activity.governanceAction === GovernanceAction.DecreaseVotingPower ||
activity.governanceAction === GovernanceAction.IncreaseVotingPower
activity?.governanceAction === GovernanceAction.DecreaseVotingPower ||
activity?.governanceAction === GovernanceAction.IncreaseVotingPower
</script>

<Table
items={[
{
key: localize('general.transactionTime'),
value: activity.time ? formattedTransactionTime : undefined,
value: activity?.time ? formattedTransactionTime : undefined,
},
{
key: isNewVotingPower ? localize('general.newVotingPower') : localize('general.votingPower'),
value:
activity.votingPower !== undefined
? formatTokenAmountBestMatch(activity.votingPower, getBaseToken(), 2)
activity?.votingPower !== undefined
? formatTokenAmountBestMatch(activity?.votingPower, getBaseToken(), 2)
: undefined,
tooltip: localize('tooltips.transactionDetails.votingPower'),
},
Expand Down

0 comments on commit 77e26f7

Please sign in to comment.