mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-13 07:36:21 +00:00
simplify add set providers; validation can be done on the client isde
This commit is contained in:
parent
a5c6c38b5e
commit
be1d9cc502
@ -26,23 +26,13 @@ class Storage {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the code to call setProviders in embarkjs after embark is ready
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
addSetProviders() {
|
addSetProviders() {
|
||||||
const self = this;
|
const self = this;
|
||||||
// filter list of dapp connections based on available_providers set in config
|
|
||||||
let hasSwarm = _.contains(this.storageConfig.available_providers, 'swarm'); // don't need to eval this in every loop iteration
|
|
||||||
// contains valid dapp storage providers
|
|
||||||
this._validDappProviders = _.filter(this.storageConfig.dappConnection, (conn) => {
|
|
||||||
return _.contains(self.storageConfig.available_providers, conn.provider) || (conn === '$BZZ' && hasSwarm);
|
|
||||||
});
|
|
||||||
|
|
||||||
let code = `\nEmbarkJS.Storage.setProviders(${JSON.stringify(this._validDappProviders)});`;
|
let code = `\nEmbarkJS.Storage.setProviders(${JSON.stringify(this.storageConfig.dappConnection)});`;
|
||||||
|
|
||||||
let shouldInit = (storageConfig) => {
|
let shouldInit = (storageConfig) => {
|
||||||
return (this._validDappProviders !== undefined && this._validDappProviders.length > 0 && storageConfig.enabled === true);
|
return storageConfig.enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.embark.addProviderInit('storage', code, shouldInit);
|
this.embark.addProviderInit('storage', code, shouldInit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user