Skip to content

Commit

Permalink
feat: adds destination network for send confirmation popup and smart …
Browse files Browse the repository at this point in the history
…contract pill (#5273)

* feat: adds destination network for send confirmation popup and smart contract pill

* fix: adds optional chaining to find result

* fix to improve readability

* chore: renamed variable

Co-authored-by: Tuditi <45079109+Tuditi@users.noreply.github.com>
Co-authored-by: Tuditi <daviddetroch@pm.me>
  • Loading branch information
3 people committed Nov 23, 2022
1 parent ab75901 commit 9f7e1eb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
19 changes: 19 additions & 0 deletions packages/shared/components/molecules/BasicActivityDetails.svelte
Expand Up @@ -24,6 +24,7 @@
import { Platform, time } from '@core/app'
import { truncateString } from '@core/utils'
import { setClipboard } from '@core/utils'
import { DestinationNetwork, NETWORK_ADDRESS } from '@core/layer-2'
export let asset: IPersistedAsset
export let asyncStatus: ActivityAsyncStatus = null
Expand All @@ -45,6 +46,7 @@
export let isInternal: boolean = false
export let isClaiming: boolean = false
export let type: ActivityType
export let networkAddress: string = null
const explorerUrl = getOfficialExplorerUrl($activeProfile?.networkProtocol, $activeProfile?.networkType)
Expand All @@ -55,6 +57,7 @@
$: claimedTime = getDateFormat(claimedDate)
$: isTimelocked = timelockDate > $time
$: hasStorageDeposit = storageDeposit || (storageDeposit === 0 && giftedStorageDeposit === 0)
$: destinationNetwork = getDestinationNetwork(networkAddress)
$: formattedStorageDeposit = formatTokenAmountPrecise(
storageDeposit ?? 0,
Expand All @@ -72,6 +75,9 @@
let detailsList: { [key in string]: { data: string; tooltipText?: string } }
$: detailsList = {
...(destinationNetwork && {
destinationNetwork: { data: destinationNetwork },
}),
...(transactionTime && {
transactionTime: { data: formattedTransactionTime },
}),
Expand Down Expand Up @@ -140,6 +146,14 @@
return undefined
}
}
function getDestinationNetwork(networkAddress: string): string {
const foundDestinationNetwork = Object.entries(NETWORK_ADDRESS[$activeProfile?.networkType]).find(
(networkAddressEntry) => networkAddressEntry[1] === networkAddress
)?.[0]
return foundDestinationNetwork ?? networkAddress ?? DestinationNetwork.Shimmer
}
</script>

<transaction-details class="w-full h-full space-y-6 flex flex-auto flex-col flex-shrink-0">
Expand All @@ -159,6 +173,11 @@
{localize('pills.locked')}
</Pill>
{/if}
{#if networkAddress}
<Pill backgroundColor="blue-200" darkBackgroundColor="blue-200">
{localize('pills.smartContractCall')}
</Pill>
{/if}
</transaction-status>
{#if subject}
<SubjectBox {subject} />
Expand Down
Expand Up @@ -41,8 +41,15 @@
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
export let disableBack = false
let { recipient, expirationDate, giftStorageDeposit, surplus, disableChangeExpiration, disableToggleGift } =
get(newTransactionDetails)
let {
recipient,
expirationDate,
giftStorageDeposit,
surplus,
disableChangeExpiration,
disableToggleGift,
layer2Parameters,
} = get(newTransactionDetails)
let storageDeposit = 0
let preparedOutput: Output
Expand Down Expand Up @@ -177,6 +184,7 @@
type={ActivityType.Transaction}
direction={ActivityDirection.Outgoing}
inclusionState={InclusionState.Pending}
networkAddress={layer2Parameters?.networkAddress}
/>
{:else if transactionDetails.type === NewTransactionType.NftTransfer}
<nft-details>
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/locales/en.json
Expand Up @@ -1893,7 +1893,8 @@
"Failed": "Failed to create alias"
}
},
"locked": "locked"
"locked": "locked",
"smartContractCall": "smart contract call"
},
"menus": {
"expirationTimePicker": {
Expand Down

0 comments on commit 9f7e1eb

Please sign in to comment.