From 8b796fb4c4418318b83fafe746b743954fe88213 Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Mon, 4 Sep 2023 15:06:27 +0200 Subject: [PATCH 1/3] only generate smart contract data if L1->L2 --- .../lib/core/activity/utils/generateSingleBasicActivity.ts | 5 ++++- .../src/lib/core/activity/utils/generateSingleNftActivity.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/lib/core/activity/utils/generateSingleBasicActivity.ts b/packages/shared/src/lib/core/activity/utils/generateSingleBasicActivity.ts index 1c89da6f3a..9876acb814 100644 --- a/packages/shared/src/lib/core/activity/utils/generateSingleBasicActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateSingleBasicActivity.ts @@ -20,6 +20,7 @@ import { getTagFromOutput, } from './helper' import { getNativeTokenFromOutput } from './outputs' +import { isStardustNetwork } from '@core/network/utils' export function generateSingleBasicActivity( account: IAccountState, @@ -55,7 +56,9 @@ export function generateSingleBasicActivity( const destinationNetworkId = getNetworkIdFromAddress(recipient?.address, sourceNetworkId) const asyncData = getAsyncDataFromOutput(output, outputId, claimingData, account) - const parsedLayer2Metadata = parseLayer2Metadata(metadata) + + const isToLayer2 = isStardustNetwork(sourceNetworkId) && sourceNetworkId !== destinationNetworkId + const parsedLayer2Metadata = isToLayer2 ? parseLayer2Metadata(metadata) : undefined const gasLimit = Number(parsedLayer2Metadata?.gasLimit ?? '0') diff --git a/packages/shared/src/lib/core/activity/utils/generateSingleNftActivity.ts b/packages/shared/src/lib/core/activity/utils/generateSingleNftActivity.ts index ffcb956f25..907d717b05 100644 --- a/packages/shared/src/lib/core/activity/utils/generateSingleNftActivity.ts +++ b/packages/shared/src/lib/core/activity/utils/generateSingleNftActivity.ts @@ -15,6 +15,7 @@ import { getTagFromOutput, } from './helper' import { getNftId } from './outputs' +import { isStardustNetwork } from '@core/network/utils' export function generateSingleNftActivity( account: IAccountState, @@ -48,7 +49,9 @@ export function generateSingleNftActivity( const destinationNetworkId = getNetworkIdFromAddress(recipient?.address, sourceNetworkId) const asyncData = getAsyncDataFromOutput(output, outputId, claimingData, account) - const parsedLayer2Metadata = parseLayer2Metadata(metadata) + + const isToLayer2 = isStardustNetwork(sourceNetworkId) && sourceNetworkId !== destinationNetworkId + const parsedLayer2Metadata = isToLayer2 ? parseLayer2Metadata(metadata) : undefined return { type: ActivityType.Nft, From 330cdb4971690f9620959869473f7246445817c3 Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Mon, 4 Sep 2023 15:08:38 +0200 Subject: [PATCH 2/3] dont show metadata if they are smart contract data --- .../GenericActivityInformation.svelte | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/shared/src/components/molecules/activity-info/GenericActivityInformation.svelte b/packages/shared/src/components/molecules/activity-info/GenericActivityInformation.svelte index e862fc191f..791197e446 100644 --- a/packages/shared/src/components/molecules/activity-info/GenericActivityInformation.svelte +++ b/packages/shared/src/components/molecules/activity-info/GenericActivityInformation.svelte @@ -11,21 +11,18 @@ $: expirationTime = getFormattedTimeStamp(activity.asyncData?.expirationDate) $: claimedTime = getFormattedTimeStamp(activity.asyncData?.claimedDate) - $: hasStorageDeposit = - activity?.storageDeposit || (activity?.storageDeposit === 0 && activity.giftedStorageDeposit === 0) - $: gasLimit = activity?.parsedLayer2Metadata?.gasLimit + $: hasStorageDeposit = activity.storageDeposit || activity.storageDeposit === 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()) $: formattedGasLimit = formatTokenAmountPrecise(Number(gasLimit ?? 0), getBaseToken()) $: explorerUrl = getDefaultExplorerUrl(activity.sourceNetworkId, ExplorerEndpoint.Transaction) function onTransactionIdClick(): void { if (explorerUrl) { - openUrlInBrowser(`${explorerUrl}/${activity?.asyncData?.claimingTransactionId}`) + openUrlInBrowser(`${explorerUrl}/${activity.asyncData?.claimingTransactionId}`) return } } @@ -35,7 +32,7 @@ items={[ { key: localize('general.destinationNetwork'), - value: getNameFromNetworkId(activity?.destinationNetworkId), + value: getNameFromNetworkId(activity.destinationNetworkId), }, { key: localize('general.transactionTime'), @@ -43,50 +40,41 @@ }, { 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.parsedLayer2Metadata ? activity.metadata : undefined, + tooltip: localize(`tooltips.transactionDetails.${activity.direction}.metadata`), }, { key: localize('general.storageDeposit'), value: hasStorageDeposit ? formattedStorageDeposit : undefined, - tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.storageDeposit`), - }, - { - key: localize('general.surplus'), - value: activity?.surplus ? formattedSurplus : undefined, - }, - { - key: localize('general.giftedStorageDeposit'), - value: activity?.giftedStorageDeposit ? formattedGiftedStorageDeposit : undefined, - tooltip: localize(`tooltips.transactionDetails.${activity?.direction}.giftedStorageDeposit`), + tooltip: localize(`tooltips.transactionDetails.${activity.direction}.storageDeposit`), }, { 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 }, onClick: explorerUrl ? onTransactionIdClick : undefined, From ea1f88967d05570b0e314fc4a18e47371674f8dd Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Mon, 4 Sep 2023 15:11:52 +0200 Subject: [PATCH 3/3] fix storage deposit --- .../molecules/activity-info/GenericActivityInformation.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/shared/src/components/molecules/activity-info/GenericActivityInformation.svelte b/packages/shared/src/components/molecules/activity-info/GenericActivityInformation.svelte index 791197e446..d9eaef118d 100644 --- a/packages/shared/src/components/molecules/activity-info/GenericActivityInformation.svelte +++ b/packages/shared/src/components/molecules/activity-info/GenericActivityInformation.svelte @@ -11,7 +11,6 @@ $: expirationTime = getFormattedTimeStamp(activity.asyncData?.expirationDate) $: claimedTime = getFormattedTimeStamp(activity.asyncData?.claimedDate) - $: hasStorageDeposit = activity.storageDeposit || activity.storageDeposit === 0 $: gasLimit = activity.parsedLayer2Metadata?.gasLimit $: formattedTransactionTime = getFormattedTimeStamp(activity.time) @@ -50,7 +49,7 @@ }, { key: localize('general.storageDeposit'), - value: hasStorageDeposit ? formattedStorageDeposit : undefined, + value: activity.storageDeposit ? formattedStorageDeposit : undefined, tooltip: localize(`tooltips.transactionDetails.${activity.direction}.storageDeposit`), }, {