diff --git a/src-tauri/src/farmer.rs b/src-tauri/src/farmer.rs index f48b6a06..517ae979 100644 --- a/src-tauri/src/farmer.rs +++ b/src-tauri/src/farmer.rs @@ -56,6 +56,11 @@ impl Default for ArchivingFrom { } } +#[tauri::command] +pub(crate) fn validate_reward_address(addr: &str) -> bool { + parse_reward_address(addr).is_ok() +} + /// manages the `farm` process /// waits on the `farm` handle, and restarts the `farm` process if needed #[tauri::command] diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ed8871b2..b2fe2ddf 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -97,6 +97,7 @@ async fn main() -> Result<()> { #[cfg(not(target_os = "windows"))] tauri::generate_handler![ farmer::farming, + farmer::validate_reward_address, node::start_node, utils::frontend_error_logger, utils::frontend_info_logger, @@ -111,6 +112,7 @@ async fn main() -> Result<()> { windows::winreg_set, windows::winreg_delete, farmer::farming, + farmer::validate_reward_address, node::start_node, utils::frontend_error_logger, utils::frontend_info_logger, diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index 4d5e8248..b2b50409 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -16,19 +16,19 @@ pub(crate) fn open_folder(dir: String) { Command::new("explorer") .arg(dir) .spawn() - .expect("could not open to specified directory"); + .expect("could not open the specified directory"); #[cfg(target_os = "macos")] Command::new("open") .arg(dir) .spawn() - .expect("could not open to specified directory"); + .expect("could not open the specified directory"); #[cfg(target_os = "linux")] Command::new("xdg-open") .arg(dir) .spawn() - .expect("could not open to specified directory"); + .expect("could not open the specified directory"); } #[tauri::command] diff --git a/src/i18n/en.json b/src/i18n/en.json index 0ec9b6ed..ffc9f39a 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -86,10 +86,9 @@ "importKey": { "tooltip": "Please provide a valid Reward Address to proceed.", "pageTitle": "Import Reward Address", - "rewardAddress": "Please enter your Reward Address in SS58 format (it should start with the letters \"st\")", + "rewardAddress": "Please use a proper wallet address from Subwallet or Polkadot.js extension", "continue": "continue", - "cancel": "Cancel", - "addressErrorMsg": "Invalid address" + "cancel": "Cancel" }, "header": { "IncentivizedLabel": "Incentivized Testnet", diff --git a/src/pages/ImportKey.vue b/src/pages/ImportKey.vue index c7c51532..a8a5fddd 100644 --- a/src/pages/ImportKey.vue +++ b/src/pages/ImportKey.vue @@ -11,56 +11,70 @@ q-page(padding) class="reward-address" v-model="store.rewardAddress" input-class="text-center" - :rules="[val => isValidSubstrateAddress(val) || $t('importKey.addressErrorMsg')]" + :error="!!store.rewardAddress && !isValidAddress" + :error-message="$t('importKey.rewardAddress')" ) .row.justify-center.q-mt-sm .row.justify-end.items-center.q-mt-lg.absolute-bottom.q-pa-lg .col-auto.q-mr-md q-btn( - @click="$router.replace({ name: 'index' })" - :label="$t('importKey.cancel')" - outline - size="lg" + @click="$router.replace({ name: 'index' })" + :label="$t('importKey.cancel')" + outline + size="lg" icon-right="cancel" ) q-space .col-auto q-btn( - :disable="!isValidSubstrateAddress(store.rewardAddress)" + :disable="!isValidAddress" :label="$t('importKey.continue')" @click="importKey()" icon-right="arrow_forward" outline size="lg" ) - q-tooltip.q-pa-md(v-if="!isValidSubstrateAddress(store.rewardAddress)") + q-tooltip.q-pa-md(v-if="!isValidAddress") p.q-mb-lg {{ $t('importKey.tooltip') }}