diff --git a/plugins/plugins/core/become-minter/not-sponsored.js b/plugins/plugins/core/become-minter/not-sponsored.js new file mode 100644 index 00000000..2199eef0 --- /dev/null +++ b/plugins/plugins/core/become-minter/not-sponsored.js @@ -0,0 +1,144 @@ +import { html, LitElement } from 'lit' +import { Epml } from '../../../epml' +import { becomeMinterStyles } from '../components/plugins-css' +import '../components/ButtonIconCopy' +import '@material/mwc-button' +import '@material/mwc-textfield' +import '@polymer/paper-spinner/paper-spinner-lite.js' +import '@vaadin/button' + +// Multi language support +import { translate } from '../../../../core/translate' + +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 get styles() { + return [becomeMinterStyles] + } + + constructor() { + super() + this.isLoadingSponsorshipKeySubmit = false + this.sponsorshipKeyValue = '' + this.addMintingAccountMessage = '' + this.atMount = () => {} + } + + 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` + + ` + } + +
+
+
+
+ ` + } + + firstUpdated() { + // ... + } + + renderErr1Text() { + return html`${translate('nodepage.nchange27')}` + } + + renderErr2Text() { + return html`${translate('nodepage.nchange28')}` + } + + 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 + } + + // Standard functions + getApiKey() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + return myNode.apiKey + } + + isEmptyArray(arr) { + if (!arr) { return true } + return arr.length === 0 + } + + round(number) { + return (Math.round(parseFloat(number) * 1e8) / 1e8).toFixed(8) + } +} + +window.customElements.define('not-sponsored', NotSponsored) diff --git a/plugins/plugins/core/become-minter/yes-sponsored.js b/plugins/plugins/core/become-minter/yes-sponsored.js new file mode 100644 index 00000000..44179592 --- /dev/null +++ b/plugins/plugins/core/become-minter/yes-sponsored.js @@ -0,0 +1,125 @@ +import { html, LitElement } from 'lit' +import { blocksNeed } from '../../utils/functions' +import { becomeMinterStyles } from '../components/plugins-css' +import '../components/ButtonIconCopy' +import '@material/mwc-button' +import '@material/mwc-textfield' +import '@polymer/paper-spinner/paper-spinner-lite.js' +import '@vaadin/button' + +// Multi language support +import { translate } from '../../../../core/translate' + +class YesSponsored extends LitElement { + static get properties() { + return { + addressInfo: { type: Object }, + rewardSharePublicKey: { type: String }, + isMinting: {type: Boolean} + } + } + + static get styles() { + return [becomeMinterStyles] + } + + constructor() { + super() + this.addressInfo = {} + this.rewardSharePublicKey = '' + this.isMinting = false + } + + 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} +

+ + +
+
+
+
+
+ ` + } + + firstUpdated() { + // ... + } + + _levelUpBlocks() { + return (blocksNeed(0) - (this.addressInfo?.blocksMinted + this.addressInfo?.blocksMintedAdjustment)).toString() + } + + // Standard functions + getApiKey() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + return myNode.apiKey + } + + isEmptyArray(arr) { + if (!arr) { return true } + return arr.length === 0 + } + + round(number) { + return (Math.round(parseFloat(number) * 1e8) / 1e8).toFixed(8) + } +} + +window.customElements.define('yes-sponsored', YesSponsored)