Merge pull request #67 from PhillipLangMartinez/bugfix/is-already-sponsored-change-logic

Bugfix/is already sponsored change logic
This commit is contained in:
AlphaX-Projects 2022-08-31 07:43:26 +02:00 committed by GitHub
commit b80766efc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 11 deletions

View File

@ -98,8 +98,7 @@ class BecomeMinter extends LitElement {
async atMount() { async atMount() {
this.changeLanguage(); this.changeLanguage();
this.addressInfo =
window.parent.reduxStore.getState().app.accountInfo.addressInfo;
this.isPageLoading = true; this.isPageLoading = true;
try { try {
const [nodeInfo, myRewardShareArray, mintingaccounts] = const [nodeInfo, myRewardShareArray, mintingaccounts] =
@ -117,6 +116,8 @@ class BecomeMinter extends LitElement {
myRewardShareArray[0]?.rewardSharePublicKey; myRewardShareArray[0]?.rewardSharePublicKey;
this.isPageLoading = false; this.isPageLoading = false;
this.mintingAccountData = mintingaccounts; this.mintingAccountData = mintingaccounts;
this.addressInfo =
window.parent.reduxStore.getState().app.accountInfo.addressInfo;
} catch (error) { } catch (error) {
console.error(error); console.error(error);
@ -147,15 +148,18 @@ class BecomeMinter extends LitElement {
} }
render() { render() {
const findMintingAccount = this.mintingAccountData?.find( const findMintingAccount = this.mintingAccountData?.find(
(ma) => ma.recipientAccount === window.parent.reduxStore.getState().app?.selectedAddress (ma) => ma.recipientAccount === window.parent.reduxStore.getState().app?.selectedAddress
?.address ?.address
); );
const isAlreadySponsored = const isAlreadySponsored =
this.addressInfo?.error !== 124 && this.addressInfo?.error !== 124 &&
this.addressInfo?.level === 0 && this.addressInfo?.level === 0 &&
findMintingAccount; this.addressInfo?.blocksMinted > 0 && this.addressInfo?.blocksMinted < 7200
return html` return html`
${this.isPageLoading ${this.isPageLoading
@ -176,19 +180,20 @@ class BecomeMinter extends LitElement {
</div> </div>
${isAlreadySponsored ${isAlreadySponsored
? '' ? ''
: html` : html`
<not-sponsored <not-sponsored
.atMount="${() => this.atMount()}" .atMount="${() => this.atMount()}"
></not-sponsored> ></not-sponsored>
`} `}
${!isAlreadySponsored ${!isAlreadySponsored
? '' ? ''
: html` : html`
<yes-sponsored <yes-sponsored
.rewardSharePublicKey=${this .rewardSharePublicKey=${this
.rewardSharePublicKey} .rewardSharePublicKey}
.addressInfo=${this.addressInfo} .addressInfo=${this.addressInfo}
.isMinting=${!!findMintingAccount}
></yes-sponsored> ></yes-sponsored>
`} `}
</div> </div>

View File

@ -19,6 +19,7 @@ class YesSponsored extends LitElement {
return { return {
addressInfo: { type: Object }, addressInfo: { type: Object },
rewardSharePublicKey: { type: String }, rewardSharePublicKey: { type: String },
isMinting: {type: Boolean}
}; };
} }
@ -27,6 +28,7 @@ class YesSponsored extends LitElement {
this.addressInfo = {}; this.addressInfo = {};
this.rewardSharePublicKey = ''; this.rewardSharePublicKey = '';
this.isMinting = false
} }
static styles = [pageStyles]; static styles = [pageStyles];
@ -63,7 +65,12 @@ class YesSponsored extends LitElement {
<hr <hr
style="color: #eee; border-radius: 90%; margin-bottom: 1rem;" style="color: #eee; border-radius: 90%; margin-bottom: 1rem;"
/> />
${this.isMinting ? html`
<h4>${translate('becomeMinterPage.bchange12')}</h4> <h4>${translate('becomeMinterPage.bchange12')}</h4>
` : html`
<h4>${translate('mintingpage.mchange9')}</h4>
`}
</div> </div>
<div class="content-box"> <div class="content-box">
<span class="title" <span class="title"