From e2fc0310c571a17b39047b0c2635da15435fb853 Mon Sep 17 00:00:00 2001 From: daverolo <107847185+daverolo@users.noreply.github.com> Date: Mon, 18 Mar 2024 23:25:41 +0100 Subject: [PATCH] FIX: ssv modal - fix operator explorer url for mainnet - add registered operator metadata to dashboard - adjust backup readme if ssv api is unavailable --- .../components/UI/services-modal/SsvModal.vue | 88 +++++++++++++++---- launcher/src/languages/en.json | 2 +- 2 files changed, 72 insertions(+), 18 deletions(-) diff --git a/launcher/src/components/UI/services-modal/SsvModal.vue b/launcher/src/components/UI/services-modal/SsvModal.vue index 67ddbd2a6..43286b380 100755 --- a/launcher/src/components/UI/services-modal/SsvModal.vue +++ b/launcher/src/components/UI/services-modal/SsvModal.vue @@ -69,7 +69,7 @@ : `${$t('serviceModal.showPerformance', { opid: operatorData?.id, opname: operatorData?.name, - network: network, + network: ucWord(network), })}` }`" :btn-name="`${ @@ -440,15 +440,25 @@ export default { } else { console.log("Current Key was backed up at least once, get operator data from SSV API"); - // Get operator data from SSV + // Get operator ID from SSV try { - let response = await axios.get( + const response = await axios.get( `https://api.ssv.network/api/v4/${this.network}/operators/public_key/` + this.pubkey ); - if (response && response?.data?.data?.publicKey) { - this.operatorData = response.data.data; - console.log("Operator registered"); - console.log("SSV: this.operatorData", this.operatorData); + if (response && response?.data?.data?.id) { + // Get operator metadata from SSV + const operator_id = response?.data?.data?.id; + const opurl = `https://api.ssv.network/api/v4/${this.network}/operators/` + operator_id; + const opresp = await axios.get(opurl); + console.log("opurl", opurl); + if (opresp && opresp?.data?.id) { + this.operatorData = opresp.data; + console.log("Operator registered"); + console.log("SSV: this.operatorData", this.operatorData); + } else { + this.apiUnavailable = true; + console.log(`SSV API did not respond metadata for operator ${operator_id}`); + } } else { console.log("SSV API reported unknown operator"); // this.operatorData = { name: "FakeNameTesting", id: 60 }; @@ -567,7 +577,8 @@ export default { if (!network) { throw new Error("openOperatorPage -> Network unknown"); } - let url = `https://${network}.explorer.ssv.network/operators/${operatorID}`; + let net = network == "mainnet" ? "" : network + "."; + let url = `https://${net}explorer.ssv.network/operators/${operatorID}`; window.open(url, "_blank"); }, openRegisterPage(network) { @@ -892,7 +903,6 @@ export default { }); let backupFileName = ""; if (this.operatorData) { - console.log("yo"); backupFileName = this.getCurrentDateTimeString(now) + `_ssv_unencrypted_operator_${this.operatorData.id}_${this.network}_backup.zip`; @@ -917,6 +927,30 @@ export default { The file "${skFileName}" holds your SSV Secret Key (also known as SSV Private Key). `), }); + } else if (this.apiUnavailable) { + backupFileName = + this.getCurrentDateTimeString(now) + `_ssv_unencrypted_operator_unavailable_${this.network}_backup.zip`; + downloadObjects.push({ + filename: "readme.txt", + content: this.formatReadmeContent(` + This is a backup of your SSV Operator keys! + ----------------------------------------------------------------- + Backup Date : ${this.getCurrentDateTimeString(now, true)} + Service-ID : ${this.ssvService.config.serviceID} + Network : ${this.ucWord(this.network)} + Operator Name : N/A (SSV API unavailable) + Operator ID : N/A (SSV API unavailable) + Public Key File: ${pkFileName} + Secret Key File: ${skFileName} + ----------------------------------------------------------------- + Important! + ========== + Keep this ZIP and all files included on a safe location! + If you loose those files your are not able to restore your SSV Operator. + The file "${pkFileName}" holds your SSV Public Key. + The file "${skFileName}" holds your SSV Secret Key (also known as SSV Private Key). + `), + }); } else { backupFileName = this.getCurrentDateTimeString() + `_ssv_unencrypted_operator_unregistered_${this.network}_backup.zip`; @@ -936,9 +970,7 @@ export default { Important! ========== Keep this ZIP and all files included on a safe location! - You have not registered an SSV Operator with this keys yet but if - you decide to do so later on and then loose those files your are - not able to restore your SSV Operator - thus keep them safe. + You have not yet registered an SSV Operator with these keys. However, if you decide to do this later and then lose these files, you will not be able to recover your SSV Operator. Therefore, keep them safe. The file "${pkFileName}" holds your SSV Public Key. The file "${skFileName}" holds your SSV Secret Key (also known as SSV Private Key). `), @@ -996,7 +1028,6 @@ export default { }); let backupFileName = ""; if (this.operatorData) { - console.log("yo"); backupFileName = this.getCurrentDateTimeString(now) + `_ssv_operator_${this.operatorData.id}_${this.network}_backup.zip`; downloadObjects.push({ @@ -1022,6 +1053,32 @@ export default { The file "${pwdFileName}" holds the password required by the SSV-node to decrypt your SSV Private Key. `), }); + } else if (this.apiUnavailable) { + backupFileName = + this.getCurrentDateTimeString(now) + `_ssv_unencrypted_operator_unavailable_${this.network}_backup.zip`; + downloadObjects.push({ + filename: "readme.txt", + content: this.formatReadmeContent(` + This is a backup of your SSV Operator keys! + ----------------------------------------------------------------- + Backup Date : ${this.getCurrentDateTimeString(now, true)} + Service-ID : ${this.ssvService.config.serviceID} + Network : ${this.ucWord(this.network)} + Operator Name : N/A (SSV API unavailable) + Operator ID : N/A (SSV API unavailable) + Public Key File: ${pkFileName} + KeyStore File : ${keyFileName} + Password File : ${pwdFileName} + ----------------------------------------------------------------- + Important! + ========== + Keep this ZIP and all files included on a safe location! + If you loose those files your are not able to restore your SSV Operator. + The file "${pkFileName}" holds your SSV Public Key. + The file "${keyFileName}" is a KeyStore that holds (inter alia) your encrypted SSV Private Key. + The file "${pwdFileName}" holds the password required by the SSV-node to decrypt your SSV Private Key. + `), + }); } else { backupFileName = this.getCurrentDateTimeString(now) + `_ssv_operator_unregistered_${this.network}_backup.zip`; @@ -1042,13 +1099,10 @@ export default { Important! ========== Keep this ZIP and all files included on a safe location! - You have not registered an SSV Operator with this keys yet but if - you decide to do so later on and then loose those files your are - not able to restore your SSV Operator - thus keep them safe. + You have not yet registered an SSV Operator with these keys. However, if you decide to do this later and then lose these files, you will not be able to recover your SSV Operator. Therefore, keep them safe. The file "${pkFileName}" holds your SSV Public Key. The file "${keyFileName}" is a KeyStore that holds (inter alia) your encrypted SSV Private Key. The file "${pwdFileName}" holds the password required by the SSV-node to decrypt your SSV Private Key. - ----- `), }); } diff --git a/launcher/src/languages/en.json b/launcher/src/languages/en.json index 0e439d579..b0567ffbd 100755 --- a/launcher/src/languages/en.json +++ b/launcher/src/languages/en.json @@ -849,7 +849,7 @@ "dnldBackup": "Please make sure to write down your password & download the backup. Nobody can help you recover your password or encrypted private key if you lose them!", "registerOperator": "Open the SSV web app in your default browser to register your operator.", "apiUnavailable": "Unknown dashboard state (SSV API currently unavailable).", - "showPerformance": "Shows an overview of the performance of your node for your registered operator with ID {opid} on the SSV Network at {network} as well as all the keys assigned to it.", + "showPerformance": "Shows an overview of the performance of your node for your registered operator \"{opname}\" with ID {opid} on the SSV Network at {network} as well as all the keys assigned to it.", "copyKey": "COPY PUBLIC OPERATOR KEY", "copyKeyDesc": "Copy the public operator key of your node to clipboard.", "skPk": "Secret Operator Key (SK) & Public Operator Key (PK)",