diff --git a/src/js/ripple/config.js b/src/js/ripple/config.js deleted file mode 100644 index f6d17a16..00000000 --- a/src/js/ripple/config.js +++ /dev/null @@ -1,10 +0,0 @@ -// This object serves as a singleton to store config options - -var extend = require('extend'); - -var config = module.exports = { - load: function (newOpts) { - extend(config, newOpts); - return config; - } -}; diff --git a/src/js/ripple/index.js b/src/js/ripple/index.js index 1ce5583f..fa37e0fb 100644 --- a/src/js/ripple/index.js +++ b/src/js/ripple/index.js @@ -33,25 +33,23 @@ exports.convertBase = require('./baseconverter'); exports.sjcl = require('./utils').sjcl; exports.types = require('./serializedtypes'); -exports.config = require('./config'); - // camelCase to under_scored API conversion function attachUnderscored(name) { - var o = exports[name]; + var o = exports[name]; - Object.keys(o.prototype).forEach(function(key) { - var UPPERCASE = /([A-Z]{1})[a-z]+/g; + Object.keys(o.prototype).forEach(function(key) { + var UPPERCASE = /([A-Z]{1})[a-z]+/g; - if (!UPPERCASE.test(key)) { - return; - } + if (!UPPERCASE.test(key)) { + return; + } - var underscored = key.replace(UPPERCASE, function(c) { - return '_' + c.toLowerCase(); - }); + var underscored = key.replace(UPPERCASE, function(c) { + return '_' + c.toLowerCase(); + }); - o.prototype[underscored] = o.prototype[key]; - }); + o.prototype[underscored] = o.prototype[key]; + }); } ['Remote', diff --git a/src/js/ripple/remote.js b/src/js/ripple/remote.js index 0ae47da4..b52b6898 100644 --- a/src/js/ripple/remote.js +++ b/src/js/ripple/remote.js @@ -34,7 +34,6 @@ var SerializedObject = require('./serializedobject').SerializedObject; var RippleError = require('./rippleerror').RippleError; var utils = require('./utils'); var hashprefixes = require('./hashprefixes'); -var config = require('./config'); var log = require('./log').internal.sub('remote'); /** @@ -238,29 +237,6 @@ Remote.flags = { } }; -Remote.from_config = function(obj, trace) { - var serverConfig = (typeof obj === 'string') ? config.servers[obj] : obj; - var remote = new Remote(serverConfig, trace); - - function initializeAccount(account) { - var accountInfo = config.accounts[account]; - if (typeof accountInfo === 'object') { - if (accountInfo.secret) { - // Index by nickname - remote.setSecret(account, accountInfo.secret); - // Index by account ID - remote.setSecret(accountInfo.account, accountInfo.secret); - } - } - } - - if (config.accounts) { - Object.keys(config.accounts).forEach(initializeAccount); - } - - return remote; -}; - /** * Check that server message is valid * diff --git a/src/js/ripple/transaction.js b/src/js/ripple/transaction.js index 0ea04d4b..e6891a66 100644 --- a/src/js/ripple/transaction.js +++ b/src/js/ripple/transaction.js @@ -11,7 +11,6 @@ var Seed = require('./seed').Seed; var SerializedObject = require('./serializedobject').SerializedObject; var RippleError = require('./rippleerror').RippleError; var hashprefixes = require('./hashprefixes'); -var config = require('./config'); var log = require('./log').internal.sub('transaction'); /** @@ -433,8 +432,8 @@ Transaction.prototype.serialize = function() { return SerializedObject.from_json(this.tx_json); }; -Transaction.prototype.signingHash = function() { - return this.hash(config.testnet ? 'HASH_TX_SIGN_TESTNET' : 'HASH_TX_SIGN'); +Transaction.prototype.signingHash = function(testnet) { + return this.hash(testnet ? 'HASH_TX_SIGN_TESTNET' : 'HASH_TX_SIGN'); }; Transaction.prototype.hash = function(prefix, asUINT256, serialized) { @@ -452,13 +451,13 @@ Transaction.prototype.hash = function(prefix, asUINT256, serialized) { return asUINT256 ? hash : hash.to_hex(); }; -Transaction.prototype.sign = function() { +Transaction.prototype.sign = function(testnet) { var seed = Seed.from_json(this._secret); var prev_sig = this.tx_json.TxnSignature; delete this.tx_json.TxnSignature; - var hash = this.signingHash(); + var hash = this.signingHash(testnet); // If the hash is the same, we can re-use the previous signature if (prev_sig && hash === this.previousSigningHash) { diff --git a/src/js/ripple/uint.js b/src/js/ripple/uint.js index 83934fba..8dafd6d2 100644 --- a/src/js/ripple/uint.js +++ b/src/js/ripple/uint.js @@ -4,7 +4,6 @@ var utils = require('./utils'); var sjcl = utils.sjcl; -var config = require('./config'); // // Abstract UInt class @@ -131,12 +130,6 @@ UInt.prototype._update = function() { // value = NaN on error. UInt.prototype.parse_generic = function(j) { - // Canonicalize and validate - if (config.accounts && (j in config.accounts)) { - j = config.accounts[j].account; - } - - switch (j) { case undefined: case '0': diff --git a/src/js/ripple/uint160.js b/src/js/ripple/uint160.js index ddd97495..70cd4e97 100644 --- a/src/js/ripple/uint160.js +++ b/src/js/ripple/uint160.js @@ -1,7 +1,6 @@ 'use strict'; var utils = require('./utils'); -var config = require('./config'); var extend = require('extend'); var UInt = require('./uint').UInt; @@ -40,11 +39,6 @@ UInt160.prototype.get_version = function() { // 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 (typeof j === 'number' && !isNaN(j)) { // Allow raw numbers - DEPRECATED // This is used mostly by the test suite and is supported diff --git a/test/amount-test.js b/test/amount-test.js index 221b752a..790db8cf 100644 --- a/test/amount-test.js +++ b/test/amount-test.js @@ -3,11 +3,6 @@ var assert = require('assert'); var Amount = require('ripple-lib').Amount; var UInt160 = require('ripple-lib').UInt160; -var load_config = require('ripple-lib').config.load; -var config = require('./config-example'); - -load_config(config); - describe('Amount', function() { describe('Negatives', function() { @@ -309,9 +304,6 @@ describe('Amount', function() { it('Parse rrrrrrrrrrrrrrrrrrrrBZbvji export', function () { assert.strictEqual(UInt160.ACCOUNT_ONE, UInt160.from_json('rrrrrrrrrrrrrrrrrrrrBZbvji').to_json()); }); - it('Parse mtgox export', function () { - assert.strictEqual(config.accounts.mtgox.account, UInt160.from_json('mtgox').to_json()); - }); it('is_valid rrrrrrrrrrrrrrrrrrrrrhoLvTp', function () { assert(UInt160.is_valid('rrrrrrrrrrrrrrrrrrrrrhoLvTp')); }); @@ -360,12 +352,6 @@ describe('Amount', function() { it('parse dem human', function() { assert.strictEqual(Amount.from_json('10/XAU (-0.5%pa)/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh').to_human_full(), '10/XAU (-0.5%pa)/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'); }); - it('Parse 800/USD/mtgox', function () { - assert.strictEqual('800/USD/' + config.accounts.mtgox.account, Amount.from_json('800/USD/mtgox').to_text_full()); - }); - it('Parse 800/USD/mtgox human', function () { - assert.strictEqual('800/USD/' + config.accounts.mtgox.account, Amount.from_json('800/USD/mtgox').to_human_full()); - }); it('Parse native 0', function () { assert.strictEqual('0/XRP', Amount.from_json('0').to_text_full()); });