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 31, 2023
2 parents 961c47b + 43fe208 commit 161d125
Show file tree
Hide file tree
Showing 14 changed files with 405 additions and 520 deletions.
15 changes: 4 additions & 11 deletions packages/desktop/components/ContactMetadataTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@
const KEYS_TO_DISPLAY = ['name', 'note']
let items: { key: string; value: string }[]
$: items, setContactMetadataValues()
function setContactMetadataValues(): void {
items = []
for (const key in contactMetadata) {
if (KEYS_TO_DISPLAY.includes(key) && contactMetadata[key]) {
items.push({ key: localize(`general.${key}`), value: contactMetadata[key] })
}
}
}
$: items = Object.keys(contactMetadata).map((key) => ({
key: localize(`general.${key}`),
value: KEYS_TO_DISPLAY.includes(key) && contactMetadata[key] ? contactMetadata[key] : undefined,
}))
</script>

<Table orientation="vertical" {items} />
21 changes: 7 additions & 14 deletions packages/desktop/components/ProposalsDetails.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { type IItem, Table } from '@bloomwalletio/ui'
import { Table } from '@bloomwalletio/ui'
import { IProposalsDetails } from '@contexts/governance/interfaces'
import {
participationOverviewForSelectedAccount,
Expand Down Expand Up @@ -27,21 +27,9 @@
votedProposals: null,
}
let items: IItem[] = []
$: isOverviewLoaded = !!$participationOverviewForSelectedAccount
$: $registeredProposalsForSelectedAccount, $participationOverviewForSelectedAccount, updateProposalsDetails()
$: $selectedAccount, void setParticipationOverview()
$: items = getProposalDetailValues(details)
function getProposalDetailValues(_details: IProposalsDetails): IItem[] {
return Object.keys(_details).map((key) => {
return {
key: localize(`views.governance.proposalsDetails.${key}`),
value: details[key] ?? 0,
}
})
}
function updateProposalsDetails(): void {
if ($activeProfileId) {
Expand Down Expand Up @@ -77,7 +65,12 @@
</Text>
<ProposalsDetailsButton modalPosition={{ right: '0px', top: '34px' }} />
</header-container>
<Table {items} />
<Table
items={Object.keys(details).map((key) => ({
key: localize(`views.governance.proposalsDetails.${key}`),
value: details[key] ?? 0,
}))}
/>
<Button size={ButtonSize.Medium} outline onClick={onAddProposalClick} classes="w-full">
{localize('actions.addProposal')}
</Button>
Expand Down
55 changes: 24 additions & 31 deletions packages/desktop/components/panes/ProposalInformationPane.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<script lang="ts">
import { type IItem, Table } from '@bloomwalletio/ui'
import { Table } from '@bloomwalletio/ui'
import { Pane, Text } from '@ui'
import { formatDate, localize } from '@core/i18n'
import { DATE_FORMAT, milestoneToDate, truncateString } from '@core/utils'
import { networkStatus } from '@core/network/stores'
import { ProposalStatus } from '@contexts/governance/enums'
import { selectedProposal } from '@contexts/governance/stores'
import { IProposal } from '@contexts/governance'
import { INetworkStatus } from '@core/network/interfaces'
export let classes: string = ''
Expand Down Expand Up @@ -44,38 +42,33 @@
return undefined
}
}
let items: IItem[] = []
$: setItems($selectedProposal, $networkStatus)
function setItems(proposal: IProposal, networkStatus: INetworkStatus): void {
items = []
if (proposalDateData?.propertyKey) {
items.push({
key: localize(`views.governance.details.proposalInformation.${proposalDateData.propertyKey}`),
value: formatDate(
milestoneToDate(networkStatus.currentMilestone, proposalDateData.milestone),
DATE_FORMAT
),
})
}
items.push({
key: localize('views.governance.details.proposalInformation.eventId'),
value: truncateString(proposal?.id, 9, 9),
copyable: true,
})
items.push({
key: localize('views.governance.details.proposalInformation.nodeUrl'),
value: proposal?.nodeUrl,
copyable: true,
})
}
</script>

