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

ReferralSystem: Insufficient Bonded Amount Fix #698

Merged
merged 5 commits into from
May 24, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/views/ReferralProgram.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ import last from 'lodash/fp/last';
import { Component, Mixins, Watch } from 'vue-property-decorator';
import { components, mixins, api, WALLET_TYPES } from '@soramitsu/soraneo-wallet-web';
import { XOR } from '@sora-substrate/util/build/assets/consts';
import type { CodecString, FPNumber } from '@sora-substrate/util';
import { FPNumber } from '@sora-substrate/util';
import type { CodecString } from '@sora-substrate/util';
import type { AccountAsset } from '@sora-substrate/util/build/assets/types';

import router, { lazyView } from '@/router';
Expand Down Expand Up @@ -256,15 +257,20 @@ export default class ReferralProgram extends Mixins(
}

get bondedXorCodecBalance(): CodecString {
return this.xor?.balance?.bonded ?? '';
return this.xor?.balance?.bonded ?? '0';
}

get inviteUserFee(): string {
return this.formatCodecNumber(this.networkFees.ReferralSetInvitedUser);
}

get isInsufficientBondedAmount(): boolean {
return this.bondedXorCodecBalance ? this.networkFees.ReferralSetInvitedUser > this.bondedXorCodecBalance : false;
return this.bondedXorCodecBalance
? FPNumber.gt(
this.getFPNumberFromCodec(this.networkFees.ReferralSetInvitedUser),
this.getFPNumberFromCodec(this.bondedXorCodecBalance)
)
: false;
}

get formattedBondedXorBalance(): string {
Expand Down