So much wallets

pull/11/head
bomb-on 6 years ago
parent be39e55fcf
commit b5b6344968

@ -31,7 +31,7 @@ export class Config {
{"address": "node.wownero.com:34568", "location": "Montreal, Canada", "region": "US"}, {"address": "node.wownero.com:34568", "location": "Montreal, Canada", "region": "US"},
{"address": "localhost:34568", 'location': "", "region": "*"} {"address": "localhost:34568", 'location': "", "region": "*"}
], ],
"wallet_path": "" "wallets": []
}); });
fs.writeFileSync(this._path_cfg, JSON.stringify(data)); fs.writeFileSync(this._path_cfg, JSON.stringify(data));
@ -69,7 +69,8 @@ export class Config {
return; return;
} }
this.data.wallet_path = path; const name = path.split('/').pop();
this.data.wallets.push({ name, path });
this.save(); this.save();
} }
} }

@ -22,7 +22,7 @@
</button> </button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a v-on:click="openWallet" class="dropdown-item" href="#">Browse</a> <a v-on:click="openWallet" class="dropdown-item" href="#">Browse</a>
<a v-on:click="openLastWallet" v-if="cfg_wallet_path !== ''" class="dropdown-item" href="#">{{cfg_wallet_path_name}}</a> <a v-on:click="openLastWallet" v-for="item in cfg_wallet_names" class="dropdown-item" href="#">{{item}}</a>
</div> </div>
</div> </div>
@ -118,13 +118,9 @@
} }
}); });
}, },
openLastWallet(){ openLastWallet(event){
if(!this.cfg_wallet_path || this.cfg_wallet_path === ''){ const selectedWallet = this.cfg_wallets.find(i => i.name === event.currentTarget.text);
alert('Invalid wallet path?!'); this.$store.commit('addWalletPath', selectedWallet.path);
return;
}
this.$store.commit('addWalletPath', this.cfg_wallet_path);
this.$store.commit('showPassword', { this.$store.commit('showPassword', {
'message': 'Enter wallet password' 'message': 'Enter wallet password'
}); });
@ -192,12 +188,11 @@
selected_node(){ selected_node(){
return this.$store.getters.cfg.node; return this.$store.getters.cfg.node;
}, },
cfg_wallet_path(){ cfg_wallets(){
return this.$store.getters.cfg.wallet_path; return this.$store.getters.cfg.wallets;
}, },
cfg_wallet_path_name(){ cfg_wallet_names(){
let path = require("path"); return this.$store.getters.cfg.wallets.map(i => i.name);
return path.basename(this.cfg_wallet_path);
} }
} }
} }

@ -67,12 +67,20 @@
this.create_wallet(wallet_name, wallet_pass); this.create_wallet(wallet_name, wallet_pass);
} }
}, },
wallet_exists (name) {
return !!this.wallets.find(i => i.name === name);
},
create_wallet (name, password) { create_wallet (name, password) {
this.clearMatrixMsg(); if (this.wallet_exists(name)) {
this.showMatrixMsg('GENERATING NEW WALLET') console.log('Wallet exists!')
// @TODO check if wallet with same name exists no matter the path
} else {
this.clearMatrixMsg();
this.showMatrixMsg('GENERATING NEW WALLET');
this.$store.commit('appState', "create_wallet"); this.$store.commit('appState', "create_wallet");
ipcRenderer.send('rpc_create_wallet', {name: name, password: password}) ipcRenderer.send('rpc_create_wallet', {name: name, password: password})
}
}, },
showMatrixMsg(msg){ showMatrixMsg(msg){
let obj = jQuery('.teh_matrix span.centered'); let obj = jQuery('.teh_matrix span.centered');
@ -179,6 +187,9 @@
}, },
walletCreating(){ walletCreating(){
return this.$store.state.wallet_creating; return this.$store.state.wallet_creating;
},
wallets() {
return this.$store.getters.cfg.wallets;
} }
} }
} }

@ -11,7 +11,7 @@ export default new Vuex.Store({
cfg: { cfg: {
"node": "", "node": "",
"nodes": [], "nodes": [],
"wallet_path": "" "wallets": []
}, },
created_wallet: {}, // only used when creating wallets created_wallet: {}, // only used when creating wallets
appState: "", // not really used appState: "", // not really used
@ -69,6 +69,10 @@ export default new Vuex.Store({
if(data.hasOwnProperty('wallet_path')){ if(data.hasOwnProperty('wallet_path')){
cfg.wallet_path = data.wallet_path; cfg.wallet_path = data.wallet_path;
} }
if(data.hasOwnProperty('wallets')){
cfg.wallets = data.wallets;
}
}, },
appState(state, data){ appState(state, data){
state.appState = data; state.appState = data;