Skip to content

Commit

Permalink
Merge branch 'develop' into feat/explorer-api-pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuditi authored Feb 27, 2024
2 parents 56f3af5 + 5ec84d6 commit 00f2f75
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
function getFormattedMarketPrice(_activity: Activity): string | undefined {
if ((_activity.type === ActivityType.Basic || _activity.type === ActivityType.Foundry) && token) {
if ([ActivityType.Basic, ActivityType.Governance, ActivityType.Foundry].includes(_activity.type) && token) {
const amount = _activity.tokenTransfer?.rawAmount ?? _activity.baseTokenTransfer.rawAmount
const marketPrice = getFiatValueFromTokenAmount(amount, token)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<script lang="ts">
import { ITokenWithBalance } from '@core/token'
import { ExpiredActivityPill, TimelockActivityPill, NftAvatar, TokenAvatar, UnclaimedActivityPill } from '@ui'
import {
ExpiredActivityPill,
TimelockActivityPill,
NftAvatar,
TokenAvatar,
UnclaimedActivityPill,
GovernanceAvatar,
} from '@ui'
import {
ActivityType,
getActivityActionColor,
getActivityActionTextColor,
getActivityActionPill,
getActivityTileAction,
getActivityTileAsset,
Expand Down Expand Up @@ -33,35 +40,37 @@
? getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
: undefined)
$: color = getActivityActionColor(activity, $darkMode)
$: color = getActivityActionTextColor(activity)
$: pill = getActivityActionPill(activity, $time)
</script>

<div class="flex flex-row gap-4 items-center overflow-hidden">
<div class="py-1">
{#if token}
{#if activity.type === ActivityType.Governance}
<GovernanceAvatar governanceAction={activity.governanceAction} size="lg" />
{:else if token}
<TokenAvatar {token} hideNetworkBadge size="lg" />
{:else if activity.type === ActivityType.Nft}
<NftAvatar {nft} size="lg" shape="square" />
{:else if activity.type === ActivityType.SmartContract}
<Avatar
icon={IconName.FileCode}
size="lg"
textColor="brand"
textColor="primary"
backgroundColor={$darkMode ? 'surface-2-dark' : 'surface-2'}
/>
{:else if activity.type === ActivityType.Alias}
<Avatar
icon={IconName.Alias}
size="lg"
textColor="brand"
textColor="primary"
backgroundColor={$darkMode ? 'surface-2-dark' : 'surface-2'}
/>
{/if}
</div>
<div class="flex flex-col items-start justify-between overflow-hidden">
<div class="w-full flex flex-row gap-1 overflow-hidden">
<Text customColor={color} class="shrink-0">{localize(getActivityTileAction(activity))}</Text>
<Text textColor={color} class="shrink-0">{localize(getActivityTileAction(activity))}</Text>
<Text truncate>{getActivityTileAsset(activity, $selectedAccountIndex)}</Text>
</div>
<div class="flex gap-2">
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Bloom Labs Ltd <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"@bloomwalletio/ui": "0.20.6",
"@bloomwalletio/ui": "0.20.8",
"@ethereumjs/rlp": "4.0.1",
"@ethereumjs/tx": "5.2.1",
"@ethereumjs/util": "9.0.2",
Expand Down
24 changes: 24 additions & 0 deletions packages/shared/src/components/avatars/GovernanceAvatar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script lang="ts">
import { Avatar, IconName } from '@bloomwalletio/ui'
import { GovernanceAction } from '@core/activity'
import { darkMode } from '@core/app/stores'
export let governanceAction: GovernanceAction
export let size: 'xxs' | 'xs' | 'sm' | 'base' | 'md' | 'lg' = 'md'
const ICONS_FOR_ACTION = {
[GovernanceAction.StartVoting]: IconName.Package,
[GovernanceAction.StopVoting]: IconName.Package,
[GovernanceAction.ChangedVote]: IconName.PackageCheck,
[GovernanceAction.Revote]: IconName.PackageCheck,
[GovernanceAction.IncreaseVotingPower]: IconName.PackagePlus,
[GovernanceAction.DecreaseVotingPower]: IconName.PackageMinus,
}
</script>

<Avatar
icon={ICONS_FOR_ACTION[governanceAction]}
{size}
textColor="primary"
backgroundColor={$darkMode ? 'surface-2-dark' : 'surface-2'}
/>
1 change: 1 addition & 0 deletions packages/shared/src/components/avatars/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as ContactAvatar } from './ContactAvatar.svelte'
export { default as GovernanceAvatar } from './GovernanceAvatar.svelte'
export { default as NftAvatar } from './NftAvatar.svelte'
export { default as NetworkAvatar } from './NetworkAvatar.svelte'
export { default as ProfileAvatar } from './ProfileAvatar.svelte'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import { Activity, ActivityAction, ActivityDirection, ActivityType } from '@core/activity'
import { TextColor } from '@bloomwalletio/ui'
import { Activity, ActivityAction, ActivityDirection, ActivityType, GovernanceAction } from '@core/activity'

export function getActivityActionColor(activity: Activity, darkMode: boolean): string {
export function getActivityActionTextColor(activity: Activity): TextColor {
const { type, direction, action } = activity

if (type === ActivityType.Basic && activity.isShimmerClaiming) {
return 'info'
}
if (type === ActivityType.Governance) {
return darkMode ? 'neutral-1' : 'neutral-7'
if ([GovernanceAction.StartVoting, GovernanceAction.StopVoting].includes(activity.governanceAction)) {
return 'secondary'
}
return 'primary'
} else if (type === ActivityType.Consolidation) {
return darkMode ? 'neutral-1' : 'neutral-7'
return 'primary'
} else if (type === ActivityType.SmartContract) {
return 'brand'
return 'primary'
} else if (action === ActivityAction.Mint) {
return 'success'
} else if (action === ActivityAction.Burn) {
return 'danger'
} else if (action === ActivityAction.InitialBalance) {
return darkMode ? 'neutral-1' : 'neutral-7'
return 'primary'
} else if (action === ActivityAction.Send || action === ActivityAction.BalanceChange) {
const isReceived = [
ActivityDirection.Incoming,
Expand All @@ -30,9 +34,9 @@ export function getActivityActionColor(activity: Activity, darkMode: boolean): s
} else if (isReceived) {
return 'info'
} else {
return darkMode ? 'neutral-1' : 'neutral-7'
return 'primary'
}
} else {
return darkMode ? 'neutral-1' : 'neutral-7'
return 'primary'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getActivityTileAction(activity: Activity): string | undefined {
} else if (activity.governanceAction === GovernanceAction.DecreaseVotingPower) {
return isConfirmed ? 'general.decreased' : 'general.decreasing'
} else if (activity.governanceAction === GovernanceAction.StartVoting) {
return isConfirmed ? 'general.voted' : 'general.voting'
return isConfirmed ? 'general.voteStarted' : 'general.voteStarting'
} else if (activity.governanceAction === GovernanceAction.StopVoting) {
return isConfirmed ? 'general.unvoted' : 'general.unvoting'
} else if (activity.governanceAction === GovernanceAction.ChangedVote) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ActivityType } from '../enums'
import { ActivityType, GovernanceAction } from '../enums'
import { Activity } from '../types'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { getTokenFromActivity } from './getTokenFromActivity'
import { get } from 'svelte/store'
import { registeredProposalsForSelectedAccount } from '@contexts/governance'

export function getActivityTileAsset(activity: Activity, accountIndex: number): string | undefined {
if (activity.type === ActivityType.Basic || activity.type === ActivityType.Foundry) {
Expand All @@ -19,6 +21,14 @@ export function getActivityTileAsset(activity: Activity, accountIndex: number):
} else if (activity.type === ActivityType.Consolidation) {
return ''
} else if (activity.type === ActivityType.Governance) {
if ([GovernanceAction.StartVoting, GovernanceAction.StopVoting].includes(activity.governanceAction)) {
if (activity?.participation?.eventId) {
const proposal = get(registeredProposalsForSelectedAccount)?.[activity.participation.eventId]
return proposal.title
} else {
return activity.participation?.eventId
}
}
return ''
} else {
return ''
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/lib/core/activity/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export * from './generateSingleFoundryActivity'
export * from './generateSingleGovernanceActivity'
export * from './generateSingleNftActivity'
export * from './getActivityDetailsTitle'
export * from './getActivityActionColor'
export * from './getActivityActionTextColor'
export * from './getActivityActionPill'
export * from './getActivityTileAction'
export * from './getActivityTileAsset'
Expand Down
12 changes: 6 additions & 6 deletions packages/shared/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1396,18 +1396,18 @@
"receiving": "Receiving",
"newVotingPower": "New voting power",
"votingPower": "Voting power",
"increased": "Voting power increased",
"increasing": "Increasing voting power",
"decreased": "Voting power decreased",
"decreasing": "Decreasing voting power",
"increased": "Voting increased",
"increasing": "Increasing voting",
"decreased": "Voting decreased",
"decreasing": "Decreasing voting",
"voted": "Voted",
"voting": "Voting",
"changedVote": "Changed vote",
"changingVote": "Changing vote",
"revoted": "Revoted",
"revoting": "Revoting",
"unvoted": "Unvoted",
"unvoting": "Unvoting",
"unvoted": "Stopped voting",
"unvoting": "Stopping voting",
"transferred": "Transferred",
"transferring": "Transferring",
"shimmerClaimed": "Claimed",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@bloomwalletio/[email protected].6":
version "0.20.6"
resolved "https://npm.pkg.github.com/download/@bloomwalletio/ui/0.20.6/566636d21ecf9553142868a95d7bf2c64e2a3007#566636d21ecf9553142868a95d7bf2c64e2a3007"
integrity sha512-MqU+umZ5IaODS0/Zi4zJdzbeVta2wbBmBz9hbSK7JEKCqFiZ9ocgmZXw5IZmb5nbWLUQUzdVUT8/C6m4pY+pCg==
"@bloomwalletio/[email protected].8":
version "0.20.8"
resolved "https://npm.pkg.github.com/download/@bloomwalletio/ui/0.20.8/c315895a962b23263da7fe5e91ddff0eb61fb9db#c315895a962b23263da7fe5e91ddff0eb61fb9db"
integrity sha512-jwailq9C48f4R+ID3wnzzC+A7KKSMI6TUM/HAX7St/qwhruK583wof05ci6JAkEnJKkj4Y6pGE5i4eHB+s48aQ==
dependencies:
"@floating-ui/dom" "1.4.3"
"@popperjs/core" "2.11.8"
Expand Down

0 comments on commit 00f2f75

Please sign in to comment.