Skip to content

Commit

Permalink
feat: block and display negative BIC error when main account has nega…
Browse files Browse the repository at this point in the history
…tive BIC
  • Loading branch information
cpl121 committed Apr 4, 2024
1 parent 18c9cfb commit 8eb8e14
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
11 changes: 10 additions & 1 deletion packages/desktop/components/popups/ActivityDetailsPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import { TextHintVariant } from '@ui/enums'
import { onMount } from 'svelte'
import { ManaBox } from '@components'
import { showAppNotification } from '@auxiliary/notification'
export let activityId: string
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
Expand All @@ -48,6 +49,14 @@
activity?.direction === ActivityDirection.SelfTransaction) &&
activity?.asyncData?.asyncStatus === ActivityAsyncStatus.Unclaimed
$: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0
$: if (hasMainAccountNegativeBIC) {
showAppNotification({
type: 'warning',
message: localize('views.accountManagement.hasMainAccountNegativeBIC'),
})
}
function onExplorerClick(): void {
let url: string
if (activity?.type === ActivityType.Vesting) {
Expand Down Expand Up @@ -168,7 +177,7 @@
</Button>
<Button
classes="w-full"
disabled={activity.asyncData?.isClaiming || !hasEnoughMana}
disabled={activity.asyncData?.isClaiming || !hasEnoughMana || hasMainAccountNegativeBIC}
onClick={onClaimClick}
isBusy={activity.asyncData?.isClaiming}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { getClient, prepareCreateNativeToken } from '@core/wallet/actions'
import { ManaBox } from '@components'
import { ITransactionInfoToCalculateManaCost } from '@core/network'
import { showAppNotification } from '@auxiliary/notification'
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
Expand All @@ -30,6 +31,14 @@
$: metadata = getMetadata($mintTokenDetails)
$: isTransferring = $selectedWallet?.isTransferring
$: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0
$: if (hasMainAccountNegativeBIC) {
showAppNotification({
type: 'warning',
message: localize('views.accountManagement.hasMainAccountNegativeBIC'),
})
}
async function prepareFoundryOutput(): Promise<void> {
if ($mintTokenDetails && $selectedWallet && metadata) {
const { totalSupply, circulatingSupply, accountAddress } = $mintTokenDetails
Expand Down Expand Up @@ -175,7 +184,7 @@
</Button>
<Button
classes="w-full"
disabled={isTransferring || !hasEnoughMana}
disabled={isTransferring || !hasEnoughMana || hasMainAccountNegativeBIC}
onClick={onConfirmClick}
isBusy={isTransferring}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import { CURRENT_IRC27_VERSION } from '@core/nfts'
import { ManaBox } from '@components'
import { ITransactionInfoToCalculateManaCost } from '@core/network'
import { showAppNotification } from '@auxiliary/notification'
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
Expand Down Expand Up @@ -54,6 +55,14 @@
}
}
$: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0
$: if (hasMainAccountNegativeBIC) {
showAppNotification({
type: 'warning',
message: localize('views.accountManagement.hasMainAccountNegativeBIC'),
})
}
async function prepareNftOutput(): Promise<void> {
const outputData = buildNftOutputData(irc27Metadata, $selectedWallet.depositAddress)
const client = await getClient()
Expand Down Expand Up @@ -153,7 +162,7 @@
</Button>
<Button
classes="w-full"
disabled={$selectedWallet?.isTransferring || !hasEnoughMana}
disabled={$selectedWallet?.isTransferring || !hasEnoughMana || hasMainAccountNegativeBIC}
onClick={onConfirmClick}
isBusy={$selectedWallet?.isTransferring}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import { onMount } from 'svelte'
import { get } from 'svelte/store'
import { ITransactionInfoToCalculateManaCost } from '@core/network'
import { showAppNotification } from '@auxiliary/notification'
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
export let isSendAndClosePopup: boolean = false
Expand Down Expand Up @@ -229,6 +230,12 @@
}
$: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0
$: if (hasMainAccountNegativeBIC) {
showAppNotification({
type: 'warning',
message: localize('views.accountManagement.hasMainAccountNegativeBIC'),
})
}
</script>

<send-confirmation-popup class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ignoreActivity,
getTimeDifference,
Activity,
selectedWallet,
} from '@core/wallet'
import { ActivityAsyncStatusPill, TooltipIcon, Text, Button, TileFooter, FontWeight, ButtonSize } from '@ui'
import { time } from '@core/app'
Expand All @@ -26,6 +27,8 @@
$: timeDiff = getTimeDiff(activity)
$: hasExpirationTime = !!activity.asyncData?.expirationDate
$: hasMainAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[$selectedWallet?.mainAccountId] < 0
function onIgnoreClick(): void {
openPopup({
id: PopupId.Confirmation,
Expand Down Expand Up @@ -94,7 +97,7 @@
</Button>
<Button
onClick={onClaimClick}
disabled={activity.asyncData?.isClaiming}
disabled={activity.asyncData?.isClaiming || hasMainAccountNegativeBIC}
isBusy={activity.asyncData?.isClaiming}
inlineStyle="min-width: 4rem;"
size={ButtonSize.Small}
Expand Down

0 comments on commit 8eb8e14

Please sign in to comment.