diff --git a/package.json b/package.json index 18788d94..3a9b6418 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "subspace-desktop", - "version": "0.4.2", + "version": "0.4.5", "private": true, "description": "Subspace desktop", "author": "Subspace Labs ", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e62146a5..2c6e48a7 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -9498,7 +9498,7 @@ dependencies = [ [[package]] name = "subspace-desktop" -version = "0.4.4" +version = "0.4.5" dependencies = [ "anyhow", "dotenv", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 7e113feb..c4f81315 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subspace-desktop" -version = "0.4.4" +version = "0.4.5" description = "Subspace desktop" authors = ["Subspace Labs "] license = "Apache-2.0" diff --git a/src/components/farmedList.vue b/src/components/farmedList.vue index e6ab2b77..85e81b0c 100644 --- a/src/components/farmedList.vue +++ b/src/components/farmedList.vue @@ -67,6 +67,7 @@ import { globalState as global } from "src/lib/global" import { FarmedBlock } from "src/lib/types" import { formatDistanceToNowStrict } from "date-fns" import { LocalStorage } from "quasar" +import { appConfig } from "src/lib/appConfig" const lang = global.data.loc.text.dashboard @@ -95,13 +96,15 @@ export default defineComponent({ return formatDistanceToNowStrict(date) }, displayRewardAddress() { - const addr: string | null = LocalStorage.getItem("rewardAddress") - if (addr == null) { - console.error("Reward Address was null!") - return "???" + const config = appConfig.getAppConfig() + let addr = "" + if (config && config.rewardAddress !== "") { + addr = config.rewardAddress } else { - return addr + console.error("FARMED LIST | could not retrieve reward address from config") + addr = "???" } + return addr } } }) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index a79ba9ba..6ae93cde 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -6,7 +6,7 @@ q-layout(view="hHh lpr fFf") q-toolbar-title .row .col-auto.q-mr-lg.relative-position - p {{ "0.4.4 "}} + p {{ "0.4.5 "}} .col-auto.q-mr-md.relative-position q-badge(color="grey" text-color="white") .q-pa-xs(style="font-size: 14px") {{ lang.nonIncentivizedLabel }} diff --git a/src/lib/appConfig.ts b/src/lib/appConfig.ts index 81df0211..7039a631 100644 --- a/src/lib/appConfig.ts +++ b/src/lib/appConfig.ts @@ -14,7 +14,7 @@ export const appConfig = { plot: Plot | null, segmentCache: SegmentCache | null, launchOnBoot: boolean | null, - importedRewAddr: boolean | null, + rewardAddress: string | null, plottingStarted: boolean | null ): void { const appConfig = this.getAppConfig() @@ -23,7 +23,7 @@ export const appConfig = { if (plot) newAppConfig.plot = plot if (segmentCache) newAppConfig.segmentCache = segmentCache if (launchOnBoot != null) newAppConfig.launchOnBoot = launchOnBoot - if (importedRewAddr != null) newAppConfig.importedRewAddr = importedRewAddr + if (rewardAddress) newAppConfig.rewardAddress = rewardAddress if (plottingStarted != null) newAppConfig.plottingStarted = plottingStarted LocalStorage.set("appConfig", newAppConfig) } diff --git a/src/lib/client.ts b/src/lib/client.ts index ef02ef0c..5c15b81e 100644 --- a/src/lib/client.ts +++ b/src/lib/client.ts @@ -16,6 +16,7 @@ import { SubPreDigest } from "src/lib/types" import EventEmitter from "events" +import { appConfig } from "./appConfig" export const myEmitter = new EventEmitter(); @@ -52,13 +53,15 @@ export class Client { this.stop() }, start: async (): Promise => { - - const farmerAddress = LocalStorage.getItem("rewardAddress") - if (farmerAddress === null) { - console.error("Reward address should not have been null...") + const config = appConfig.getAppConfig() + let farmerAddress = "" + if (config && config.rewardAddress !== "") { + farmerAddress = config.rewardAddress + } + if (farmerAddress === "") { + console.error("Reward address should not have been empty...") return } - this.unsubscribe = await this.localApi.rpc.chain.subscribeNewHeads( async ({ hash, number }) => { const blockNum = number.toNumber() @@ -234,15 +237,18 @@ export class Client { const keyring = new Keyring() const pair = keyring.createFromUri(mnemonic) keyring.setSS58Format(2254); // 2254 is the prefix for subspace-testnet - LocalStorage.set("rewardAddress", pair.address) + appConfig.updateAppConfig(null, null, null, pair.address, null) this.mnemonic = mnemonic } /* FARMER INTEGRATION */ public async startFarming(path: string, plotSizeGB: number): Promise { const plotSize = Math.round(plotSizeGB * 1048576) - const rewardAddress: string | null = LocalStorage.getItem("rewardAddress") - if (rewardAddress == null) { + const config = appConfig.getAppConfig() + let rewardAddress = "" + if (config && config.rewardAddress !== "") { + rewardAddress = config.rewardAddress + } else { console.error("Tried to send empty reward address to backend!") } return await tauri.invoke("farming", { path, rewardAddress, plotSize }) diff --git a/src/lib/util.ts b/src/lib/util.ts index 84e1b171..908a451b 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -43,7 +43,7 @@ export interface AppConfig { plot: Plot segmentCache: SegmentCache launchOnBoot: boolean - importedRewAddr: boolean + rewardAddress: string plottingStarted: boolean } @@ -60,7 +60,7 @@ export const emptyAppConfig: AppConfig = { plot: { location: "", sizeGB: 0 }, segmentCache: { networkSegmentCount: 0, blockchainSizeGB: 0 }, launchOnBoot: true, - importedRewAddr: false, + rewardAddress: "", plottingStarted: false } diff --git a/src/pages/ImportKey.vue b/src/pages/ImportKey.vue index d305f524..31cfda48 100644 --- a/src/pages/ImportKey.vue +++ b/src/pages/ImportKey.vue @@ -59,8 +59,7 @@ export default defineComponent({ } }, async importKey() { - LocalStorage.set("rewardAddress", this.rewardAddress) - appConfig.updateAppConfig(null, null, null, true, null) + appConfig.updateAppConfig(null, null, null, this.rewardAddress, null) this.$router.replace({ name: "setupPlot" }) }, skip() { diff --git a/src/pages/SetupPlot.vue b/src/pages/SetupPlot.vue index c50a4aad..a54edb73 100644 --- a/src/pages/SetupPlot.vue +++ b/src/pages/SetupPlot.vue @@ -300,7 +300,7 @@ export default defineComponent({ async checkIdentity() { const config = appConfig.getAppConfig() if (config) { - if (config.importedRewAddr === false) { + if (config.rewardAddress === "") { await this.client.createRewardAddress() await this.viewMnemonic() } else {