Skip to content

Commit

Permalink
FIX: ssv modal
Browse files Browse the repository at this point in the history
- fix operator explorer url for mainnet
- add registered operator metadata to dashboard
- adjust backup readme if ssv api is unavailable
  • Loading branch information
daverolo committed Mar 18, 2024
1 parent d5ee3fd commit e2fc031
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 18 deletions.
88 changes: 71 additions & 17 deletions launcher/src/components/UI/services-modal/SsvModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
: `${$t('serviceModal.showPerformance', {
opid: operatorData?.id,
opname: operatorData?.name,
network: network,
network: ucWord(network),
})}`
}`"
:btn-name="`${
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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`;
Expand All @@ -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`;
Expand All @@ -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).
`),
Expand Down Expand Up @@ -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({
Expand All @@ -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`;
Expand All @@ -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.
-----
`),
});
}
Expand Down
2 changes: 1 addition & 1 deletion launcher/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down

0 comments on commit e2fc031

Please sign in to comment.