Skip to content

Commit

Permalink
Merge branch 'develop' into 15-integrate-function-for-unwrapping-base…
Browse files Browse the repository at this point in the history
…-irc30-tokens
  • Loading branch information
Tuditi authored Aug 30, 2023
2 parents 1a5f4cd + 476bceb commit 999a362
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 109 deletions.
2 changes: 1 addition & 1 deletion packages/desktop/components/NetworkCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Button, CopyableButton, IconName } from '@bloomwalletio/ui'
import { selectedAccount } from '@core/account/stores'
import { localize } from '@core/i18n'
import { generateAndStoreEvmAddressForAccount } from '@core/layer-2'
import { generateAndStoreEvmAddressForAccount } from '@core/layer-2/actions'
import { LedgerAppName } from '@core/ledger'
import {
IChain,
Expand Down
108 changes: 55 additions & 53 deletions packages/desktop/components/popups/ActivityDetailsPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@
$collectiblesRouter.goTo(CollectiblesRoute.Details)
}
function onExplorerClick(): void {
openUrlInBrowser(`${explorerUrl}/${ExplorerEndpoint.Transaction}/${activity?.transactionId}`)
function onExplorerClick(_activity: Activity): void {
openUrlInBrowser(`${explorerUrl}/${ExplorerEndpoint.Transaction}/${_activity.transactionId}`)
}
function onTransactionIdClick(): void {
setClipboard(activity?.transactionId)
function onTransactionIdClick(_activity: Activity): void {
setClipboard(_activity.transactionId)
}
async function onClaimClick(): Promise<void> {
async function onClaimClick(_activity: Activity): Promise<void> {
await checkActiveProfileAuth(
async () => {
await claimActivity(activity)
await claimActivity(_activity)
openPopup({
id: PopupId.ActivityDetails,
props: { activityId },
Expand Down Expand Up @@ -118,52 +118,54 @@
})
</script>

<activity-details-popup class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<div class="flex flex-col">
<Text type={TextType.h3} fontWeight={FontWeight.semibold} classes="text-left">
{title}
</Text>
{#if explorerUrl && activity?.transactionId}
<button
class="action w-max flex justify-start text-center font-medium text-14 text-blue-500"
on:click={onExplorerClick}
>
{localize('general.viewOnExplorer')}
</button>
{:else if activity?.transactionId}
<button
class="action w-fit flex justify-start text-center font-medium text-14 text-blue-500"
on:click={onTransactionIdClick}
>
{truncateString(activity.transactionId, 12, 12)}
</button>
{/if}
</div>
<activity-details class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<ActivityStatusPills {activity} />
{#if activity}
<activity-details-popup class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<div class="flex flex-col">
<Text type={TextType.h3} fontWeight={FontWeight.semibold} classes="text-left">
{title}
</Text>
{#if explorerUrl && activity.transactionId}
<button
class="action w-max flex justify-start text-center font-medium text-14 text-blue-500"
on:click={() => onExplorerClick(activity)}
>
{localize('general.viewOnExplorer')}
</button>
{:else if activity.transactionId}
<button
class="action w-fit flex justify-start text-center font-medium text-14 text-blue-500"
on:click={() => onTransactionIdClick(activity)}
>
{truncateString(activity.transactionId, 12, 12)}
</button>
{/if}
</div>
<activity-details class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<ActivityStatusPills {activity} />

<TransactionAssetSection {...transactionAssets} onNftClick={nftIsOwned ? onNftClick : undefined} />
<TransactionAssetSection {...transactionAssets} onNftClick={nftIsOwned ? onNftClick : undefined} />

<ActivityInformation {activity} />
</activity-details>
{#if !isTimelocked && isActivityIncomingAndUnclaimed}
<popup-buttons class="flex flex-row flex-nowrap w-full space-x-4">
<Button
outline
classes="w-full"
disabled={activity.asyncData?.isClaiming || activity.asyncData?.isRejected}
onClick={onRejectClick}
>
{localize('actions.reject')}
</Button>
<Button
classes="w-full"
disabled={activity.asyncData?.isClaiming}
onClick={onClaimClick}
isBusy={activity.asyncData?.isClaiming}
>
{localize('actions.claim')}
</Button>
</popup-buttons>
{/if}
</activity-details-popup>
<ActivityInformation {activity} />
</activity-details>
{#if !isTimelocked && isActivityIncomingAndUnclaimed}
<popup-buttons class="flex flex-row flex-nowrap w-full space-x-4">
<Button
outline
classes="w-full"
disabled={activity.asyncData?.isClaiming || activity.asyncData?.isRejected}
onClick={onRejectClick}
>
{localize('actions.reject')}
</Button>
<Button
classes="w-full"
disabled={activity.asyncData?.isClaiming}
onClick={() => onClaimClick(activity)}
isBusy={activity.asyncData?.isClaiming}
>
{localize('actions.claim')}
</Button>
</popup-buttons>
{/if}
</activity-details-popup>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { selectedAccount } from '@core/account/stores'
import { getStorageDepositFromOutput } from '@core/activity/utils/helper'
import { localize } from '@core/i18n'
import { getGasFeesForLayer1ToLayer2Transaction } from '@core/layer-2'
import { getGasFeesForLayer1ToLayer2Transaction } from '@core/layer-2/actions'
import { getNetwork, isEvmChain } from '@core/network'
import { INft } from '@core/nfts/interfaces'
import { selectedAccountTokens } from '@core/token/stores'
Expand Down
20 changes: 10 additions & 10 deletions packages/shared/src/components/molecules/ActivityInformation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
let hasMetadata = false
$: {
const storedNft =
activity?.type === ActivityType.Nft
? getNftByIdFromAllAccountNfts($selectedAccountIndex, activity?.nftId)
activity.type === ActivityType.Nft
? getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
: undefined
hasMetadata = !!storedNft?.metadata
}
let tabs: Tab[] = []
$: {
switch (activity?.type) {
switch (activity.type) {
case ActivityType.Basic:
tabs = [Tab.Transaction, ...(activity?.parsedLayer2Metadata ? [Tab.SmartContract] : [])]
tabs = [Tab.Transaction, ...(activity.parsedLayer2Metadata ? [Tab.SmartContract] : [])]
break
case ActivityType.Governance:
tabs = [Tab.Transaction]
Expand All @@ -48,7 +48,7 @@
Tab.Transaction,
Tab.Nft,
...(hasMetadata ? [Tab.NftMetadata] : []),
...(activity?.parsedLayer2Metadata ? [Tab.SmartContract] : []),
...(activity.parsedLayer2Metadata ? [Tab.SmartContract] : []),
]
break
case ActivityType.Foundry:
Expand All @@ -63,22 +63,22 @@
<Tabs bind:activeTab {tabs} />
{/if}
{#if activeTab === Tab.Transaction}
{#if activity?.type === ActivityType.Governance}
{#if activity.type === ActivityType.Governance}
<GovernanceActivityInformation {activity} />
{:else if activity?.type === ActivityType.Consolidation}
{:else if activity.type === ActivityType.Consolidation}
<ConsolidationActivityInformation {activity} />
{:else}
<GenericActivityInformation {activity} />
{/if}
{:else if activeTab === Tab.Alias && activity?.type === ActivityType.Alias}
{:else if activeTab === Tab.Alias && activity.type === ActivityType.Alias}
<AliasActivityInformation {activity} />
{:else if activeTab === Tab.Nft && activity?.type === ActivityType.Nft}
{:else if activeTab === Tab.Nft && activity.type === ActivityType.Nft}
<NftActivityInformation {activity} />
{:else if activeTab === Tab.Foundry}
<FoundryActivityInformation {activity} />
{:else if activeTab === Tab.Token}
<TokenActivityInformation {activity} />
{:else if activeTab === Tab.NftMetadata && activity?.type === ActivityType.Nft}
{:else if activeTab === Tab.NftMetadata && activity.type === ActivityType.Nft}
<NftMetadataInformation {activity} />
{:else if activeTab === Tab.SmartContract}
<SmartContractActivityInformation {activity} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
export let activity: Activity
$: expirationTime = getFormattedTimeStamp(activity?.asyncData?.expirationDate)
$: claimedTime = getFormattedTimeStamp(activity?.asyncData?.claimedDate)
$: hasStorageDeposit =
activity?.storageDeposit || (activity?.storageDeposit === 0 && activity?.giftedStorageDeposit === 0)
$: gasLimit = activity?.parsedLayer2Metadata?.gasLimit
$: expirationTime = activity?.asyncData?.expirationDate
? getFormattedTimeStamp(activity?.asyncData?.expirationDate)
: undefined
$: claimedTime = activity?.asyncData?.claimedDate
? getFormattedTimeStamp(activity?.asyncData?.claimedDate)
: undefined
$: hasStorageDeposit = activity?.storageDeposit
$: gasFee = activity?.parsedLayer2Metadata?.gasLimit || activity?.gasUsed
$: 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())
$: formattedTransactionTime = getFormattedTimeStamp(activity.time)
$: formattedTimelockDate = activity.asyncData ? getFormattedTimeStamp(activity.asyncData?.timelockDate) : undefined
$: formattedStorageDeposit = formatTokenAmountPrecise(activity.storageDeposit ?? 0, getBaseToken())
$: formattedGasFee = formatTokenAmountPrecise(Number(gasFee ?? 0), getBaseToken())
let items: IItem[] = []
Expand Down Expand Up @@ -60,24 +61,10 @@
tooltip: localize(`tooltips.transactionDetails.${_activity?.direction}.storageDeposit`),
})
}
if (_activity?.surplus) {
if (gasFee) {
items.push({
key: localize('general.surplus'),
value: formattedSurplus,
})
}
if (_activity?.giftedStorageDeposit) {
items.push({
key: localize('general.giftedStorageDeposit'),
value: formattedGiftedStorageDeposit,
tooltip: localize(`tooltips.transactionDetails.${_activity?.direction}.giftedStorageDeposit`),
})
}
if (gasLimit) {
items.push({
key: localize('general.gasLimit'),
value: formattedGasLimit,
tooltip: localize(`tooltips.transactionDetails.${_activity?.direction}.gasLimit`),
key: localize('general.gasFee'),
value: formattedGasFee,
})
}
if (expirationTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
$: isTimelocked = timelockDate && timelockDate > $time
$: hasPills =
(activity.asyncData?.asyncStatus && activity?.asyncData?.asyncStatus !== ActivityAsyncStatus.Timelocked) ||
(activity.asyncData?.asyncStatus && activity.asyncData?.asyncStatus !== ActivityAsyncStatus.Timelocked) ||
isTimelocked ||
activity?.parsedLayer2Metadata
activity.parsedLayer2Metadata
</script>

{#if hasPills}
<transaction-status class="flex flex-row w-full space-x-2 justify-start">
{#if activity.asyncData?.asyncStatus && activity?.asyncData?.asyncStatus !== ActivityAsyncStatus.Timelocked}
{#if activity.asyncData?.asyncStatus && activity.asyncData?.asyncStatus !== ActivityAsyncStatus.Timelocked}
<ActivityAsyncStatusPill asyncStatus={activity.asyncData.asyncStatus} />
{/if}
{#if isTimelocked}
<ActivityAsyncStatusPill asyncStatus={ActivityAsyncStatus.Timelocked} />
{/if}
{#if activity?.parsedLayer2Metadata}
{#if activity.parsedLayer2Metadata}
<Pill color="blue">
{localize('pills.smartContract')}
</Pill>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { preprocessTransactionsForAccount } from './preprocessTransactionsForAcc
import { preprocessOutputsForAccount } from './preprocessOutputsForAccount'
import { linkTransactionsWithClaimingTransactions } from './linkTransactionsWithClaimingTransactions'
import { hideActivitiesForFoundries } from './hideActivitiesForFoundries'
import { generateActivitiesFromProcessedTransactions } from './generateActivitiesFromProcessedTransactions'
import { generateActivitiesFromProcessedTransactions } from '../utils/generateActivitiesFromProcessedTransactions'
import { loadAssetsForAllActivities } from './loadAssetsForAllAccounts'
import { generateActivitiesFromBalanceChanges, setOutgoingAsyncActivitiesToClaimed } from '@core/activity/actions'
import { generateActivitiesFromBalanceChanges, generateActivitiesFromChains } from '../utils'
import { NetworkId } from '@core/network'
import { setOutgoingAsyncActivitiesToClaimed } from './setOutgoingAsyncActivitiesToClaimed'

export async function generateAndStoreActivitiesForAccount(
account: IAccountState,
Expand All @@ -27,9 +28,11 @@ export async function generateAndStoreActivitiesForAccount(
// Step 3: generate activities from processed transactions
const activities = generateActivitiesFromProcessedTransactions(linkedProcessedTransactions, account, networkId)
const balanceChangeActivities = generateActivitiesFromBalanceChanges(account)

activities.push(...balanceChangeActivities)

const chainActivities = await generateActivitiesFromChains(account)
activities.push(...chainActivities)

// Step 4: set account activities with generated activities
setAccountActivitiesInAllAccountActivities(account.index, activities)

Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/lib/core/activity/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './calculateAndAddPersistedBalanceChange'
export * from './generateActivitiesFromBalanceChanges'
export * from './generateAndStoreActivitiesForAccount'
export * from './generateAndStoreActivitiesForAllAccounts'
export * from './hideActivitiesForFoundries'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type BaseActivity = {
action: ActivityAction
isInternal: boolean
storageDeposit: number
gasUsed?: number
rawBaseCoinAmount?: number
subject: Subject | undefined
metadata?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Activity } from '../types'
import { getBalanceChanges } from '../stores'
import { get } from 'svelte/store'
import { network } from '@core/network'
import { generateBalanceChangeActivity } from '../utils'
import { generateBalanceChangeActivity } from './generateBalanceChangeActivity'

export function generateActivitiesFromBalanceChanges(account: IAccountState): Activity[] {
const activities: Activity[] = []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { IAccountState } from '@core/account'
import { Activity } from '../types'
import { getPersistedEvmTransactions } from '../stores'
import { generateActivityFromEvmTransaction } from './generateActivityFromEvmTransaction'
import { get } from 'svelte/store'
import { network } from '@core/network'

export async function generateActivitiesFromChains(account: IAccountState): Promise<Activity[]> {
const activities: Activity[] = []

const chains = get(network)?.getChains() ?? []
for (const chain of chains) {
const networkId = chain.getConfiguration().id

const transactions = getPersistedEvmTransactions(account.index, networkId)
for (const transaction of transactions) {
const activity = await generateActivityFromEvmTransaction(transaction, networkId, chain.getProvider())
activities.push(activity)
}
}

return activities
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IAccountState } from '@core/account'
import { Activity, IProcessedTransaction } from '../types'
import { generateActivities } from '../utils'
import { generateActivities } from '.'
import { NetworkId } from '@core/network/types'

export function generateActivitiesFromProcessedTransactions(
Expand Down
Loading

0 comments on commit 999a362

Please sign in to comment.