-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/fix-ledger-popup-on-send
- Loading branch information
Showing
38 changed files
with
658 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
packages/desktop/components/popup/popups/MintNftCollectionConfirmationPopup.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<script lang="ts"> | ||
import { Table, Avatar, Tabs } from '@bloomwalletio/ui' | ||
import { selectedAccount } from '@core/account/stores' | ||
import { handleError } from '@core/error/handlers/handleError' | ||
import { localize } from '@core/i18n' | ||
import { CURRENT_IRC27_VERSION } from '@core/nfts' | ||
import { getClient } from '@core/profile-manager' | ||
import { checkActiveProfileAuthAsync, getBaseToken } from '@core/profile/actions' | ||
import { formatTokenAmountPrecise } from '@core/token' | ||
import { buildNftOutputBuilderParams, mintNftCollection, mintNftCollectionDetails } from '@core/wallet' | ||
import { PopupId, closePopup, openPopup } from '@desktop/auxiliary/popup' | ||
import { MediaIcon, PopupTab, getTabItems } from '@ui' | ||
import { onMount } from 'svelte' | ||
import PopupTemplate from '../PopupTemplate.svelte' | ||
const TABS = getTabItems([PopupTab.Transaction, PopupTab.Nft, PopupTab.NftMetadata]) | ||
let selectedTab = TABS[0] | ||
let storageDeposit: number = 0 | ||
const { standard, type, uri, name, issuerName, description, attributes } = $mintNftCollectionDetails || {} | ||
$: irc27Metadata = { | ||
standard, | ||
version: CURRENT_IRC27_VERSION, | ||
name, | ||
type, | ||
uri, | ||
...(issuerName && { issuerName }), | ||
...(description && { description }), | ||
...(attributes && { attributes }), | ||
} | ||
async function setStorageDeposit(): Promise<void> { | ||
try { | ||
const outputData = buildNftOutputBuilderParams(irc27Metadata, $selectedAccount.depositAddress) | ||
const client = await getClient() | ||
const preparedOutput = await client.buildNftOutput(outputData) | ||
storageDeposit = Number(preparedOutput.amount) ?? 0 | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
} | ||
function onBackClick(): void { | ||
closePopup() | ||
openPopup({ | ||
id: PopupId.MintNftCollectionForm, | ||
overflow: true, | ||
confirmClickOutside: true, | ||
}) | ||
} | ||
async function onConfirmClick(): Promise<void> { | ||
try { | ||
await checkActiveProfileAuthAsync() | ||
} catch (err) { | ||
return | ||
} | ||
try { | ||
await mintNftCollection(irc27Metadata) | ||
closePopup() | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
} | ||
onMount(() => { | ||
try { | ||
void setStorageDeposit() | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
}) | ||
</script> | ||
|
||
<PopupTemplate | ||
title={localize('popups.mintNftForm.title')} | ||
backButton={{ | ||
text: localize('actions.back'), | ||
disabled: $selectedAccount?.isTransferring, | ||
onClick: onBackClick, | ||
}} | ||
continueButton={{ | ||
text: localize('actions.confirm'), | ||
disabled: $selectedAccount?.isTransferring, | ||
onClick: onConfirmClick, | ||
}} | ||
busy={$selectedAccount?.isTransferring} | ||
> | ||
<div class="max-h-100 scrollable-y flex-1"> | ||
<nft-details class="flex flex-col justify-center items-center space-y-5"> | ||
<Avatar size="lg" shape="square" surface={2}> | ||
<MediaIcon {type} size="base" surface={2} /> | ||
</Avatar> | ||
<activity-details class="w-full h-full space-y-2 flex flex-auto flex-col shrink-0"> | ||
<Tabs bind:selectedTab tabs={TABS} /> | ||
{#if selectedTab.key === PopupTab.Transaction} | ||
<Table | ||
items={[ | ||
{ | ||
key: localize('general.storageDeposit'), | ||
value: formatTokenAmountPrecise(storageDeposit, getBaseToken()), | ||
}, | ||
{ | ||
key: localize('general.immutableIssuer'), | ||
value: $selectedAccount?.depositAddress, | ||
truncate: true, | ||
}, | ||
]} | ||
/> | ||
{:else if selectedTab.key === PopupTab.Nft} | ||
<Table | ||
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, | ||
}, | ||
]} | ||
/> | ||
{:else if selectedTab.key === PopupTab.NftMetadata} | ||
<Table | ||
items={[ | ||
{ | ||
key: localize('general.metadata'), | ||
value: irc27Metadata, | ||
copyable: true, | ||
}, | ||
]} | ||
/> | ||
{/if} | ||
</activity-details> | ||
</nft-details> | ||
</div> | ||
</PopupTemplate> |
Oops, something went wrong.