Rework config.js to not be add to web pack.

This commit is contained in:
Arthur Britto
2012-11-07 16:03:39 -08:00
parent c04b94f781
commit b271192547
8 changed files with 24 additions and 12 deletions

View File

@@ -6,9 +6,6 @@ var bn = require('./sjcl/core.js').bn;
var utils = require('./utils.js');
var jsbn = require('./jsbn.js');
// Don't include in browser context.
var config = require('../../test/config.js');
var BigInteger = jsbn.BigInteger;
var nbi = jsbn.nbi;
@@ -158,8 +155,8 @@ UInt160.prototype.equals = function(d) {
// value = NaN on error.
UInt160.prototype.parse_json = function (j) {
// Canonicalize and validate
if (config.accounts && j in config.accounts)
j = config.accounts[j].account;
if (exports.config.accounts && j in exports.config.accounts)
j = exports.config.accounts[j].account;
switch (j) {
case undefined:
@@ -603,6 +600,8 @@ exports.Amount = Amount;
exports.Currency = Currency;
exports.UInt160 = UInt160;
exports.config = {};
exports.consts = {
'address_xns' : "rrrrrrrrrrrrrrrrrrrrrhoLvTp",
'address_one' : "rrrrrrrrrrrrrrrrrrrrBZbvji",

View File

@@ -21,9 +21,6 @@ var EventEmitter = require('events').EventEmitter;
var Amount = require('./amount.js').Amount;
var UInt160 = require('./amount.js').UInt160;
// Don't include in browser context.
var config = require('../../test/config.js');
// Request events emmitted:
// 'success' : Request successful.
// 'error' : Request failed.
@@ -159,7 +156,6 @@ var Remote = function (trusted, websocket_ip, websocket_port, trace) {
this.state = 'offline'; // 'online', 'offline'
this.retry_timer = undefined;
this.retry = undefined;
this.config = config || { 'accounts' : {}};
// Cache information for accounts.
this.accounts = {
@@ -182,7 +178,7 @@ var Remote = function (trusted, websocket_ip, websocket_port, trace) {
Remote.prototype = new EventEmitter;
Remote.from_config = function (name, trace) {
var serverConfig = config.servers[name];
var serverConfig = exports.config.servers[name];
return new Remote(serverConfig.trusted, serverConfig.websocket_ip, serverConfig.websocket_port, trace);
};
@@ -1141,7 +1137,7 @@ Transaction.prototype.set_flags = function (flags) {
Transaction.prototype._account_secret = function (account) {
// Fill in secret from config, if needed.
return this.remote.config.accounts[account] ? this.remote.config.accounts[account].secret : undefined;
return exports.config.accounts && exports.config.accounts[account] ? exports.config.accounts[account].secret : undefined;
};
// Options:
@@ -1268,6 +1264,7 @@ Transaction.prototype.wallet_add = function (src, amount, authorized_key, public
return this;
};
exports.config = {};
exports.Remote = Remote;
// vim:sw=2:sts=2:ts=8

View File

@@ -8,6 +8,8 @@ var amount = require("../src/js/amount.js");
var Amount = require("../src/js/amount.js").Amount;
var UInt160 = require("../src/js/amount.js").UInt160;
require("../src/js/amount.js").config = require("./config.js");
var config = require('./config.js');
buster.testCase("Amount", {

View File

@@ -8,6 +8,9 @@ var Server = require("./server.js").Server;
var testutils = require("./testutils.js");
require("../src/js/amount.js").config = require("./config.js");
require("../src/js/remote.js").config = require("./config.js");
buster.testRunner.timeout = 5000;
buster.testCase("Offer tests", {

View File

@@ -6,6 +6,9 @@ var Server = require("./server.js").Server;
var testutils = require("./testutils.js");
require("../src/js/amount.js").config = require("./config.js");
require("../src/js/remote.js").config = require("./config.js");
var fastTearDown = true;
// How long to wait for server to start.

View File

@@ -7,6 +7,9 @@ var Server = require("./server.js").Server;
var testutils = require("./testutils.js");
require("../src/js/amount.js").config = require("./config.js");
require("../src/js/remote.js").config = require("./config.js");
// How long to wait for server to start.
var serverDelay = 1500;

View File

@@ -5,6 +5,9 @@ var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote;
var Server = require("./server.js").Server;
require("../src/js/amount.js").config = require("./config.js");
require("../src/js/remote.js").config = require("./config.js");
var config = require("./config.js");
/**

View File

@@ -3,6 +3,8 @@ var buster = require("buster");
var Server = require("./server.js").Server;
var Remote = require("../src/js/remote.js").Remote;
require("../src/js/remote.js").config = require("./config.js");
// How long to wait for server to start.
var serverDelay = 1500;