Fixing some logic on Embark.Storage.setProvider

This commit is contained in:
Andy Nogueira 2017-03-12 17:59:21 -04:00
parent 3a50dbdfdd
commit f1b8438cbb
2 changed files with 503 additions and 473 deletions

View File

@ -2,48 +2,74 @@ var EmbarkJS =
/******/ (function(modules) { // webpackBootstrap /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache /******/ // The module cache
/******/ var installedModules = {}; /******/ var installedModules = {};
/******/
/******/ // The require function /******/ // The require function
/******/ function __webpack_require__(moduleId) { /******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache /******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) /******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports; /******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache) /******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = { /******/ var module = installedModules[moduleId] = {
/******/ exports: {}, /******/ i: moduleId,
/******/ id: moduleId, /******/ l: false,
/******/ loaded: false /******/ exports: {}
/******/ }; /******/ };
/******/
/******/ // Execute the module function /******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded /******/ // Flag the module as loaded
/******/ module.loaded = true; /******/ module.l = true;
/******/
/******/ // Return the exports of the module /******/ // Return the exports of the module
/******/ return module.exports; /******/ return module.exports;
/******/ } /******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__) /******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules; /******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache /******/ // expose the module cache
/******/ __webpack_require__.c = installedModules; /******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__ /******/ // __webpack_public_path__
/******/ __webpack_require__.p = ""; /******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports /******/ // Load entry module and return exports
/******/ return __webpack_require__(0); /******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ }) /******/ })
/************************************************************************/ /************************************************************************/
/******/ ([ /******/ ([
/* 0 */ /* 0 */
/***/ function(module, exports) { /***/ (function(module, exports) {
/*jshint esversion: 6 */ /*jshint esversion: 6 */
//var Ipfs = require('./ipfs.js'); //var Ipfs = require('./ipfs.js');
@ -184,13 +210,15 @@ var EmbarkJS =
return promise; return promise;
}; };
EmbarkJS.IPFS = 'ipfs';
EmbarkJS.Storage = { EmbarkJS.Storage = {
IPFS : 'ipfs'
}; };
EmbarkJS.Storage.setProvider = function(provider, options) { EmbarkJS.Storage.setProvider = function(provider, options) {
if (provider === 'ipfs') { if (provider.toLowerCase() === EmbarkJS.Storage.IPFS) {
//I don't think currentStorage is used anywhere, this might not be needed
//for now until additional storage providers are supported. But keeping it
//anyways
this.currentStorage = EmbarkJS.Storage.IPFS; this.currentStorage = EmbarkJS.Storage.IPFS;
if (options === undefined) { if (options === undefined) {
this.ipfsConnection = IpfsApi('localhost', '5001'); this.ipfsConnection = IpfsApi('localhost', '5001');
@ -198,7 +226,7 @@ var EmbarkJS =
this.ipfsConnection = IpfsApi(options.server, options.port); this.ipfsConnection = IpfsApi(options.server, options.port);
} }
} else { } else {
throw Error('unknown provider'); throw Error('Unknown storage provider');
} }
}; };
@ -493,5 +521,5 @@ var EmbarkJS =
module.exports = EmbarkJS; module.exports = EmbarkJS;
/***/ } /***/ })
/******/ ]); /******/ ]);

View File

@ -137,13 +137,15 @@ EmbarkJS.Contract.prototype.deploy = function(args, _options) {
return promise; return promise;
}; };
EmbarkJS.IPFS = 'ipfs';
EmbarkJS.Storage = { EmbarkJS.Storage = {
IPFS : 'ipfs'
}; };
EmbarkJS.Storage.setProvider = function(provider, options) { EmbarkJS.Storage.setProvider = function(provider, options) {
if (provider === 'ipfs') { if (provider.toLowerCase() === EmbarkJS.Storage.IPFS) {
//I don't think currentStorage is used anywhere, this might not be needed
//for now until additional storage providers are supported. But keeping it
//anyways
this.currentStorage = EmbarkJS.Storage.IPFS; this.currentStorage = EmbarkJS.Storage.IPFS;
if (options === undefined) { if (options === undefined) {
this.ipfsConnection = IpfsApi('localhost', '5001'); this.ipfsConnection = IpfsApi('localhost', '5001');
@ -151,7 +153,7 @@ EmbarkJS.Storage.setProvider = function(provider, options) {
this.ipfsConnection = IpfsApi(options.server, options.port); this.ipfsConnection = IpfsApi(options.server, options.port);
} }
} else { } else {
throw Error('unknown provider'); throw Error('Unknown storage provider');
} }
}; };