Skip to content

Commit

Permalink
dont allow duplicating endorsed networks by host
Browse files Browse the repository at this point in the history
  • Loading branch information
nsjames committed Jun 20, 2018
1 parent ff9155a commit e716ae3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/plugins/PluginRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class PluginRepositorySingleton {
plugin(name){
return this.plugins.find(plugin => plugin.name === name);
}

async endorsedNetworks(){
return await Promise.all(this.signatureProviders().map(async plugin => await plugin.getEndorsedNetwork()));
}
}

const PluginRepository = new PluginRepositorySingleton();
Expand Down
9 changes: 8 additions & 1 deletion src/views/NetworkView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import AlertMsg from '../models/alerts/AlertMsg'
import IdentityService from '../services/IdentityService'
import {BlockchainsArray} from '../models/Blockchains';
import PluginRepository from '../plugins/PluginRepository'
export default {
data(){ return {
Expand Down Expand Up @@ -60,9 +61,15 @@
if(newHost.indexOf('/') > -1) newHost = newHost.split('/')[0];
this.network.host = newHost;
},
saveNetwork(){
async saveNetwork(){
const scatter = this.scatter.clone();
const endorsedNetworks = await PluginRepository.endorsedNetworks();
if(endorsedNetworks.map(network => network.host).includes(this.network.host)){
this[Actions.PUSH_ALERT](AlertMsg.NetworkExists());
return false;
}
if(!this.network.port)
this.network.port = this.network.protocol === 'http' ? 80 : 443;
Expand Down

0 comments on commit e716ae3

Please sign in to comment.