From 3ddd8009f59c6e36a8d91572a63d9bca037bb4c1 Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Wed, 24 Aug 2022 15:43:46 +0300 Subject: [PATCH 01/14] remove text --- qortal-ui-core/language/us.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qortal-ui-core/language/us.json b/qortal-ui-core/language/us.json index 974495eb..895d0f85 100644 --- a/qortal-ui-core/language/us.json +++ b/qortal-ui-core/language/us.json @@ -174,7 +174,7 @@ "mchange33":"Introduction", "mchange34":"In Qortal, in order to become a minter and begin earning QORT rewards with your increase in Minter Level, you must first become ‘sponsored’. A sponsor in Qortal is any other minter of level 5 or higher, or a Qortal Founder. You will obtain a sponsorship key from the sponsor, and use that key to get to level 1. Once you have reached level 1, you will be able to create your own minting key and start earning rewards for helping secure the Qortal Blockchain.", "mchange35":"Sponsorship", - "mchange36":"Your sponsor will issue you a ‘Sponsorship Key’ which you will use to add to your node, and begin minting (for no rewards until reaching level 1.) Once you reach level 1, you create/assign your own ‘Minting Key’ and begin earning rewards. You have XXXX blocks remaining in your sponsorship period.", + "mchange36":"Your sponsor will issue you a ‘Sponsorship Key’ which you will use to add to your node, and begin minting (for no rewards until reaching level 1.) Once you reach level 1, you create/assign your own ‘Minting Key’ and begin earning rewards.", "mchange37":"Simply reach out to a minter in Qortal who is high enough level to issue a sponsorship key, obtain that key, then come back here and input the key to begin your minting journey !", "mchange38":"in" }, From b6caf166453d83772199830644c5f844a8e29b2f Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Wed, 24 Aug 2022 15:45:01 +0300 Subject: [PATCH 02/14] add condition to see if public key exists in node --- .../plugins/core/become-minter/become-minter.src.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qortal-ui-plugins/plugins/core/become-minter/become-minter.src.js b/qortal-ui-plugins/plugins/core/become-minter/become-minter.src.js index d0509219..f2f887e3 100644 --- a/qortal-ui-plugins/plugins/core/become-minter/become-minter.src.js +++ b/qortal-ui-plugins/plugins/core/become-minter/become-minter.src.js @@ -147,9 +147,9 @@ class BecomeMinter extends LitElement { } render() { - console.log({ mintingAccountData: this.mintingAccountData }); const findMintingAccount = this.mintingAccountData?.find( - (ma) => !!ma.publicKey + (ma) => ma.publicKey === window.parent.reduxStore.getState().app?.selectedAddress + ?.base58PublicKey ); const isAlreadySponsored = From fa9765e5101b13bf3485329a86afb2b86f4cc773 Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Wed, 24 Aug 2022 16:21:04 +0300 Subject: [PATCH 03/14] fix table mobile and adress one line --- .../sponsorship-list-css.src.js | 15 ++++++++++-- .../sponsorship-list/sponsorship-list.src.js | 23 ++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list-css.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list-css.src.js index 1851c584..eb0fd61b 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list-css.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list-css.src.js @@ -201,9 +201,9 @@ export const pageStyles = css` .tableGrid { display: grid; - grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax( + grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax( 0, - 1fr + 2fr ) minmax(0, 1fr); align-items: center; gap: 5px; @@ -214,6 +214,16 @@ export const pageStyles = css` } + .header { + align-self: flex-start; + + + } + + .header p { + word-break: break-word ; + } + .grid-item { text-align: center; @@ -331,6 +341,7 @@ export const pageStyles = css` text-decoration: none; margin: 0px; margin-right: 10px; + word-break: break-word; } .grid-item { diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index 3a3696d0..f7ee2b78 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -119,6 +119,7 @@ class SponsorshipList extends LitElement { const address = window.parent.reduxStore.getState().app?.selectedAddress ?.address + let rewardShares = await this.getRewardShareRelationship( address ) @@ -420,7 +421,7 @@ class SponsorshipList extends LitElement { render() { - + console.log({sponsors: this.sponsorships}) return html` ${ this.isPageLoading @@ -452,17 +453,17 @@ class SponsorshipList extends LitElement {

${translate("sponsorshipspage.schange1")}

-
+

${translate("sponsorshipspage.schange2")}

-
+

${translate("walletprofile.blocksminted")}

-
+

${translate("becomeMinterPage.bchange17")}

-
+
@@ -472,17 +473,23 @@ class SponsorshipList extends LitElement { (sponsorship) => html`
  • - +

    + Account Address +

    ${sponsorship.address}
  • - +

    + Blocks Minted +

    ${+sponsorship.blocksMinted + +sponsorship.blocksMintedAdjustment}
  • - +

    + Copy Sponsorship Key +

    Date: Fri, 26 Aug 2022 00:15:38 +0300 Subject: [PATCH 04/14] added popup to indicate progress --- qortal-ui-core/font/switch-theme.css | 2 + .../sponsorship-list-css.src.js | 74 +++- .../sponsorship-list/sponsorship-list.src.js | 348 +++++++++++------- 3 files changed, 290 insertions(+), 134 deletions(-) diff --git a/qortal-ui-core/font/switch-theme.css b/qortal-ui-core/font/switch-theme.css index 45fb525b..bb48fc95 100644 --- a/qortal-ui-core/font/switch-theme.css +++ b/qortal-ui-core/font/switch-theme.css @@ -30,6 +30,7 @@ html { --nav-icon-color: #080808; --nav-border-color: #eeeeee; --nav-border-selected-color: #03a9f4; + --error: #d50000; --background: url("/img/qortal_background_light_.jpg"); } @@ -65,5 +66,6 @@ html[theme="dark"] { --nav-icon-color: #008fd5; --nav-border-color: #0b305e; --nav-border-selected-color: #76c8f5; + --error: #d50000; --background: url("/img/qortal_background_dark_.jpg"); } diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list-css.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list-css.src.js index eb0fd61b..9e64410f 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list-css.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list-css.src.js @@ -37,8 +37,8 @@ export const pageStyles = css` - .message { - color: var(--gray); + .message-error { + color: var(--error); } @@ -62,6 +62,15 @@ export const pageStyles = css` .row { display: flex; width: 100%; + align-items: center; + } + + .hide { + visibility: hidden + } + + .inactiveText { + opacity: .60 } .column { display: flex; @@ -156,6 +165,30 @@ export const pageStyles = css` z-index: 9; position: fixed; } + .marginLoader { + margin-left: 10px; + } + .marginRight { + margin-right: 10px; + } + .smallLoading, + .smallLoading:after { + border-radius: 50%; + width: 2px; + height: 2px; + } + + .smallLoading { + border-width: 0.6em; + border-style: solid; + border-color: rgba(3, 169, 244, 0.2) rgba(3, 169, 244, 0.2) + rgba(3, 169, 244, 0.2) rgb(3, 169, 244); + font-size: 10px; + position: relative; + text-indent: -9999em; + transform: translateZ(0px); + animation: 1.1s linear 0s infinite normal none running loadingAnimation; + } .loading, .loading:after { @@ -277,7 +310,9 @@ export const pageStyles = css` } - + .word-break { + word-break:break-all; + } .dialog-container { width: 300px; min-height: 300px; @@ -367,4 +402,37 @@ export const pageStyles = css` grid-column: 1 / -1; } } + + .between { + justify-content: space-between; + } + .no-width { + width: auto + } + + .between p { + margin: 0; + padding: 0; + } + + #showDialogRewardShareCreationStatus .dialog-container { + width: 300px; + min-height: 250px; + max-height: 75vh; + padding: 5px; + display: flex; + align-items: flex-start; + flex-direction: column; +} + +.warning{ + display: flex; + flex-grow: 1 +} + +#showDialogRewardShareCreationStatus li { + margin-bottom: 15px; +} ` + + diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index f7ee2b78..47f86313 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -16,11 +16,25 @@ import "@vaadin/button" import "@material/mwc-button" import "@polymer/paper-spinner/paper-spinner-lite.js" import '@material/mwc-dialog' +import {asyncReplace} from 'lit/directives/async-replace.js'; import { pageStyles } from "./sponsorship-list-css.src.js" const parentEpml = new Epml({ type: "WINDOW", source: window.parent }) +async function* countDown(count, callback) { + + + while (count > 0) { + yield count--; + await new Promise((r) => setTimeout(r, 1000)); + if(count === 0){ + console.log('hello call') + callback() + } + } + } + class SponsorshipList extends LitElement { static get properties() { return { @@ -32,11 +46,14 @@ class SponsorshipList extends LitElement { mintingAccountData: { type: Array }, sponsorships: { type: Array }, removeRewardShareLoading: { type: Array }, - createSponsorshipMessage: { type: String }, + errorMessage: { type: String }, isLoadingCreateSponsorship: { type: Array }, publicKeyValue: { type: String }, - error: { type: Boolean }, - isOpenModal: {type: Boolean} + isOpenModal: {type: Boolean}, + status: {type: Number}, + privateRewardShareKey: {type: String}, + timer: {type: Number}, + openDialogRewardShare: {type: Boolean} } } @@ -54,11 +71,14 @@ class SponsorshipList extends LitElement { this.mintingAccountData = null this.sponsorships = [] this.removeRewardShareLoading = false - this.error = false - this.createSponsorshipMessage = "" + + this.errorMessage = "" this.isLoadingCreateSponsorship = false this.publicKeyValue = "" this.isOpenModal = false + this.status = 0 + this.privateRewardShareKey = "" + this.openDialogRewardShare = false } inputHandler(e) { @@ -108,17 +128,38 @@ class SponsorshipList extends LitElement { return nodeInfo } + async saveToClipboard(text) { + try { + await navigator.clipboard.writeText(text) + parentEpml.request('showSnackBar', this.onSuccessMessage) + } catch (err) { + parentEpml.request('showSnackBar', this.onErrorMessage) + console.error('Copy to clipboard error:', err) + } + } + + changeStatus(value){ + this.status = value + saveToClipboard(translate( + "walletpage.wchange4" + )) + + } + async atMount() { this.changeLanguage() - + this.addressInfo = window.parent.reduxStore.getState().app.accountInfo.addressInfo this.isPageLoading = true try { - const address = - window.parent.reduxStore.getState().app?.selectedAddress - ?.address + // const address = + // window.parent.reduxStore.getState().app?.selectedAddress + // ?.address + + const address = 'QPsjHoKhugEADrtSQP5xjFgsaQPn9WmE3Y' + let rewardShares = await this.getRewardShareRelationship( address @@ -153,6 +194,7 @@ class SponsorshipList extends LitElement { if(openModal){ this.shadowRoot.querySelector('#showDialog').show() } + } catch (error) { @@ -251,18 +293,20 @@ class SponsorshipList extends LitElement { removeReceiver() } - async createRewardShare(e) { - this.error = false - this.createSponsorshipMessage = "" - const recipientPublicKey = this.publicKeyValue + async createRewardShare(publicKeyValue) { + this.openDialogRewardShare = true + + this.privateRewardShareKey = "" + + this.errorMessage = "" + const recipientPublicKey = publicKeyValue const percentageShare = 0 const selectedAddress = window.parent.reduxStore.getState().app?.selectedAddress // Check for valid... this.isLoadingCreateSponsorship = true + - let recipientAddress = - window.parent.base58PublicKeyToAddress(recipientPublicKey) // Get Last Ref const getLastRef = async () => { @@ -282,96 +326,39 @@ class SponsorshipList extends LitElement { return myAccountDetails } - // Get Reward Relationship if it already exists - const getRewardShareRelationship = async (minterAddr) => { - let isRewardShareExisting = false - let myRewardShareArray = await parentEpml.request("apiCall", { - type: "api", - url: `/addresses/rewardshares?minters=${minterAddr}&recipients=${recipientAddress}`, - }) - isRewardShareExisting = - myRewardShareArray.length !== 0 ? true : false - return isRewardShareExisting - } + // Validate Reward Share by Level const validateReceiver = async () => { - let accountDetails = await getAccountDetails() + let accountDetails + try { + accountDetails = await getAccountDetails() + } catch (error) { + this.errorMessage = "Couldn't fetch account details" + } + let lastRef = await getLastRef() - let isExisting = await getRewardShareRelationship( - selectedAddress.address - ) - - // Check for creating self share at different levels (also adding check for flags...) - if (accountDetails.flags === 1) { - this.error = false - this.createSponsorshipMessage = "" - let myTransaction = await makeTransactionRequest(lastRef) - if (isExisting === true) { - this.error = true - this.createSponsorshipMessage = `Cannot Create Multiple Reward Shares!` - } else { - // Send the transaction for confirmation by the user - this.error = false - this.createSponsorshipMessage = "" - getTxnRequestResponse(myTransaction) - } - } else if (accountDetails.address === recipientAddress) { - if (accountDetails.level >= 1 && accountDetails.level <= 4) { - this.error = false - this.createSponsorshipMessage = "" - let myTransaction = await makeTransactionRequest(lastRef) - if (isExisting === true) { - let err1string = get("rewardsharepage.rchange18") - this.error = true - this.createSponsorshipMessage = `${err1string}` - } else { - // Send the transaction for confirmation by the user - this.error = false - this.createSponsorshipMessage = "" - getTxnRequestResponse(myTransaction) - } - } else if (accountDetails.level >= 5) { - this.error = false - this.createSponsorshipMessage = "" - let myTransaction = await makeTransactionRequest(lastRef) - if (isExisting === true) { - let err2string = get("rewardsharepage.rchange19") - this.error = true - this.createSponsorshipMessage = `${err2string}` - } else { - // Send the transaction for confirmation by the user - this.error = false - this.createSponsorshipMessage = "" - getTxnRequestResponse(myTransaction) - } - } else { - let err3string = get("rewardsharepage.rchange20") - this.error = true - this.createSponsorshipMessage = `${err3string} ${accountDetails.level}` - } - } else { - //Check for creating reward shares if (accountDetails.level >= 5) { - this.error = false - this.createSponsorshipMessage = "" - let myTransaction = await makeTransactionRequest(lastRef) - if (isExisting === true) { - let err4string = get("rewardsharepage.rchange18") - this.error = true - this.createSponsorshipMessage = `${err4string}` - } else { - // Send the transaction for confirmation by the user - this.error = false - this.createSponsorshipMessage = "" + this.status = 1 + + this.errorMessage = "" + + try { + const myTransaction = await makeTransactionRequest(lastRef) + + getTxnRequestResponse(myTransaction) + } catch (error) { + this.errorMessage = error?.message || 'Error creating relationship' } + + } else { - this.error = true + let err5string = get("rewardsharepage.rchange20") - this.createSponsorshipMessage = `${err5string} ${accountDetails.level}` + this.errorMessage = `${err5string} ${accountDetails.level}` } - } + } // Make Transaction Request @@ -399,26 +386,69 @@ class SponsorshipList extends LitElement { const getTxnRequestResponse = (txnResponse) => { if (txnResponse.success === false && txnResponse.message) { - this.error = true - this.createSponsorshipMessage = txnResponse.message - throw new Error(txnResponse) + + this.errorMessage = txnResponse.message + this.isLoadingCreateSponsorship = false + throw(txnResponse) } else if ( txnResponse.success === true && !txnResponse.data.error ) { - let err6string = get("rewardsharepage.rchange21") - this.createSponsorshipMessage = err6string - this.error = false + + this.isLoadingCreateSponsorship = false + + this.privateRewardShareKey = txnResponse.data + this.confirmRelationship() } else { - this.error = true - this.createSponsorshipMessage = txnResponse.data.message - throw new Error(txnResponse) + + this.errorMessage = txnResponse.data.message + this.isLoadingCreateSponsorship = false + throw(txnResponse) } } validateReceiver() - this.isLoadingCreateSponsorship = false + + } + + + + async confirmRelationship(){ + let interval = null + let stop = false + + const getAnswer = async () => { + if (!stop) { + stop= true; + + try { + + const recipientAddress = + window.parent.base58PublicKeyToAddress(recipientPublicKey) + const minterAddress = window.parent.reduxStore.getState().app?.selectedAddress.address + const myRewardShareArray = await parentEpml.request("apiCall", { + type: "api", + url: `/addresses/rewardshares?minters=${minterAddress}&recipients=${recipientAddress}`, + }) + if(myRewardShareArray.length > 0){ + clearInterval(interval) + this.status = 3 + + + this.timer = countDown(180, ()=> this.changeStatus(4)); + } + + } catch (error) { + + } + + stop = false + } + }; + interval = setInterval(getAnswer, 2000); } + + render() { console.log({sponsors: this.sponsorships}) @@ -490,22 +520,8 @@ class SponsorshipList extends LitElement {

    Copy Sponsorship Key

    - + + this.createRewardShare(sponsorship.publicKey)}>copy
  • ` : ''} -

    ${this.createSponsorshipMessage}

    +

    ${this.errorMessage}

    @@ -605,6 +615,82 @@ class SponsorshipList extends LitElement { ${translate("general.close")} + + + +
    +
    +

    In progress

    3 && 'hide'}`}>
    +
    + +
    +
    +
    +
      + + + +
    • 1. Creating relationship
    • +
    • +

      + 2. Awaiting confirmation on blockchain +

      +
      + +
    • + +
    • +

      + 3. Finishing up +

      + +
      +
      ${asyncReplace(this.timer)} +
      + + +
    • +
    • +

      + 4. Complete +

      + + +
    • + ${this.privateRewardShareKey && this.status === 4 ? html` +
    • + +

      Copy the key below and share it with your sponsored person.

      +
      + ${this.privateRewardShareKey} +
      + + + + +
    • + ` : ''} +
    +
    +

    + Warning: do not close the Qortal UI until completion! +

    +

    ${this.errorMessage}

    +
    + +
    + { + this.openDialogRewardShare = false + this.errorMessage = '' + }} + class="red" + > + ${translate("general.close")} + + +
    ` From 0c784813c48601d752f7ee3cb201a819086ace0f Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 26 Aug 2022 00:16:48 +0300 Subject: [PATCH 05/14] removed testing key --- .../plugins/core/sponsorship-list/sponsorship-list.src.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index 47f86313..436a3f71 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -154,11 +154,11 @@ class SponsorshipList extends LitElement { this.isPageLoading = true try { - // const address = - // window.parent.reduxStore.getState().app?.selectedAddress - // ?.address + const address = + window.parent.reduxStore.getState().app?.selectedAddress + ?.address - const address = 'QPsjHoKhugEADrtSQP5xjFgsaQPn9WmE3Y' + let rewardShares = await this.getRewardShareRelationship( From f7f4dbec14fb441b5e187593872aa51b0427b907 Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 26 Aug 2022 00:28:55 +0300 Subject: [PATCH 06/14] added state changes --- .../plugins/core/sponsorship-list/sponsorship-list.src.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index 436a3f71..bea00fa0 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -684,6 +684,8 @@ class SponsorshipList extends LitElement { @click=${()=>{ this.openDialogRewardShare = false this.errorMessage = '' + this.isLoadingCreateSponsorship = false + this.privateRewardShareKey = "" }} class="red" > From 94f050aae746db7a87ded9b1288ecd6aaae251a1 Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 26 Aug 2022 00:37:15 +0300 Subject: [PATCH 07/14] fix conditions --- .../plugins/core/sponsorship-list/sponsorship-list.src.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index bea00fa0..8823d55a 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -650,7 +650,7 @@ class SponsorshipList extends LitElement {
  • -
  • +
  • 4. Complete

    @@ -658,7 +658,7 @@ class SponsorshipList extends LitElement {
  • ${this.privateRewardShareKey && this.status === 4 ? html` -
  • +
  • Copy the key below and share it with your sponsored person.

    From da2f1a0afa999dbfd1529e2ebc046581a519ad3c Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 26 Aug 2022 00:51:03 +0300 Subject: [PATCH 08/14] remove import --- .../plugins/core/sponsorship-list/sponsorship-list.src.js | 1 - 1 file changed, 1 deletion(-) diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index 8823d55a..461f58bf 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -13,7 +13,6 @@ import "@polymer/paper-spinner/paper-spinner-lite.js" import "@material/mwc-button" import "@material/mwc-textfield" import "@vaadin/button" -import "@material/mwc-button" import "@polymer/paper-spinner/paper-spinner-lite.js" import '@material/mwc-dialog' import {asyncReplace} from 'lit/directives/async-replace.js'; From 66a3f52e11f53df3dc9d4ddea8a28f38477d0fc8 Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 26 Aug 2022 00:53:12 +0300 Subject: [PATCH 09/14] remove log --- .../plugins/core/sponsorship-list/sponsorship-list.src.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index 461f58bf..fb6e6438 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -28,7 +28,7 @@ async function* countDown(count, callback) { yield count--; await new Promise((r) => setTimeout(r, 1000)); if(count === 0){ - console.log('hello call') + callback() } } From 098da59648b1a302e42e05c76833a71725de6dae Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 26 Aug 2022 19:12:04 +0300 Subject: [PATCH 10/14] fixes --- .../core/sponsorship-list/sponsorship-list.src.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index fb6e6438..5010f1f8 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -139,7 +139,7 @@ class SponsorshipList extends LitElement { changeStatus(value){ this.status = value - saveToClipboard(translate( + this.saveToClipboard(translate( "walletpage.wchange4" )) @@ -384,6 +384,13 @@ class SponsorshipList extends LitElement { } const getTxnRequestResponse = (txnResponse) => { + + if(txnResponse.message.includes('multiple')){ + this.isLoadingCreateSponsorship = false + + this.privateRewardShareKey = txnResponse.data + this.confirmRelationship(recipientPublicKey) + } if (txnResponse.success === false && txnResponse.message) { this.errorMessage = txnResponse.message @@ -411,7 +418,7 @@ class SponsorshipList extends LitElement { - async confirmRelationship(){ + async confirmRelationship(recipientPublicKey){ let interval = null let stop = false @@ -437,6 +444,7 @@ class SponsorshipList extends LitElement { } } catch (error) { + console.error(error) } From 3401e884a174fac964a3c3786a1570b03da9ab94 Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 26 Aug 2022 19:12:57 +0300 Subject: [PATCH 11/14] added popup for start-minting process --- .../src/components/start-minting.js | 452 +++++++++++++++--- 1 file changed, 377 insertions(+), 75 deletions(-) diff --git a/qortal-ui-core/src/components/start-minting.js b/qortal-ui-core/src/components/start-minting.js index 5fa35fe7..9d2bfd59 100644 --- a/qortal-ui-core/src/components/start-minting.js +++ b/qortal-ui-core/src/components/start-minting.js @@ -2,27 +2,193 @@ import { LitElement, html, css } from 'lit'; import { connect } from 'pwa-helpers'; import { store } from '../store.js'; import { translate, get } from 'lit-translate'; +import {asyncReplace} from 'lit/directives/async-replace.js'; import '../functional-components/my-button.js'; import { routes } from '../plugins/routes.js'; +import "@material/mwc-button" +import '@material/mwc-dialog' + + +async function* countDown(count, callback) { + + + while (count > 0) { + yield count--; + await new Promise((r) => setTimeout(r, 1000)); + if(count === 0){ + + callback() + } + } + } class StartMinting extends connect(store)(LitElement) { static get properties() { return { addressInfo: { type: Object }, mintingAccountData: { type: Array }, errorMsg: { type: String }, + openDialogRewardShare : {type: Boolean}, + status: {type: Number}, + timer: {type: Number}, + privateRewardShareKey: {type: String} }; } static get styles() { return [ css` + + .dialogCustom { + position: fixed; + z-index: 10000; + display: flex; + justify-content: center; + flex-direction: column; + align-items: center; + top: 0px; + bottom: 0px; + + left: 0px; + width: 100vw; + } + .dialogCustomInner { + + width: 300px; + min-height: 400px; + background-color: var(--white); + box-shadow: var(--mdc-dialog-box-shadow, 0px 11px 15px -7px rgba(0, 0, 0, 0.2), 0px 24px 38px 3px rgba(0, 0, 0, 0.14), 0px 9px 46px 8px rgba(0, 0, 0, 0.12)); + padding: 20px 24px; + border-radius: 4px; + } + .dialogCustomInner ul { + padding-left: 0px + } + .dialogCustomInner li { + margin-bottom: 10px; + } .start-minting-wrapper { position: absolute; left: 50%; transform: translateX(calc(-50% - 10px)); + z-index: 10; } + + .dialog-header h1 { + font-size: 18px; + } + + .row { + display: flex; + width: 100%; + align-items: center; + } + + .modalFooter { + width: 100%; + display: flex; + justify-content: flex-end; + } + + + + + .hide { + visibility: hidden + } + + .inactiveText { + opacity: .60 + } + .column { + display: flex; + flex-direction: column; + width: 100%; + } + + .smallLoading, + .smallLoading:after { + border-radius: 50%; + width: 2px; + height: 2px; + } + + .smallLoading { + border-width: 0.6em; + border-style: solid; + border-color: rgba(3, 169, 244, 0.2) rgba(3, 169, 244, 0.2) + rgba(3, 169, 244, 0.2) rgb(3, 169, 244); + font-size: 10px; + position: relative; + text-indent: -9999em; + transform: translateZ(0px); + animation: 1.1s linear 0s infinite normal none running loadingAnimation; + } + @-webkit-keyframes loadingAnimation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } + } + + @keyframes loadingAnimation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } + } + + .word-break { + word-break:break-all; + } + .dialog-container { + width: 300px; + min-height: 300px; + max-height: 75vh; + padding: 5px; + display: flex; + align-items: flex-start; + flex-direction: column; + + + } + + + .between { + justify-content: space-between; + } + .no-width { + width: auto + } + + .between p { + margin: 0; + padding: 0; + } + .marginLoader { + margin-left: 10px; + } + .marginRight { + margin-right: 10px; + } + .warning{ + display: flex; + flex-grow: 1 +} + +.message-error { + color: var(--error); + } + `, ]; } @@ -32,6 +198,9 @@ class StartMinting extends connect(store)(LitElement) { this.addressInfo = {}; this.mintingAccountData = []; this.errorMsg = ''; + this.openDialogRewardShare = false; + this.status = 0; + this.privateRewardShareKey = ""; } render() { @@ -40,6 +209,10 @@ class StartMinting extends connect(store)(LitElement) { firstUpdated() { this.getMintingAcccounts(); + + + + this.shadowRoot.querySelector('mdc-dialog--open').setAttribute('style', 'width: 100vw') } async getMintingAcccounts() { @@ -60,6 +233,103 @@ class StartMinting extends connect(store)(LitElement) { } } + async changeStatus(value){ + this.status = value + const publicAddress = + window.parent.reduxStore.getState().app?.selectedAddress + ?.base58PublicKey; + // Check to see if a sponsorship key on a newly-level 1 minter exists. If it does, remove it. + const findMintingAccountFromOtherUser = mintingAccountData.find( + (ma) => !ma.publicKey.includes(publicAddress) + ); + const removeMintingAccount = async (publicKey) => { + const url = `${nodeUrl}/admin/mintingaccounts?apiKey=${myNode.apiKey}`; + + return await fetch(url, { + method: 'DELETE', + body: publicKey, + }); + }; + + const addMintingAccount = async (sponsorshipKeyValue) => { + const url = `${nodeUrl}/admin/mintingaccounts?apiKey=${myNode.apiKey}`; + + return await fetch(url, { + method: 'POST', + body: sponsorshipKeyValue, + }); + }; + + try { + if ( + findMintingAccountFromOtherUser && + findMintingAccountFromOtherUser?.publicKey[0] + ) { + await removeMintingAccount( + findMintingAccountFromOtherUser?.publicKey[0] + ); + } + } catch (error) { + this.errorMsg = 'Failed to remove key'; + return; + } + + try { + await addMintingAccount(sponsorshipKeyValue); + routes.showSnackBar({ + data: translate('becomeMinterPage.bchange19'), + }); + this.status = 5; + this.getMintingAcccounts(); + } catch (error) { + this.errorMsg = 'Failed to add minting key'; + return; + } + + } + + + + async confirmRelationship(){ + let interval = null + let stop = false + this.status = 2 + const getAnswer = async () => { + + const rewardShares = async (minterAddr) => { + const url = `${nodeUrl}/addresses/rewardshares?minters=${minterAddr}&recipients=${minterAddr}`; + const res = await fetch(url); + const data = await res.json(); + return data; + }; + + if (!stop) { + stop= true; + + try { + + const address = + window.parent.reduxStore.getState().app?.selectedAddress?.address; + + const myRewardShareArray = await rewardShares(address); + if(myRewardShareArray.length > 0){ + clearInterval(interval) + this.status = 3 + + + this.timer = countDown(180, ()=> this.changeStatus(4)); + } + + } catch (error) { + + } + + stop = false + } + }; + interval = setInterval(getAnswer, 2000); + } + renderStartMintingButton() { const myNode = store.getState().app.nodeConfig.knownNodes[ @@ -70,12 +340,7 @@ class StartMinting extends connect(store)(LitElement) { const mintingAccountData = this.mintingAccountData; const addressInfo = this.addressInfo; - const rewardShares = async (minterAddr) => { - const url = `${nodeUrl}/addresses/rewardshares?minters=${minterAddr}&recipients=${minterAddr}`; - const res = await fetch(url); - const data = await res.json(); - return data; - }; + const address = window.parent.reduxStore.getState().app?.selectedAddress?.address; const nonce = @@ -92,14 +357,7 @@ class StartMinting extends connect(store)(LitElement) { addressInfo?.level === 1 && !findMintingAccount; - const removeMintingAccount = async (publicKey) => { - const url = `${nodeUrl}/admin/mintingaccounts?apiKey=${myNode.apiKey}`; - - return await fetch(url, { - method: 'DELETE', - body: publicKey, - }); - }; + const makeTransactionRequest = async (lastRef) => { let mylastRef = lastRef; @@ -128,8 +386,12 @@ class StartMinting extends connect(store)(LitElement) { }; const getTxnRequestResponse = (txnResponse) => { + + if(txnResponse?.message?.includes('multiple')){ + return err6string + } if (txnResponse.success === false && txnResponse.message) { - throw new Error(txnResponse); + throw(txnResponse); } else if ( txnResponse.success === true && !txnResponse.data.error @@ -137,11 +399,12 @@ class StartMinting extends connect(store)(LitElement) { let err6string = get('rewardsharepage.rchange21'); return err6string; } else { - throw new Error(txnResponse); + throw(txnResponse); } }; const createSponsorshipKey = async () => { + this.status= 1 let lastRef = await getLastRef(); let myTransaction = await makeTransactionRequest(lastRef); @@ -149,14 +412,7 @@ class StartMinting extends connect(store)(LitElement) { getTxnRequestResponse(myTransaction); return myTransaction.data; }; - const addMintingAccount = async (sponsorshipKeyValue) => { - const url = `${nodeUrl}/admin/mintingaccounts?apiKey=${myNode.apiKey}`; - - return await fetch(url, { - method: 'POST', - body: sponsorshipKeyValue, - }); - }; + const getLastRef = async () => { const url = `${nodeUrl}/addresses/lastreference/${address}`; @@ -167,64 +423,23 @@ class StartMinting extends connect(store)(LitElement) { return data; }; - const startMinting = async () => { - this.errorMsg = ''; - let rewardSharesList; - try { - rewardSharesList = await rewardShares(address); - } catch (error) { - this.errorMsg = 'Cannot fetch reward shares'; - return; - } - // check to see if self-share exists - const findRewardShareData = rewardSharesList.find( - (rs) => - rs?.mintingAccount === address && rs?.recipient === address - ); - let sponsorshipKeyValue = null; - try { - if (!findRewardShareData) { - // if no self-share exits, create one. - sponsorshipKeyValue = await createSponsorshipKey(); - } else { - sponsorshipKeyValue = - findRewardShareData.rewardSharePublicKey; - } - } catch (error) { - this.errorMsg = 'Cannot create sponsorship key'; - return; - } - - // Check to see if a sponsorship key on a newly-level 1 minter exists. If it does, remove it. - const findMintingAccountFromOtherUser = mintingAccountData.find( - (ma) => !ma.publicKey.includes(publicAddress) - ); + const startMinting = async () => { + this.openDialogRewardShare = true + this.errorMsg = ''; + try { - if ( - findMintingAccountFromOtherUser && - findMintingAccountFromOtherUser?.publicKey[0] - ) { - await removeMintingAccount( - findMintingAccountFromOtherUser?.publicKey[0] - ); - } + + this.privateRewardShareKey = await createSponsorshipKey(); + this.confirmRelationship() } catch (error) { - this.errorMsg = 'Failed to remove key'; + console.log({error}) + this.errorMsg = error?.data?.message || 'Cannot create sponsorship key'; return; } - try { - await addMintingAccount(sponsorshipKeyValue); - routes.showSnackBar({ - data: translate('becomeMinterPage.bchange19'), - }); - this.getMintingAcccounts(); - } catch (error) { - this.errorMsg = 'Failed to add minting key'; - return; - } + }; return html` @@ -246,6 +461,93 @@ class StartMinting extends connect(store)(LitElement) { }} >
    + + + + + + ${this.openDialogRewardShare ? html` +
    +
    +
    +
    +

    In progress

    3 && 'hide'}`}>
    +
    + +
    +
    +
    +
      + + + +
    • 1. Creating relationship
    • +
    • +

      + 2. Awaiting confirmation on blockchain +

      +
      + +
    • + +
    • +

      + 3. Finishing up relationship +

      + +
      +
      ${asyncReplace(this.timer)} +
      + + +
    • +
    • +

      + 4. Adding minting key to node +

      +
      + +
    • +
    • +

      + 5. Complete +

      + + +
    • + +
    +
    +

    + Warning: do not close the Qortal UI until completion! +

    +

    ${this.errorMsg}

    +
    + +
    +
    + { + this.openDialogRewardShare = false + this.errorMsg = '' + + }} + class="red" + > + ${translate("general.close")} + +
    + + +
    + + + +
    + + ` : ""} + ` : ''} `; From f6e4de1bf33b16ed5bdcb02275b91e4278648715 Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 26 Aug 2022 19:34:10 +0300 Subject: [PATCH 12/14] change condition --- qortal-ui-core/src/components/start-minting.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qortal-ui-core/src/components/start-minting.js b/qortal-ui-core/src/components/start-minting.js index 9d2bfd59..361efdd0 100644 --- a/qortal-ui-core/src/components/start-minting.js +++ b/qortal-ui-core/src/components/start-minting.js @@ -354,7 +354,7 @@ class StartMinting extends connect(store)(LitElement) { ); const isMinterButKeyMintingKeyNotAssigned = addressInfo?.error !== 124 && - addressInfo?.level === 1 && + addressInfo?.level >= 1 && !findMintingAccount; From 536ccbcad20f605024993e878b720ad2cbbade94 Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Sat, 27 Aug 2022 15:28:37 +0300 Subject: [PATCH 13/14] fix bugs: key already existing publickey missing --- .../src/components/start-minting.js | 27 ++++++++--- qortal-ui-core/src/plugins/routes.js | 8 +++- .../sponsorship-list/sponsorship-list.src.js | 45 ++++++++++--------- 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/qortal-ui-core/src/components/start-minting.js b/qortal-ui-core/src/components/start-minting.js index 361efdd0..bc4a68c0 100644 --- a/qortal-ui-core/src/components/start-minting.js +++ b/qortal-ui-core/src/components/start-minting.js @@ -234,15 +234,23 @@ class StartMinting extends connect(store)(LitElement) { } async changeStatus(value){ + const myNode = + store.getState().app.nodeConfig.knownNodes[ + store.getState().app.nodeConfig.node + ]; + + const nodeUrl = + myNode.protocol + '://' + myNode.domain + ':' + myNode.port; this.status = value const publicAddress = window.parent.reduxStore.getState().app?.selectedAddress ?.base58PublicKey; // Check to see if a sponsorship key on a newly-level 1 minter exists. If it does, remove it. - const findMintingAccountFromOtherUser = mintingAccountData.find( + const findMintingAccountFromOtherUser = this.mintingAccountData.find( (ma) => !ma.publicKey.includes(publicAddress) ); const removeMintingAccount = async (publicKey) => { + const url = `${nodeUrl}/admin/mintingaccounts?apiKey=${myNode.apiKey}`; return await fetch(url, { @@ -275,7 +283,7 @@ class StartMinting extends connect(store)(LitElement) { } try { - await addMintingAccount(sponsorshipKeyValue); + await addMintingAccount(this.privateRewardShareKey); routes.showSnackBar({ data: translate('becomeMinterPage.bchange19'), }); @@ -291,6 +299,13 @@ class StartMinting extends connect(store)(LitElement) { async confirmRelationship(){ + const myNode = + store.getState().app.nodeConfig.knownNodes[ + store.getState().app.nodeConfig.node + ]; + const nodeUrl = + myNode.protocol + '://' + myNode.domain + ':' + myNode.port; + let interval = null let stop = false this.status = 2 @@ -386,8 +401,8 @@ class StartMinting extends connect(store)(LitElement) { }; const getTxnRequestResponse = (txnResponse) => { - - if(txnResponse?.message?.includes('multiple')){ + let err6string = get('rewardsharepage.rchange21'); + if(txnResponse?.extraData?.rewardSharePrivateKey && txnResponse.success === true){ return err6string } if (txnResponse.success === false && txnResponse.message) { @@ -396,7 +411,7 @@ class StartMinting extends connect(store)(LitElement) { txnResponse.success === true && !txnResponse.data.error ) { - let err6string = get('rewardsharepage.rchange21'); + return err6string; } else { throw(txnResponse); @@ -410,7 +425,7 @@ class StartMinting extends connect(store)(LitElement) { let myTransaction = await makeTransactionRequest(lastRef); getTxnRequestResponse(myTransaction); - return myTransaction.data; + return myTransaction?.extraData?.rewardSharePrivateKey }; diff --git a/qortal-ui-core/src/plugins/routes.js b/qortal-ui-core/src/plugins/routes.js index 215e653d..3ce4ec66 100644 --- a/qortal-ui-core/src/plugins/routes.js +++ b/qortal-ui-core/src/plugins/routes.js @@ -140,15 +140,21 @@ export const routes = { req.data.params ); - if (!req.disableModal) { + if (!req.disableModal && !req.data.disableModal) { await requestTransactionDialog.requestTransaction(tx); } const res = await processTransaction(tx.signedBytes); + let extraData = {} + if(req.data.type === 38 && tx?._rewardShareKeyPair?.secretKey){ + extraData.rewardSharePrivateKey = Base58.encode(tx._rewardShareKeyPair.secretKey) + } + response = { success: true, data: res, + extraData }; } catch (e) { console.error(e); diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index 5010f1f8..38bf91be 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -156,9 +156,8 @@ class SponsorshipList extends LitElement { const address = window.parent.reduxStore.getState().app?.selectedAddress ?.address - - + let rewardShares = await this.getRewardShareRelationship( address @@ -171,7 +170,6 @@ class SponsorshipList extends LitElement { type: "api", url: `/addresses/${rs.recipient}`, }) - let blocksRemaining = this._levelUpBlocks(addressInfo) blocksRemaining = +blocksRemaining > 0 ? +blocksRemaining : 0 return { @@ -294,7 +292,10 @@ class SponsorshipList extends LitElement { async createRewardShare(publicKeyValue) { this.openDialogRewardShare = true - + if(!publicKeyValue){ + this.errorMessage = "unable to pull public key from the chain, account has no outgoing transactions" + return + } this.privateRewardShareKey = "" this.errorMessage = "" @@ -348,7 +349,7 @@ class SponsorshipList extends LitElement { getTxnRequestResponse(myTransaction) } catch (error) { - this.errorMessage = error?.message || 'Error creating relationship' + this.errorMessage = error } @@ -379,37 +380,35 @@ class SponsorshipList extends LitElement { rewarddialog3: rewarddialog3, rewarddialog4: rewarddialog4, }, + disableModal: true }) return myTxnrequest } const getTxnRequestResponse = (txnResponse) => { - - if(txnResponse.message.includes('multiple')){ - this.isLoadingCreateSponsorship = false + + if(txnResponse?.extraData?.rewardSharePrivateKey && txnResponse.success === true){ - this.privateRewardShareKey = txnResponse.data - this.confirmRelationship(recipientPublicKey) - } - if (txnResponse.success === false && txnResponse.message) { + this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey + this.confirmRelationship() + } else if (txnResponse.success === false && txnResponse?.message) { - this.errorMessage = txnResponse.message + this.errorMessage = txnResponse?.message this.isLoadingCreateSponsorship = false - throw(txnResponse) + throw(txnResponse?.message) } else if ( txnResponse.success === true && !txnResponse.data.error ) { - this.isLoadingCreateSponsorship = false - this.privateRewardShareKey = txnResponse.data + this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey this.confirmRelationship() } else { - this.errorMessage = txnResponse.data.message + this.errorMessage = txnResponse?.data?.message || txnResponse?.message this.isLoadingCreateSponsorship = false - throw(txnResponse) + throw(txnResponse?.data?.message || txnResponse?.message) } } validateReceiver() @@ -419,10 +418,12 @@ class SponsorshipList extends LitElement { async confirmRelationship(recipientPublicKey){ + this.status = 2 let interval = null let stop = false const getAnswer = async () => { + if (!stop) { stop= true; @@ -458,7 +459,6 @@ class SponsorshipList extends LitElement { render() { - console.log({sponsors: this.sponsorships}) return html` ${ this.isPageLoading @@ -528,7 +528,11 @@ class SponsorshipList extends LitElement { Copy Sponsorship Key

    - this.createRewardShare(sponsorship.publicKey)}>copy + { + + + this.createRewardShare(sponsorship?.publicKey) + } }>copy
  • From 8d8c5c5ca425b1faa2e9c389e2b9a17f516575ea Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Sat, 27 Aug 2022 17:13:04 +0300 Subject: [PATCH 14/14] fix bugs --- qortal-ui-core/src/components/start-minting.js | 6 +++--- qortal-ui-core/src/plugins/routes.js | 8 ++++---- .../core/sponsorship-list/sponsorship-list.src.js | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/qortal-ui-core/src/components/start-minting.js b/qortal-ui-core/src/components/start-minting.js index bc4a68c0..3d6f6121 100644 --- a/qortal-ui-core/src/components/start-minting.js +++ b/qortal-ui-core/src/components/start-minting.js @@ -342,7 +342,7 @@ class StartMinting extends connect(store)(LitElement) { stop = false } }; - interval = setInterval(getAnswer, 2000); + interval = setInterval(getAnswer, 5000); } renderStartMintingButton() { @@ -402,7 +402,7 @@ class StartMinting extends connect(store)(LitElement) { const getTxnRequestResponse = (txnResponse) => { let err6string = get('rewardsharepage.rchange21'); - if(txnResponse?.extraData?.rewardSharePrivateKey && txnResponse.success === true){ + if(txnResponse?.extraData?.rewardSharePrivateKey && (txnResponse?.data?.message.includes('multiple') || txnResponse?.data?.message.includes('SELF_SHARE_EXISTS'))){ return err6string } if (txnResponse.success === false && txnResponse.message) { @@ -447,7 +447,7 @@ class StartMinting extends connect(store)(LitElement) { try { this.privateRewardShareKey = await createSponsorshipKey(); - this.confirmRelationship() + this.confirmRelationship(publicAddress) } catch (error) { console.log({error}) this.errorMsg = error?.data?.message || 'Cannot create sponsorship key'; diff --git a/qortal-ui-core/src/plugins/routes.js b/qortal-ui-core/src/plugins/routes.js index 3ce4ec66..c2101b02 100644 --- a/qortal-ui-core/src/plugins/routes.js +++ b/qortal-ui-core/src/plugins/routes.js @@ -143,14 +143,14 @@ export const routes = { if (!req.disableModal && !req.data.disableModal) { await requestTransactionDialog.requestTransaction(tx); } - + const res = await processTransaction(tx.signedBytes); let extraData = {} - if(req.data.type === 38 && tx?._rewardShareKeyPair?.secretKey){ + if(req.data.type === 38 && tx && tx._rewardShareKeyPair && tx._rewardShareKeyPair.secretKey){ extraData.rewardSharePrivateKey = Base58.encode(tx._rewardShareKeyPair.secretKey) } - - + + response = { success: true, data: res, diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index 38bf91be..dacc452a 100644 --- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -156,7 +156,6 @@ class SponsorshipList extends LitElement { const address = window.parent.reduxStore.getState().app?.selectedAddress ?.address - let rewardShares = await this.getRewardShareRelationship( @@ -387,10 +386,10 @@ class SponsorshipList extends LitElement { const getTxnRequestResponse = (txnResponse) => { - if(txnResponse?.extraData?.rewardSharePrivateKey && txnResponse.success === true){ + if(txnResponse?.extraData?.rewardSharePrivateKey && (txnResponse?.data?.message.includes('multiple') || txnResponse?.data?.message.includes('SELF_SHARE_EXISTS')) ){ this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey - this.confirmRelationship() + this.confirmRelationship(publicKeyValue) } else if (txnResponse.success === false && txnResponse?.message) { this.errorMessage = txnResponse?.message @@ -403,7 +402,7 @@ class SponsorshipList extends LitElement { this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey - this.confirmRelationship() + this.confirmRelationship(publicKeyValue) } else { this.errorMessage = txnResponse?.data?.message || txnResponse?.message @@ -431,6 +430,7 @@ class SponsorshipList extends LitElement { const recipientAddress = window.parent.base58PublicKeyToAddress(recipientPublicKey) + const minterAddress = window.parent.reduxStore.getState().app?.selectedAddress.address const myRewardShareArray = await parentEpml.request("apiCall", { type: "api", @@ -452,7 +452,7 @@ class SponsorshipList extends LitElement { stop = false } }; - interval = setInterval(getAnswer, 2000); + interval = setInterval(getAnswer, 5000); }