From a72cebfea975e1ec872d1e24c235ed37f2c2016b Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Wed, 31 Aug 2022 01:14:05 +0300 Subject: [PATCH] added public key lookup with address --- qortal-ui-core/language/us.json | 8 +- .../sponsorship-list-css.src.js | 13 ++ .../sponsorship-list/sponsorship-list.src.js | 128 +++++++++++++++++- 3 files changed, 141 insertions(+), 8 deletions(-) diff --git a/qortal-ui-core/language/us.json b/qortal-ui-core/language/us.json index a99f27ca..4d33e8b4 100644 --- a/qortal-ui-core/language/us.json +++ b/qortal-ui-core/language/us.json @@ -649,6 +649,10 @@ "schange6":"Finished Sponsorships", "schange7":"Completed", "schange8":"Addresses", - "schange9":"You currently have no active sponsorships" + "schange9":"You currently have no active sponsorships", + "schange10" : "Public Key Lookup", + "schange11" : "Copy", + "schange12": "Address to Public Key Converter", + "schange13" : "Enter address" } -} +} 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 7e093d8b..116d9e97 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 @@ -143,6 +143,13 @@ export const pageStyles = css` outline: 1px var(--black) solid; min-width: 80px; } + mwc-icon-button { + height: 100%; + margin: 0; + cursor: pointer; + outline: 1px var(--black) solid; + min-width: 80px; + } .loader, .loader:after { border-radius: 50%; @@ -280,6 +287,12 @@ export const pageStyles = css` flex-wrap: wrap; } + .publicKeyLookupBtn { + position: fixed; + bottom: 15px; + right: 15px; + } + .summary-box p:first-child { margin-right: 30px; } 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 406108df..d7d58c2c 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 @@ -4,6 +4,7 @@ import "../components/ButtonIconCopy.js" import { use, get, translate, registerTranslateConfig } from "lit-translate" import { blocksNeed } from "../../utils/blocks-needed.js" import "../components/ButtonIconCopy.js" +import '@material/mwc-icon-button' registerTranslateConfig({ loader: (lang) => fetch(`/language/${lang}.json`).then((res) => res.json()), @@ -52,7 +53,11 @@ class SponsorshipList extends LitElement { status: {type: Number}, privateRewardShareKey: {type: String}, timer: {type: Number}, - openDialogRewardShare: {type: Boolean} + openDialogRewardShare: {type: Boolean}, + isOpenDialogPublicKeyLookup: {type: Boolean}, + lookupAddressValue: {type: String}, + lookupPublicAddressValue: {type: String}, + errorLookup: {type: String} } } @@ -78,11 +83,21 @@ class SponsorshipList extends LitElement { this.status = 0 this.privateRewardShareKey = "" this.openDialogRewardShare = false + this.isOpenDialogPublicKeyLookup = false + this.lookupAddressValue = "" + this.lookupPublicAddressValue = "" + this.errorLookup = "" } inputHandler(e) { this.publicKeyValue = e.target.value } + lookupPublicAddressInputHandler(e) { + this.lookupAddressValue = e.target.value + } + + + changeLanguage() { const checkLanguage = localStorage.getItem("qortalLanguage") @@ -127,9 +142,9 @@ class SponsorshipList extends LitElement { return nodeInfo } - async saveToClipboard(text) { + async saveToClipboard(toBeCopied, text) { try { - await navigator.clipboard.writeText(this.privateRewardShareKey) + await navigator.clipboard.writeText(toBeCopied) parentEpml.request('showSnackBar', text) } catch (err) { @@ -139,7 +154,7 @@ class SponsorshipList extends LitElement { changeStatus(value){ this.status = value - this.saveToClipboard('Copied to clipboard') + this.saveToClipboard(this.privateRewardShareKey, 'Copied to clipboard') } @@ -455,7 +470,22 @@ class SponsorshipList extends LitElement { interval = setInterval(getAnswer, 5000); } - + async lookUpPublicAddressFunc(){ + this.errorLookup = '' + try { + const response = await parentEpml.request("apiCall", { + type: "api", + url: `/addresses/publickey/${this.lookupAddressValue}`, + }) + if(response.error){ + throw(response.message) + } + this.lookupPublicAddressValue = response + } catch (error) { + this.errorLookup = error + console.error(error) + } + } render() { @@ -600,6 +630,18 @@ class SponsorshipList extends LitElement { )} +
+ + + ${translate("sponsorshipspage.schange10")} + + +
@@ -676,7 +718,7 @@ class SponsorshipList extends LitElement { ${this.privateRewardShareKey} { - this.saveToClipboard('Copied to clipboard') + this.saveToClipboard(this.privateRewardShareKey, 'Copied to clipboard') } }>copy @@ -708,6 +750,80 @@ class SponsorshipList extends LitElement { + + + + +
+

${translate("sponsorshipspage.schange10")}

+
+
+
+ +

+ ${translate("sponsorshipspage.schange12")} + +

+ +
+ + + + +
+

${this.errorLookup}

+
+ + ${translate("sponsorshipspage.schange10")} + +
+ + ${this.lookupPublicAddressValue ? html` +
+ ${this.lookupPublicAddressValue} +
+
+ { + + this.saveToClipboard(this.lookupPublicAddressValue, 'Copied to clipboard') + } }>${translate("sponsorshipspage.schange11")} + +
+ + ` : ''} + + + + +
+ + { + this.lookupAddressValue = "" + this.lookupPublicAddressValue = "" + this.isOpenDialogPublicKeyLookup = false + this.errorLookup = "" + + }} + > + ${translate("general.close")} + +
`