From 8c82ebec791ba2a21259cffba5c1fd35a471d772 Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Mon, 20 Jul 2015 17:33:19 -0700 Subject: [PATCH] Use "core" instead of "utils.core" --- src/api/common/schema-validator.js | 6 +++--- src/api/common/validate.js | 4 ++-- src/api/transaction/order.js | 3 ++- src/api/transaction/ordercancellation.js | 3 ++- src/api/transaction/payment.js | 3 ++- src/api/transaction/settings.js | 3 ++- src/api/transaction/submit.js | 3 ++- src/api/transaction/trustline.js | 3 ++- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/api/common/schema-validator.js b/src/api/common/schema-validator.js index abac53d8..9d58f3f8 100644 --- a/src/api/common/schema-validator.js +++ b/src/api/common/schema-validator.js @@ -3,17 +3,17 @@ const _ = require('lodash'); const fs = require('fs'); const path = require('path'); const validator = require('is-my-json-valid'); -const utils = require('./utils'); +const core = require('./utils').core; const ValidationError = require('./errors').ValidationError; let SCHEMAS = {}; function isValidAddress(address) { - return utils.core.UInt160.is_valid(address); + return core.UInt160.is_valid(address); } function isValidLedgerHash(ledgerHash) { - return utils.core.UInt256.is_valid(ledgerHash); + return core.UInt256.is_valid(ledgerHash); } function loadSchema(filepath) { diff --git a/src/api/common/validate.js b/src/api/common/validate.js index 384c8add..25024353 100644 --- a/src/api/common/validate.js +++ b/src/api/common/validate.js @@ -1,6 +1,6 @@ 'use strict'; const _ = require('lodash'); -const utils = require('./utils'); +const core = require('./utils').core; const ValidationError = require('./errors').ValidationError; const schemaValidate = require('./schema-validator'); @@ -16,7 +16,7 @@ function validateAddressAndSecret(obj) { throw error('Parameter missing: secret'); } try { - if (!utils.core.Seed.from_json(secret).get_key(address)) { + if (!core.Seed.from_json(secret).get_key(address)) { throw error('secret does not match address'); } } catch (exception) { diff --git a/src/api/transaction/order.js b/src/api/transaction/order.js index 58043a62..e6dc36a2 100644 --- a/src/api/transaction/order.js +++ b/src/api/transaction/order.js @@ -2,6 +2,7 @@ 'use strict'; const utils = require('./utils'); const validate = utils.common.validate; +const Transaction = utils.common.core.Transaction; const OfferCreateFlags = { passive: {set: 'Passive'}, @@ -13,7 +14,7 @@ function createOrderTransaction(account, order) { validate.address(account); validate.order(order); - const transaction = new utils.common.core.Transaction(); + const transaction = new Transaction(); const takerPays = utils.common.toRippledAmount(order.direction === 'buy' ? order.quantity : order.totalPrice); const takerGets = utils.common.toRippledAmount(order.direction === 'buy' ? diff --git a/src/api/transaction/ordercancellation.js b/src/api/transaction/ordercancellation.js index 803bcd62..912973c9 100644 --- a/src/api/transaction/ordercancellation.js +++ b/src/api/transaction/ordercancellation.js @@ -2,12 +2,13 @@ 'use strict'; const utils = require('./utils'); const validate = utils.common.validate; +const Transaction = utils.common.core.Transaction; function createOrderCancellationTransaction(account, sequence) { validate.address(account); validate.sequence(sequence); - const transaction = new utils.common.core.Transaction(); + const transaction = new Transaction(); transaction.offerCancel(account, sequence); return transaction; } diff --git a/src/api/transaction/payment.js b/src/api/transaction/payment.js index 6a6d5db1..a76a5427 100644 --- a/src/api/transaction/payment.js +++ b/src/api/transaction/payment.js @@ -5,6 +5,7 @@ const BigNumber = require('bignumber.js'); const utils = require('./utils'); const validate = utils.common.validate; const toRippledAmount = utils.common.toRippledAmount; +const Transaction = utils.common.core.Transaction; function isSendMaxAllowed(payment) { const srcAmt = payment.source.amount; @@ -41,7 +42,7 @@ function createPaymentTransaction(account, payment) { validate.address(account); validate.payment(payment); - const transaction = new utils.common.core.Transaction(); + const transaction = new Transaction(); transaction.payment({ from: payment.source.address, to: payment.destination.address, diff --git a/src/api/transaction/settings.js b/src/api/transaction/settings.js index 8f7250bb..e6df0bcc 100644 --- a/src/api/transaction/settings.js +++ b/src/api/transaction/settings.js @@ -6,6 +6,7 @@ const utils = require('./utils'); const validate = utils.common.validate; const AccountFlagIndices = utils.common.constants.AccountFlagIndices; const AccountFields = utils.common.constants.AccountFields; +const Transaction = utils.common.core.Transaction; // Emptry string passed to setting will clear it const CLEAR_SETTING = ''; @@ -70,7 +71,7 @@ function createSettingsTransaction(account, settings) { validate.address(account); validate.settings(settings); - const transaction = new utils.common.core.Transaction(); + const transaction = new Transaction(); if (settings.regularKey) { return transaction.setRegularKey({ account: account, diff --git a/src/api/transaction/submit.js b/src/api/transaction/submit.js index 94f7563d..a79c3845 100644 --- a/src/api/transaction/submit.js +++ b/src/api/transaction/submit.js @@ -2,11 +2,12 @@ 'use strict'; const utils = require('./utils'); const validate = utils.common.validate; +const Request = utils.common.core.Request; function submit(tx_blob: string, callback: (err: any, data: any) => void): void { validate.blob(tx_blob); - const request = new utils.common.core.Request(this.remote, 'submit'); + const request = new Request(this.remote, 'submit'); request.message.tx_blob = tx_blob; request.request(null, callback); } diff --git a/src/api/transaction/trustline.js b/src/api/transaction/trustline.js index e3d762ac..dadffc79 100644 --- a/src/api/transaction/trustline.js +++ b/src/api/transaction/trustline.js @@ -2,6 +2,7 @@ 'use strict'; const utils = require('./utils'); const validate = utils.common.validate; +const Transaction = utils.common.core.Transaction; const TrustSetFlags = { authorized: {set: 'SetAuth'}, @@ -19,7 +20,7 @@ function createTrustlineTransaction(account, trustline) { value: trustline.limit }; - const transaction = new utils.common.core.Transaction(); + const transaction = new Transaction(); transaction.trustSet(account, limit, trustline.qualityIn, trustline.qualityOut); utils.setTransactionBitFlags(transaction, trustline, TrustSetFlags);