diff --git a/plugins/plugins/core/become-minter/components/not-sponsored.js b/plugins/plugins/core/become-minter/components/not-sponsored.js new file mode 100644 index 00000000..c298b55c --- /dev/null +++ b/plugins/plugins/core/become-minter/components/not-sponsored.js @@ -0,0 +1,137 @@ +import { LitElement, html } from 'lit'; +import { Epml } from '../../../../epml.js'; +import '../../components/ButtonIconCopy.js'; +import { use, translate, registerTranslateConfig } from 'lit-translate'; + +registerTranslateConfig({ + loader: (lang) => fetch(`/language/${lang}.json`).then((res) => res.json()), +}); + +import '@polymer/paper-spinner/paper-spinner-lite.js'; +import '@material/mwc-button'; +import '@material/mwc-textfield'; +import '@vaadin/button'; +import { pageStyles } from '../become-minter-css.src.js'; + +const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }); + +class NotSponsored extends LitElement { + static properties = { + atMount: { type: Function }, + isLoadingSponsorshipKeySubmit: { type: Boolean }, + sponsorshipKeyValue: { type: String }, + addMintingAccountMessage: { type: String }, + }; + + static styles = [pageStyles]; + + constructor() { + super(); + this.isLoadingSponsorshipKeySubmit = false; + this.sponsorshipKeyValue = ''; + this.addMintingAccountMessage = ''; + this.atMount = () => {}; + } + + renderErr1Text() { + return html`${translate('nodepage.nchange27')}`; + } + + renderErr2Text() { + return html`${translate('nodepage.nchange28')}`; + } + + getApiKey() { + const myNode = + window.parent.reduxStore.getState().app.nodeConfig.knownNodes[ + window.parent.reduxStore.getState().app.nodeConfig.node + ]; + let apiKey = myNode.apiKey; + return apiKey; + } + + addMintingAccount(e) { + this.isLoadingSponsorshipKeySubmit = true; + this.addMintingAccountMessage = 'Loading...'; + + parentEpml + .request('apiCall', { + url: `/admin/mintingaccounts?apiKey=${this.getApiKey()}`, + method: 'POST', + body: this.sponsorshipKeyValue, + }) + .then((res) => { + if (res === true) { + // refetch data + this.atMount(); + this.sponsorshipKeyValue = ''; + this.addMintingAccountMessage = this.renderErr1Text(); + this.isLoadingSponsorshipKeySubmit = false; + } else { + this.sponsorshipKeyValue = ''; + this.addMintingAccountMessage = this.renderErr2Text(); + this.isLoadingSponsorshipKeySubmit = false; + } + }); + } + + inputHandler(e) { + this.sponsorshipKeyValue = e.target.value; + } + + render() { + return html` +
+
+

+ ${translate('mintingpage.mchange33')} +

+

+ ${translate('mintingpage.mchange34')} +

+

+ ${translate('mintingpage.mchange35')} +

+

+ ${translate('mintingpage.mchange36')} +

+

+ ${translate('mintingpage.mchange37')} +

+ +

${this.addMintingAccountMessage}

+
+
+ + +
+ +
+ + ${this.isLoadingSponsorshipKeySubmit === false + ? html`${translate('puzzlepage.pchange15')}` + : html` + + `} + +
+
+
+
+ `; + } +} + +window.customElements.define('not-sponsored', NotSponsored); diff --git a/plugins/plugins/core/become-minter/components/yes-sponsored.js b/plugins/plugins/core/become-minter/components/yes-sponsored.js new file mode 100644 index 00000000..901c48d3 --- /dev/null +++ b/plugins/plugins/core/become-minter/components/yes-sponsored.js @@ -0,0 +1,114 @@ +import { LitElement, html } from 'lit'; +import { Epml } from '../../../../epml.js'; +import '../../components/ButtonIconCopy.js'; +import { use, translate, registerTranslateConfig } from 'lit-translate'; + +registerTranslateConfig({ + loader: (lang) => fetch(`/language/${lang}.json`).then((res) => res.json()), +}); + +import '@polymer/paper-spinner/paper-spinner-lite.js'; +import '@material/mwc-button'; +import '@material/mwc-textfield'; +import '@vaadin/button'; +import { blocksNeed } from '../../../utils/blocks-needed.js'; +import { pageStyles } from '../become-minter-css.src.js'; + +class YesSponsored extends LitElement { + static get properties() { + return { + addressInfo: { type: Object }, + rewardSharePublicKey: { type: String }, + isMinting: {type: Boolean} + }; + } + + constructor() { + super(); + + this.addressInfo = {}; + this.rewardSharePublicKey = ''; + this.isMinting = false + } + + static styles = [pageStyles]; + + _levelUpBlocks() { + let countBlocksString = ( + blocksNeed(0) - + (this.addressInfo?.blocksMinted + + this.addressInfo?.blocksMintedAdjustment) + ).toString(); + return countBlocksString; + } + + render() { + return html` +
+
+
+ + ${translate('becomeMinterPage.bchange10')} + +
+
+
+
+
+ + ${translate('walletpage.wchange41')} + +
+ ${this.isMinting ? html` +

${translate('becomeMinterPage.bchange12')}

+ ` : html` +

${translate('mintingpage.mchange9')}

+ `} +
+
+
+
+ + ${translate('becomeMinterPage.bchange13')} + +
+

+ ${this._levelUpBlocks()} + ${translate('mintingpage.mchange26')} +

+
+
+
+
+ + ${translate('becomeMinterPage.bchange15')} + +
+

+ ${translate('becomeMinterPage.bchange16')} +

+
+

+ ${this.rewardSharePublicKey} +

+ + +
+
+
+
+
+ `; + } +} + +window.customElements.define('yes-sponsored', YesSponsored);