Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: block and display negative BIC error when main account has negative BIC #8320

Merged
merged 7 commits into from
Apr 5, 2024
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
Loading