<Pane classes="p-6 h-fit {classes}">
<Text smaller classes="mb-5">
{localize('views.governance.details.proposalInformation.title')}
</Text>
<Table {items} />
<Table
items={[
{
key: localize(`views.governance.details.proposalInformation.${proposalDateData.propertyKey}`),
value: proposalDateData?.propertyKey
? formatDate(
milestoneToDate($networkStatus.currentMilestone, proposalDateData.milestone),
DATE_FORMAT
)
: undefined,
},
{
key: localize('views.governance.details.proposalInformation.eventId'),
value: truncateString($selectedProposal?.id, 9, 9),
copyable: true,
},
{
key: localize('views.governance.details.proposalInformation.nodeUrl'),
value: $selectedProposal?.nodeUrl,
copyable: true,
},
]}
/>
</Pane>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { type IItem, Table } from '@bloomwalletio/ui'
import { Table } from '@bloomwalletio/ui'
import { onMount } from 'svelte'
import { selectedAccount } from '@core/account/stores'
import { handleError } from '@core/error/handlers/handleError'
Expand Down Expand Up @@ -32,69 +32,6 @@
}
}
let items: IItem[] = []
$: setItems($mintTokenDetails)
function setItems(details: IMintTokenDetails | undefined): void {
if (!details) {
return
}
items = []
const { name: tokenName, symbol, aliasId, url, logoUrl, decimals, totalSupply } = details
if (aliasId) {
items.push({
key: localize('popups.nativeToken.property.alias'),
value: aliasId,
copyable: true,
})
}
if (storageDeposit) {
items.push({
key: localize('popups.nativeToken.property.storageDeposit'),
value: storageDeposit,
})
}
if (tokenName) {
items.push({
key: localize('popups.nativeToken.property.tokenName'),
value: tokenName,
})
}
if (totalSupply) {
items.push({
key: localize('popups.nativeToken.property.totalSupply'),
value: String(totalSupply),
})
}
if (decimals) {
items.push({
key: localize('popups.nativeToken.property.decimals'),
value: String(decimals),
})
}
if (symbol) {
items.push({
key: localize('popups.nativeToken.property.symbol'),
value: symbol,
})
}
if (url) {
items.push({
key: localize('popups.nativeToken.property.url'),
value: url,
})
}
if (logoUrl) {
items.push({
key: localize('popups.nativeToken.property.logoUrl'),
value: logoUrl,
})
}
}
function getMetadata(details: IMintTokenDetails | undefined): IIrc30Metadata | undefined {
if (details) {
const { name: tokenName, symbol, description, url, logoUrl, decimals } = details
Expand Down Expand Up @@ -158,10 +95,48 @@
<Text type={TextType.h4} fontSize="18" lineHeight="6" fontWeight={FontWeight.semibold}>
{localize('popups.nativeToken.confirmationTitle')}
</Text>

<div class="space-y-2 max-h-100 scrollable-y flex-1">
<Table {items} />
</div>
{#if $mintTokenDetails}
{@const { name: tokenName, symbol, aliasId, url, logoUrl, decimals, totalSupply } = $mintTokenDetails}
<div class="space-y-2 max-h-100 scrollable-y flex-1">
<Table
items={[
{
key: localize('popups.nativeToken.property.alias'),
value: aliasId,
copyable: true,
},
{
key: localize('popups.nativeToken.property.storageDeposit'),
value: storageDeposit ? storageDeposit : undefined,
},
{
key: localize('popups.nativeToken.property.tokenName'),
value: tokenName,
},
{
key: localize('popups.nativeToken.property.totalSupply'),
value: String(totalSupply),
},
{
key: localize('popups.nativeToken.property.decimals'),
value: decimals ? String(decimals) : undefined,
},
{
key: localize('popups.nativeToken.property.symbol'),
value: symbol,
},
{
key: localize('popups.nativeToken.property.url'),
value: url,
},
{
key: localize('popups.nativeToken.property.logoUrl'),
value: logoUrl,
},
]}
/>
</div>
{/if}
<div class="flex flex-row flex-nowrap w-full space-x-4">
<Button outline classes="w-full" disabled={isTransferring} onClick={onBackClick}>
{localize('actions.back')}
Expand Down
103 changes: 54 additions & 49 deletions packages/desktop/components/popups/MintNftConfirmationPopup.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { type IItem, Table } from '@bloomwalletio/ui'
import { Table } from '@bloomwalletio/ui'
import { selectedAccount } from '@core/account/stores'
import { handleError } from '@core/error/handlers/handleError'
import { localize } from '@core/i18n'
Expand Down Expand Up @@ -40,49 +40,6 @@
...(attributes && { attributes }),
}
let nftTabDetails: { [key in string]: string }
$: {
nftTabDetails = {
name,
...(description && { description }),
uri,
...(issuerName && { issuerName }),
...(collectionName && { collectionName }),
}
}
let transactionTabItems: IItem[] = []
$: activeTab === Tab.Transaction && setTransactionTabItems(quantity)
function setTransactionTabItems(quantity: number): void {
transactionTabItems = []
if (quantity > 1) {
transactionTabItems.push({
key: localize('general.quantity'),
value: quantity,
})
transactionTabItems.push({
key: localize('general.storageDepositPerNft'),
value: formatTokenAmountPrecise(storageDeposit, getBaseToken()),
})
transactionTabItems.push({
key: localize('general.totalStorageDeposit'),
value: formatTokenAmountPrecise(totalStorageDeposit, getBaseToken()),
})
} else {
transactionTabItems.push({
key: localize('general.storageDeposit'),
value: formatTokenAmountPrecise(storageDeposit, getBaseToken()),
})
}
transactionTabItems.push({
key: localize('general.immutableIssuer'),
value: $selectedAccount.depositAddress,
})
}
async function prepareNftOutput(): Promise<void> {
const outputData = buildNftOutputData(irc27Metadata, $selectedAccount.depositAddress)
const preparedOutput = await $selectedAccount.buildNftOutput(outputData)
Expand Down Expand Up @@ -135,13 +92,61 @@
<activity-details class="w-full h-full space-y-2 flex flex-auto flex-col shrink-0">
<Tabs bind:activeTab {tabs} />
{#if activeTab === Tab.Transaction}
<Table items={transactionTabItems} />
<Table
items={[
{
key: localize('general.quantity'),
value: quantity > 1 ? quantity : undefined,
},
{
key: localize('general.storageDepositPerNft'),
value:
quantity > 1 ? formatTokenAmountPrecise(storageDeposit, getBaseToken()) : undefined,
},
{
key: localize('general.totalStorageDeposit'),
value:
quantity > 1
? formatTokenAmountPrecise(totalStorageDeposit, getBaseToken())
: undefined,
},
{
key: localize('general.storageDeposit'),
value:
quantity === 0
? formatTokenAmountPrecise(storageDeposit, getBaseToken())
: undefined,
},
{
key: localize('general.immutableIssuer'),
value: $selectedAccount?.depositAddress,
},
]}
/>
{:else if activeTab === Tab.Nft}
<Table
items={Object.entries(nftTabDetails).map(([key, value]) => ({
key: localize(`general.${key}`),
value,
}))}
items={[
{
key: localize('general.name'),
value: name,
},
{
key: localize('general.description'),
value: description ? description : undefined,
},
{
key: localize('general.uri'),
value: uri,
},
{
key: localize('general.issuerName'),
value: issuerName ? issuerName : undefined,
},
{
key: localize('general.collectionName'),
value: collectionName ? collectionName : undefined,
},
]}
/>
{:else if activeTab === Tab.Metadata}
<Table
Expand Down
Loading

0 comments on commit 161d125

Please sign in to comment.