Skip to content

Commit

Permalink
Delete serialization code
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Clark committed Oct 14, 2015
1 parent eb9a48d commit 7419244
Show file tree
Hide file tree
Showing 26 changed files with 159 additions and 3,833 deletions.
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"lodash": "^3.1.0",
"lru-cache": "~2.5.0",
"ripple-address-codec": "^2.0.1",
"ripple-binary-codec": "^0.0.5",
"ripple-binary-codec": "^0.0.6",
"ripple-keypairs": "^0.9.0",
"ripple-lib-transactionparser": "^0.5.1",
"ripple-lib-value": "0.1.0",
Expand Down
10 changes: 7 additions & 3 deletions src/api/ledger/parse/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ function parseOutcome(tx: Object): ?Object {
};
}

function hexToString(hex) {
return hex ? new Buffer(hex, 'hex').toString('utf-8') : undefined;
}

function parseMemos(tx: Object): ?Array<Object> {
if (!Array.isArray(tx.Memos) || tx.Memos.length === 0) {
return undefined;
}
return tx.Memos.map((m) => {
return removeUndefined({
type: m.Memo.parsed_memo_type,
format: m.Memo.parsed_memo_format,
data: m.Memo.parsed_memo_data
type: m.Memo.parsed_memo_type || hexToString(m.Memo.MemoType),
format: m.Memo.parsed_memo_format || hexToString(m.Memo.MemoFormat),
data: m.Memo.parsed_memo_data || hexToString(m.Memo.MemoData)
});
});
}
Expand Down
57 changes: 0 additions & 57 deletions src/core/base.js

This file was deleted.

45 changes: 0 additions & 45 deletions src/core/baseconverter.js

This file was deleted.

11 changes: 1 addition & 10 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,19 @@ exports.Amount = require('./amount').Amount;
exports.Account = require('./account').Account;
exports.Transaction = require('./transaction').Transaction;
exports.Currency = require('./currency').Currency;
exports.Base = require('./base').Base;
exports.Meta = require('./meta').Meta;
exports.SerializedObject = require('./serializedobject').SerializedObject;
exports.RippleError = require('./rippleerror').RippleError;
exports.binformat = require('./binformat');
exports.utils = require('./utils');
exports.Server = require('./server').Server;
exports.Ledger = require('./ledger').Ledger;
exports.TransactionQueue = require('./transactionqueue').TransactionQueue;
exports.convertBase = require('./baseconverter');

exports._test = {
Log: require('./log'),
PathFind: require('./pathfind').PathFind,
TransactionManager: require('./transactionmanager').TransactionManager,
TransactionQueue: require('./transactionqueue').TransactionQueue,
RangeSet: require('./rangeset').RangeSet,
HashPrefixes: require('./hashprefixes'),
UInt128: require('./uint128').UInt128,
UInt160: require('./uint160').UInt160,
UInt256: require('./uint256').UInt256,
OrderbookUtils: require('./orderbookutils'),
constants: require('./constants')
};

exports.types = require('./serializedtypes');
28 changes: 13 additions & 15 deletions src/core/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ const Account = require('./account').Account;
const Meta = require('./meta').Meta;
const OrderBook = require('./orderbook').OrderBook;
const PathFind = require('./pathfind').PathFind;
const SerializedObject = require('./serializedobject').SerializedObject;
const RippleError = require('./rippleerror').RippleError;
const utils = require('./utils');
const hashprefixes = require('./hashprefixes');
const log = require('./log').internal.sub('remote');
const {isValidAddress} = require('ripple-address-codec');
const binary = require('ripple-binary-codec');

export type GetLedgerSequenceCallback = (err?: ?Error, index?: number) => void;

Expand Down Expand Up @@ -1412,27 +1411,26 @@ Remote.prototype.requestAccountTx = function(options, callback) {
*/

Remote.parseBinaryAccountTransaction = function(transaction) {
const tx_obj = new SerializedObject(transaction.tx_blob);
const tx_obj_json = tx_obj.to_json();
const meta = new SerializedObject(transaction.meta).to_json();
const tx_json = binary.decode(transaction.tx_blob);
const meta = binary.decode(transaction.meta);

const tx_result = {
validated: transaction.validated
};

tx_result.meta = meta;
tx_result.tx = tx_obj_json;
tx_result.tx.hash = tx_obj.hash(hashprefixes.HASH_TX_ID).to_hex();
tx_result.tx = tx_json;
tx_result.tx.hash = Transaction.from_json(tx_json).hash();
tx_result.tx.ledger_index = transaction.ledger_index;
tx_result.tx.inLedger = transaction.ledger_index;

if (typeof meta.DeliveredAmount === 'object') {
tx_result.meta.delivered_amount = meta.DeliveredAmount;
} else {
switch (typeof tx_obj_json.Amount) {
switch (typeof tx_json.Amount) {
case 'string':
case 'object':
tx_result.meta.delivered_amount = tx_obj_json.Amount;
tx_result.meta.delivered_amount = tx_json.Amount;
break;
}
}
Expand All @@ -1441,10 +1439,10 @@ Remote.parseBinaryAccountTransaction = function(transaction) {
};

Remote.parseBinaryTransaction = function(transaction) {
const tx_obj = new SerializedObject(transaction.tx).to_json();
const meta = new SerializedObject(transaction.meta).to_json();
const tx_json = binary.decode(transaction.tx);
const meta = binary.decode(transaction.meta);

const tx_result = tx_obj;
const tx_result = tx_json;

tx_result.date = transaction.date;
tx_result.hash = transaction.hash;
Expand All @@ -1459,10 +1457,10 @@ Remote.parseBinaryTransaction = function(transaction) {
tx_result.meta.delivered_amount = meta.DeliveredAmount;
break;
default:
switch (typeof tx_obj.Amount) {
switch (typeof tx_json.Amount) {
case 'string':
case 'object':
tx_result.meta.delivered_amount = tx_obj.Amount;
tx_result.meta.delivered_amount = tx_json.Amount;
break;
}
}
Expand All @@ -1481,7 +1479,7 @@ Remote.parseBinaryTransaction = function(transaction) {
*/

Remote.parseBinaryLedgerData = function(ledgerData) {
const data = new SerializedObject(ledgerData.data).to_json();
const data = binary.decode(ledgerData.data);
data.index = ledgerData.index;
return data;
};
Expand Down

0 comments on commit 7419244

Please sign in to comment.