Skip to content

Commit

Permalink
fix: show l2 tokens (#1623)
Browse files Browse the repository at this point in the history
* show l2 tokens

* add timelock filter

* fix locale
  • Loading branch information
MarkNerdi authored Dec 18, 2023
1 parent ad69cea commit daf059c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<script lang="ts">
import { activeProfile } from '@core/profile/stores'
import { IOption, SelectInput } from '@bloomwalletio/ui'
import { visibleSelectedAccountTokens } from '@core/token/stores'
import { TokenFilterUnit } from '@core/utils/interfaces/filter'
export let filterUnit: TokenFilterUnit
const { baseCoin, nativeTokens } = $visibleSelectedAccountTokens[$activeProfile?.network?.id]
const options: IOption[] = [baseCoin, ...nativeTokens].map((choice) => ({
label: choice.metadata?.name,
value: choice.id,
}))
const options: IOption[] = getTokenOptions()
function getTokenOptions(): IOption[] {
const tokens: { [key: string]: string } = {}
for (const networkTokens of Object.values($visibleSelectedAccountTokens)) {
if (networkTokens?.baseCoin?.metadata) {
tokens[networkTokens.baseCoin.id] = networkTokens.baseCoin.metadata?.name
}
networkTokens?.nativeTokens.forEach((token) => {
if (token.metadata) {
tokens[token.id] = token.metadata.name
}
})
}
return Object.entries(tokens).map(([id, name]) => ({ label: name, value: id }))
}
let selected = options.find((option) => option.value === filterUnit.selected)
$: selected && onSelect(selected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const DEFAULT_ACTIVITY_FILTER: ActivityFilter = {
choices: [
StatusFilterOption.Confirmed,
StatusFilterOption.Pending,
StatusFilterOption.Timelocked,
StatusFilterOption.Claimed,
StatusFilterOption.Unclaimed,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ function isVisibleWithActiveStatusFilter(activity: Activity, filter: ActivityFil
) {
return false
}
if (
filter.status.selected === StatusFilterOption.Timelocked &&
activity.asyncData?.asyncStatus !== ActivityAsyncStatus.Timelocked
) {
return false
}
if (
filter.status.selected === StatusFilterOption.Claimed &&
activity.type === ActivityType.Basic &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum StatusFilterOption {
Confirmed = 'confirmed',
Pending = 'pending',
Timelocked = 'timelocked',
Claimed = 'claimed',
Unclaimed = 'unclaimed',
}
1 change: 1 addition & 0 deletions packages/shared/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@
"status": {
"label": "Status",
"confirmed": "confirmed",
"timelocked": "timelocked",
"pending": "pending",
"claimed": "claimed",
"unclaimed": "unclaimed"
Expand Down

0 comments on commit daf059c

Please sign in to comment.