Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix migrate settings and network. #2935

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/neuron-wallet/src/services/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum NetworksKey {
}

const oldDefaultNames = ['Default', 'default node', presetNetworks.networks[0].name]
const oldDefaultRemotes = ['http://localhost:8114', BUNDLED_CKB_URL]
Keith-CY marked this conversation as resolved.
Show resolved Hide resolved

export default class NetworksService extends Store {
private static instance: NetworksService
Expand Down Expand Up @@ -263,7 +264,7 @@ export default class NetworksService extends Store {
if (
// make sure that user has not change the network name
oldDefaultNames.includes(oldMainnetNetwork.name) &&
oldMainnetNetwork.remote === defaultMainnetNetwork.remote &&
oldDefaultRemotes.includes(oldMainnetNetwork.remote) &&
oldMainnetNetwork.type === defaultMainnetNetwork.type
) {
this.updateAll([
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class SettingsService extends Store {
ckbDataPath: path.resolve(app.getPath('userData'), 'chains/mainnet'),
})
)
if (!this.getNodeDataPath(LIGHT_CLIENT_MAINNET)) {
if (!this.getNodeDataPath(LIGHT_CLIENT_MAINNET) || !this.getNodeDataPath('ckb')) {
this.migrateDataPath()
}
}
Expand All @@ -93,8 +93,8 @@ export default class SettingsService extends Store {
migrateDataPath() {
const networkChain = NetworksService.getInstance().getCurrent()?.chain
const currentCkbDataPath = this.readSync(settingKeys.ckbDataPath)
this.writeSync(`${settingKeys.nodeDataPath}_${networkChain}`, currentCkbDataPath)
const defaultMainNetworkDir = path.resolve(app.getPath('userData'), 'chains/mainnet')
this.writeSync(`${settingKeys.nodeDataPath}_${networkChain}`, currentCkbDataPath || defaultMainNetworkDir)
if (networkChain !== 'ckb') {
// if user has changed the ckb data path and running with testnet
this.writeSync(`${settingKeys.nodeDataPath}_ckb`, defaultMainNetworkDir)
Expand Down