From 5e940c6e8f582a19ab073c6c9bff9bf3209ec6a0 Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Mon, 9 May 2016 18:46:51 +0700 Subject: [PATCH] Update enum definitions and dependencies * Remove redundant `bytes` from field definitions * Remove "date-generated" given hand editing * Remove ripple-lib test dependency * Fix linting errors introduced by updated eslint/eslintrc * Ensure STObject.toJSON returns a plain object --- .babelrc | 4 + package.json | 27 ++--- src/binary.js | 2 - src/coretypes.js | 2 - src/enums/definitions.json | 162 ++++----------------------- src/enums/index.js | 4 +- src/hash-prefixes.js | 2 - src/hashes.js | 2 - src/index.js | 2 - src/ledger-hashes.js | 2 - src/quality.js | 3 +- src/serdes/binary-parser.js | 2 - src/serdes/binary-serializer.js | 2 - src/shamap.js | 2 - src/signing.js | 1 - src/types/account-id.js | 2 - src/types/amount.js | 8 +- src/types/blob.js | 2 - src/types/currency.js | 2 - src/types/hash-128.js | 2 - src/types/hash-160.js | 2 - src/types/hash-256.js | 2 - src/types/hash.js | 2 - src/types/index.js | 2 - src/types/serialized-type.js | 2 - src/types/st-array.js | 2 - src/types/st-object.js | 8 +- src/types/uint-16.js | 2 - src/types/uint-32.js | 2 - src/types/uint-64.js | 2 - src/types/uint-8.js | 2 - src/types/uint.js | 2 - src/types/vector-256.js | 2 - src/utils/bytes-utils.js | 2 - src/utils/make-class.js | 2 - test/amount-test.js | 2 - test/binary-json-test.js | 2 - test/binary-parser-test.js | 37 ++---- test/binary-serializer-test.js | 6 +- test/bytes-utils-test.js | 2 - test/fixtures/data-driven-tests.json | 2 +- test/hash-test.js | 2 - test/ledger-test.js | 2 - test/mocha.opts | 2 +- test/quality-test.js | 2 - test/shamap-test.js | 2 - test/signing-data-encoding-test.js | 2 - test/types-test.js | 2 - test/uint-test.js | 2 - test/utils.js | 2 - 50 files changed, 62 insertions(+), 278 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..d521395 --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets" : ["es2015"], + "retainLines": true +} diff --git a/package.json b/package.json index 1d1b53b..7dd28f3 100644 --- a/package.json +++ b/package.json @@ -12,27 +12,28 @@ "test": "test" }, "dependencies": { - "babel-runtime": "^5.8.25", - "bn.js": "^3.2.0", + "babel-runtime": "^6.6.1", + "bn.js": "^4.11.3", "create-hash": "^1.1.2", - "decimal.js": "^4.0.2", + "decimal.js": "^5.0.8", "inherits": "^2.0.1", - "lodash": "^3.10.1", + "lodash": "^4.12.0", "ripple-address-codec": "^2.0.1" }, "devDependencies": { "assert-diff": "^1.0.1", - "babel": "^5.8.20", - "babel-core": "^5.8.20", - "babel-eslint": "^4.0.5", - "babel-loader": "^5.3.2", + "babel-cli": "^6.8.0", + "babel-core": "^6.8.0", + "babel-eslint": "^6.0.4", + "babel-loader": "^6.2.4", + "babel-preset-es2015": "^6.6.0", + "babel-register": "^6.8.0", "codecov.io": "^0.1.6", - "eslint": "^1.10.3", - "fs-extra": "^0.24.0", + "eslint": "^2.9.0", + "fs-extra": "^0.30.0", "intercept-stdout": "^0.1.2", - "istanbul": "~0.3.5", - "mocha": "~2.1.0", - "ripple-lib": "^0.12.9" + "istanbul": "~0.4.3", + "mocha": "~2.4.5" }, "scripts": { "compile": "babel --optional runtime -d distrib/npm/ src/ && cp src/enums/definitions.json distrib/npm/enums", diff --git a/src/binary.js b/src/binary.js index 14a7766..973ad8c 100644 --- a/src/binary.js +++ b/src/binary.js @@ -1,7 +1,5 @@ /* eslint-disable func-style */ -'use strict'; - const types = require('./types'); const {HashPrefix} = require('./hash-prefixes'); const {BinaryParser} = require('./serdes/binary-parser'); diff --git a/src/coretypes.js b/src/coretypes.js index 01fa9f9..0e9f88e 100644 --- a/src/coretypes.js +++ b/src/coretypes.js @@ -1,5 +1,3 @@ -'use strict'; - const _ = require('lodash'); const enums = require('./enums'); const {Field} = enums; diff --git a/src/enums/definitions.json b/src/enums/definitions.json index 938355f..0d0ca42 100644 --- a/src/enums/definitions.json +++ b/src/enums/definitions.json @@ -24,12 +24,13 @@ "LEDGER_ENTRY_TYPES": { "Ticket": 84, "LedgerHashes": 104, - "EnabledAmendments": 102, + "Amendments": 102, "SignerList": 83, "Offer": 111, "AccountRoot": 97, "RippleState": 114, "FeeSettings": 115, + "SuspendedPayment": 117, "DirectoryNode": 100, "GeneratorMap": 103, "Contract": 99, @@ -41,7 +42,6 @@ { "nth": 0, "isVLEncoded": false, - "bytes": "E0", "isSerialized": false, "isSigningField": false, "type": "Unknown" @@ -52,7 +52,6 @@ { "nth": -1, "isVLEncoded": false, - "bytes": "FF", "isSerialized": false, "isSigningField": false, "type": "Unknown" @@ -63,7 +62,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "11", "isSerialized": true, "isSigningField": true, "type": "UInt16" @@ -74,7 +72,6 @@ { "nth": 2, "isVLEncoded": false, - "bytes": "12", "isSerialized": true, "isSigningField": true, "type": "UInt16" @@ -85,7 +82,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "13", "isSerialized": true, "isSigningField": true, "type": "UInt16" @@ -96,7 +92,6 @@ { "nth": 2, "isVLEncoded": false, - "bytes": "22", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -107,7 +102,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "23", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -118,7 +112,6 @@ { "nth": 4, "isVLEncoded": false, - "bytes": "24", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -129,7 +122,6 @@ { "nth": 5, "isVLEncoded": false, - "bytes": "25", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -140,7 +132,6 @@ { "nth": 6, "isVLEncoded": false, - "bytes": "26", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -151,7 +142,6 @@ { "nth": 7, "isVLEncoded": false, - "bytes": "27", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -162,7 +152,6 @@ { "nth": 8, "isVLEncoded": false, - "bytes": "28", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -173,7 +162,6 @@ { "nth": 9, "isVLEncoded": false, - "bytes": "29", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -184,7 +172,6 @@ { "nth": 10, "isVLEncoded": false, - "bytes": "2A", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -195,7 +182,6 @@ { "nth": 11, "isVLEncoded": false, - "bytes": "2B", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -206,7 +192,6 @@ { "nth": 12, "isVLEncoded": false, - "bytes": "2C", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -217,7 +202,6 @@ { "nth": 13, "isVLEncoded": false, - "bytes": "2D", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -228,7 +212,6 @@ { "nth": 14, "isVLEncoded": false, - "bytes": "2E", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -239,7 +222,6 @@ { "nth": 16, "isVLEncoded": false, - "bytes": "2010", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -250,7 +232,6 @@ { "nth": 17, "isVLEncoded": false, - "bytes": "2011", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -261,7 +242,6 @@ { "nth": 18, "isVLEncoded": false, - "bytes": "2012", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -272,7 +252,6 @@ { "nth": 19, "isVLEncoded": false, - "bytes": "2013", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -283,7 +262,6 @@ { "nth": 20, "isVLEncoded": false, - "bytes": "2014", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -294,7 +272,6 @@ { "nth": 21, "isVLEncoded": false, - "bytes": "2015", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -305,7 +282,6 @@ { "nth": 22, "isVLEncoded": false, - "bytes": "2016", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -316,7 +292,6 @@ { "nth": 23, "isVLEncoded": false, - "bytes": "2017", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -327,7 +302,6 @@ { "nth": 24, "isVLEncoded": false, - "bytes": "2018", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -338,7 +312,6 @@ { "nth": 25, "isVLEncoded": false, - "bytes": "2019", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -349,7 +322,6 @@ { "nth": 26, "isVLEncoded": false, - "bytes": "201A", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -360,7 +332,6 @@ { "nth": 27, "isVLEncoded": false, - "bytes": "201B", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -371,7 +342,6 @@ { "nth": 28, "isVLEncoded": false, - "bytes": "201C", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -382,7 +352,6 @@ { "nth": 29, "isVLEncoded": false, - "bytes": "201D", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -393,7 +362,6 @@ { "nth": 30, "isVLEncoded": false, - "bytes": "201E", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -404,7 +372,6 @@ { "nth": 31, "isVLEncoded": false, - "bytes": "201F", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -415,7 +382,6 @@ { "nth": 32, "isVLEncoded": false, - "bytes": "2020", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -426,7 +392,6 @@ { "nth": 33, "isVLEncoded": false, - "bytes": "2021", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -437,7 +402,6 @@ { "nth": 34, "isVLEncoded": false, - "bytes": "2022", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -448,7 +412,6 @@ { "nth": 35, "isVLEncoded": false, - "bytes": "2023", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -459,7 +422,6 @@ { "nth": 36, "isVLEncoded": false, - "bytes": "2024", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -470,7 +432,6 @@ { "nth": 37, "isVLEncoded": false, - "bytes": "2025", "isSerialized": true, "isSigningField": true, "type": "UInt32" @@ -481,7 +442,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "31", "isSerialized": true, "isSigningField": true, "type": "UInt64" @@ -492,7 +452,6 @@ { "nth": 2, "isVLEncoded": false, - "bytes": "32", "isSerialized": true, "isSigningField": true, "type": "UInt64" @@ -503,7 +462,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "33", "isSerialized": true, "isSigningField": true, "type": "UInt64" @@ -514,7 +472,6 @@ { "nth": 4, "isVLEncoded": false, - "bytes": "34", "isSerialized": true, "isSigningField": true, "type": "UInt64" @@ -525,7 +482,6 @@ { "nth": 5, "isVLEncoded": false, - "bytes": "35", "isSerialized": true, "isSigningField": true, "type": "UInt64" @@ -536,7 +492,6 @@ { "nth": 6, "isVLEncoded": false, - "bytes": "36", "isSerialized": true, "isSigningField": true, "type": "UInt64" @@ -547,7 +502,6 @@ { "nth": 7, "isVLEncoded": false, - "bytes": "37", "isSerialized": true, "isSigningField": true, "type": "UInt64" @@ -558,7 +512,6 @@ { "nth": 8, "isVLEncoded": false, - "bytes": "38", "isSerialized": true, "isSigningField": true, "type": "UInt64" @@ -569,7 +522,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "41", "isSerialized": true, "isSigningField": true, "type": "Hash128" @@ -580,7 +532,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "51", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -591,7 +542,6 @@ { "nth": 2, "isVLEncoded": false, - "bytes": "52", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -602,7 +552,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "53", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -613,7 +562,6 @@ { "nth": 4, "isVLEncoded": false, - "bytes": "54", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -624,7 +572,6 @@ { "nth": 5, "isVLEncoded": false, - "bytes": "55", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -635,7 +582,6 @@ { "nth": 6, "isVLEncoded": false, - "bytes": "56", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -646,7 +592,6 @@ { "nth": 7, "isVLEncoded": false, - "bytes": "57", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -657,7 +602,6 @@ { "nth": 8, "isVLEncoded": false, - "bytes": "58", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -668,7 +612,6 @@ { "nth": 9, "isVLEncoded": false, - "bytes": "59", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -679,7 +622,6 @@ { "nth": 16, "isVLEncoded": false, - "bytes": "5010", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -690,7 +632,6 @@ { "nth": 17, "isVLEncoded": false, - "bytes": "5011", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -701,7 +642,6 @@ { "nth": 18, "isVLEncoded": false, - "bytes": "5012", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -712,7 +652,6 @@ { "nth": 19, "isVLEncoded": false, - "bytes": "5013", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -723,7 +662,6 @@ { "nth": 20, "isVLEncoded": false, - "bytes": "5014", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -734,7 +672,6 @@ { "nth": 21, "isVLEncoded": false, - "bytes": "5015", "isSerialized": true, "isSigningField": true, "type": "Hash256" @@ -745,7 +682,6 @@ { "nth": 257, "isVLEncoded": false, - "bytes": "5001", "isSerialized": false, "isSigningField": false, "type": "Hash256" @@ -756,7 +692,6 @@ { "nth": 258, "isVLEncoded": false, - "bytes": "5002", "isSerialized": false, "isSigningField": false, "type": "Hash256" @@ -767,7 +702,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "61", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -778,7 +712,6 @@ { "nth": 2, "isVLEncoded": false, - "bytes": "62", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -789,7 +722,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "63", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -800,7 +732,6 @@ { "nth": 4, "isVLEncoded": false, - "bytes": "64", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -811,7 +742,6 @@ { "nth": 5, "isVLEncoded": false, - "bytes": "65", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -822,7 +752,6 @@ { "nth": 6, "isVLEncoded": false, - "bytes": "66", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -833,7 +762,6 @@ { "nth": 7, "isVLEncoded": false, - "bytes": "67", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -844,7 +772,6 @@ { "nth": 8, "isVLEncoded": false, - "bytes": "68", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -855,7 +782,6 @@ { "nth": 9, "isVLEncoded": false, - "bytes": "69", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -866,7 +792,6 @@ { "nth": 10, "isVLEncoded": false, - "bytes": "6A", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -877,7 +802,6 @@ { "nth": 16, "isVLEncoded": false, - "bytes": "6010", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -888,7 +812,6 @@ { "nth": 17, "isVLEncoded": false, - "bytes": "6011", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -899,7 +822,6 @@ { "nth": 18, "isVLEncoded": false, - "bytes": "6012", "isSerialized": true, "isSigningField": true, "type": "Amount" @@ -910,7 +832,6 @@ { "nth": 258, "isVLEncoded": false, - "bytes": "6002", "isSerialized": false, "isSigningField": false, "type": "Amount" @@ -921,7 +842,6 @@ { "nth": 259, "isVLEncoded": false, - "bytes": "6003", "isSerialized": false, "isSigningField": false, "type": "Amount" @@ -932,7 +852,6 @@ { "nth": 1, "isVLEncoded": true, - "bytes": "71", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -943,7 +862,6 @@ { "nth": 2, "isVLEncoded": true, - "bytes": "72", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -954,7 +872,6 @@ { "nth": 3, "isVLEncoded": true, - "bytes": "73", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -965,7 +882,6 @@ { "nth": 4, "isVLEncoded": true, - "bytes": "74", "isSerialized": true, "isSigningField": false, "type": "Blob" @@ -976,7 +892,6 @@ { "nth": 5, "isVLEncoded": true, - "bytes": "75", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -987,7 +902,6 @@ { "nth": 6, "isVLEncoded": true, - "bytes": "76", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -998,7 +912,6 @@ { "nth": 7, "isVLEncoded": true, - "bytes": "77", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1009,7 +922,6 @@ { "nth": 8, "isVLEncoded": true, - "bytes": "78", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1020,7 +932,6 @@ { "nth": 9, "isVLEncoded": true, - "bytes": "79", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1031,7 +942,6 @@ { "nth": 10, "isVLEncoded": true, - "bytes": "7A", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1042,7 +952,6 @@ { "nth": 11, "isVLEncoded": true, - "bytes": "7B", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1053,7 +962,6 @@ { "nth": 12, "isVLEncoded": true, - "bytes": "7C", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1064,7 +972,6 @@ { "nth": 13, "isVLEncoded": true, - "bytes": "7D", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1075,7 +982,6 @@ { "nth": 14, "isVLEncoded": true, - "bytes": "7E", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1086,7 +992,6 @@ { "nth": 17, "isVLEncoded": true, - "bytes": "7011", "isSerialized": true, "isSigningField": true, "type": "Blob" @@ -1097,7 +1002,6 @@ { "nth": 1, "isVLEncoded": true, - "bytes": "81", "isSerialized": true, "isSigningField": true, "type": "AccountID" @@ -1108,7 +1012,6 @@ { "nth": 2, "isVLEncoded": true, - "bytes": "82", "isSerialized": true, "isSigningField": true, "type": "AccountID" @@ -1119,7 +1022,6 @@ { "nth": 3, "isVLEncoded": true, - "bytes": "83", "isSerialized": true, "isSigningField": true, "type": "AccountID" @@ -1130,7 +1032,6 @@ { "nth": 4, "isVLEncoded": true, - "bytes": "84", "isSerialized": true, "isSigningField": true, "type": "AccountID" @@ -1141,7 +1042,6 @@ { "nth": 7, "isVLEncoded": true, - "bytes": "87", "isSerialized": true, "isSigningField": true, "type": "AccountID" @@ -1152,7 +1052,6 @@ { "nth": 8, "isVLEncoded": true, - "bytes": "88", "isSerialized": true, "isSigningField": true, "type": "AccountID" @@ -1163,7 +1062,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "E1", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1174,7 +1072,6 @@ { "nth": 2, "isVLEncoded": false, - "bytes": "E2", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1185,7 +1082,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "E3", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1196,7 +1092,6 @@ { "nth": 4, "isVLEncoded": false, - "bytes": "E4", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1207,7 +1102,6 @@ { "nth": 5, "isVLEncoded": false, - "bytes": "E5", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1218,7 +1112,6 @@ { "nth": 6, "isVLEncoded": false, - "bytes": "E6", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1229,7 +1122,6 @@ { "nth": 7, "isVLEncoded": false, - "bytes": "E7", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1240,7 +1132,6 @@ { "nth": 8, "isVLEncoded": false, - "bytes": "E8", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1251,7 +1142,6 @@ { "nth": 9, "isVLEncoded": false, - "bytes": "E9", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1262,7 +1152,6 @@ { "nth": 10, "isVLEncoded": false, - "bytes": "EA", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1273,7 +1162,6 @@ { "nth": 11, "isVLEncoded": false, - "bytes": "EB", "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1284,7 +1172,16 @@ { "nth": 16, "isVLEncoded": false, - "bytes": "E010", + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "Majority", + { + "nth": 18, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, "type": "STObject" @@ -1295,7 +1192,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "F1", "isSerialized": true, "isSigningField": true, "type": "STArray" @@ -1306,7 +1202,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "F3", "isSerialized": true, "isSigningField": false, "type": "STArray" @@ -1317,7 +1212,6 @@ { "nth": 4, "isVLEncoded": false, - "bytes": "F4", "isSerialized": true, "isSigningField": true, "type": "STArray" @@ -1328,7 +1222,6 @@ { "nth": 5, "isVLEncoded": false, - "bytes": "F5", "isSerialized": true, "isSigningField": true, "type": "STArray" @@ -1339,7 +1232,6 @@ { "nth": 6, "isVLEncoded": false, - "bytes": "F6", "isSerialized": true, "isSigningField": true, "type": "STArray" @@ -1350,7 +1242,6 @@ { "nth": 7, "isVLEncoded": false, - "bytes": "F7", "isSerialized": true, "isSigningField": true, "type": "STArray" @@ -1361,7 +1252,6 @@ { "nth": 8, "isVLEncoded": false, - "bytes": "F8", "isSerialized": true, "isSigningField": true, "type": "STArray" @@ -1372,7 +1262,16 @@ { "nth": 9, "isVLEncoded": false, - "bytes": "F9", + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } + ], + [ + "Majorities", + { + "nth": 16, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, "type": "STArray" @@ -1383,7 +1282,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "0110", "isSerialized": true, "isSigningField": true, "type": "UInt8" @@ -1394,7 +1292,6 @@ { "nth": 2, "isVLEncoded": false, - "bytes": "0210", "isSerialized": true, "isSigningField": true, "type": "UInt8" @@ -1405,7 +1302,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "0310", "isSerialized": true, "isSigningField": true, "type": "UInt8" @@ -1416,7 +1312,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "0111", "isSerialized": true, "isSigningField": true, "type": "Hash160" @@ -1427,7 +1322,6 @@ { "nth": 2, "isVLEncoded": false, - "bytes": "0211", "isSerialized": true, "isSigningField": true, "type": "Hash160" @@ -1438,7 +1332,6 @@ { "nth": 3, "isVLEncoded": false, - "bytes": "0311", "isSerialized": true, "isSigningField": true, "type": "Hash160" @@ -1449,7 +1342,6 @@ { "nth": 4, "isVLEncoded": false, - "bytes": "0411", "isSerialized": true, "isSigningField": true, "type": "Hash160" @@ -1460,7 +1352,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "0112", "isSerialized": true, "isSigningField": true, "type": "PathSet" @@ -1471,7 +1362,6 @@ { "nth": 1, "isVLEncoded": true, - "bytes": "0113", "isSerialized": true, "isSigningField": true, "type": "Vector256" @@ -1482,18 +1372,16 @@ { "nth": 2, "isVLEncoded": true, - "bytes": "0213", "isSerialized": true, "isSigningField": true, "type": "Vector256" } ], [ - "Features", + "Amendments", { "nth": 3, "isVLEncoded": true, - "bytes": "0313", "isSerialized": true, "isSigningField": true, "type": "Vector256" @@ -1504,7 +1392,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "0111", "isSerialized": false, "isSigningField": false, "type": "Transaction" @@ -1515,7 +1402,6 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "0112", "isSerialized": false, "isSigningField": false, "type": "LedgerEntry" @@ -1526,14 +1412,12 @@ { "nth": 1, "isVLEncoded": false, - "bytes": "0113", "isSerialized": false, "isSigningField": false, "type": "Validation" } ] ], - "date-generated": "Fri Sep 11 11:35:38 ICT 2015", "TRANSACTION_RESULTS": { "tecINSUFFICIENT_RESERVE": 141, "telNO_DST_PARTIAL": -393, diff --git a/src/enums/index.js b/src/enums/index.js index 4f61683..eeb8172 100644 --- a/src/enums/index.js +++ b/src/enums/index.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const _ = require('lodash'); const {parseBytes, serializeUIntN} = require('./../utils/bytes-utils'); @@ -102,7 +100,7 @@ Enums.Field = makeClass({ const extra = {ordinal, name, type, bytes}; return new this(_.assign(definition, extra)); }); - return _.indexBy(fields, 'name'); + return _.keyBy(fields, 'name'); }, header(type, nth) { const name = nth; diff --git a/src/hash-prefixes.js b/src/hash-prefixes.js index 8409609..e8edbf8 100644 --- a/src/hash-prefixes.js +++ b/src/hash-prefixes.js @@ -1,5 +1,3 @@ -'use strict'; - const {serializeUIntN} = require('./utils/bytes-utils'); function bytes(uint32) { diff --git a/src/hashes.js b/src/hashes.js index b40d391..4495946 100644 --- a/src/hashes.js +++ b/src/hashes.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('./utils/make-class'); const {HashPrefix} = require('./hash-prefixes'); const {Hash256} = require('./types'); diff --git a/src/index.js b/src/index.js index 11df663..396e932 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const coreTypes = require('./coretypes'); const {quality, diff --git a/src/ledger-hashes.js b/src/ledger-hashes.js index 877a7d8..d3234c4 100644 --- a/src/ledger-hashes.js +++ b/src/ledger-hashes.js @@ -1,5 +1,3 @@ -'use strict'; - const _ = require('lodash'); const BN = require('bn.js'); const assert = require('assert'); diff --git a/src/quality.js b/src/quality.js index 0d7562d..936b831 100644 --- a/src/quality.js +++ b/src/quality.js @@ -1,4 +1,3 @@ -'use strict'; const Decimal = require('decimal.js'); const {bytesToHex, slice, parseBytes} = require('./utils/bytes-utils'); const {UInt64} = require('./types'); @@ -16,7 +15,7 @@ module.exports = { decode(arg) { const bytes = slice(parseBytes(arg), -8); const exponent = bytes[0] - 100; - const mantissa = new Decimal(bytesToHex(slice(bytes, 1)), 16); + const mantissa = new Decimal('0x' + bytesToHex(slice(bytes, 1))); return mantissa.times('1e' + exponent); } }; diff --git a/src/serdes/binary-parser.js b/src/serdes/binary-parser.js index 45d4dec..0717635 100644 --- a/src/serdes/binary-parser.js +++ b/src/serdes/binary-parser.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const makeClass = require('../utils/make-class'); const {Field} = require('../enums'); diff --git a/src/serdes/binary-serializer.js b/src/serdes/binary-serializer.js index 0b31267..620aa3d 100644 --- a/src/serdes/binary-serializer.js +++ b/src/serdes/binary-serializer.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const {parseBytes, bytesToHex} = require('../utils/bytes-utils'); const makeClass = require('../utils/make-class'); diff --git a/src/shamap.js b/src/shamap.js index 9a2d2da..fd608f3 100644 --- a/src/shamap.js +++ b/src/shamap.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const makeClass = require('./utils/make-class'); const {Hash256} = require('./types'); diff --git a/src/signing.js b/src/signing.js index 90f72a3..29e0944 100644 --- a/src/signing.js +++ b/src/signing.js @@ -1,4 +1,3 @@ -'use strict'; /* eslint-disable func-style */ const _ = require('lodash'); diff --git a/src/types/account-id.js b/src/types/account-id.js index 8245539..def51d6 100644 --- a/src/types/account-id.js +++ b/src/types/account-id.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {decodeAccountID, encodeAccountID} = require('ripple-address-codec'); const {Hash160} = require('./hash-160'); diff --git a/src/types/amount.js b/src/types/amount.js index 7fb13b9..4dee6b4 100644 --- a/src/types/amount.js +++ b/src/types/amount.js @@ -1,5 +1,3 @@ -'use strict'; - const _ = require('lodash'); const assert = require('assert'); const BN = require('bn.js'); @@ -58,7 +56,7 @@ const Amount = makeClass({ const isIOU = b1 & 0x80; const isPositive = b1 & 0x40; - const sign = isPositive ? '+' : '-'; + const sign = isPositive ? '' : '-'; if (isIOU) { mantissa[0] = 0; @@ -67,13 +65,13 @@ const Amount = makeClass({ const exponent = ((b1 & 0x3F) << 2) + ((b2 & 0xff) >> 6) - 97; mantissa[1] &= 0x3F; // decimal.js won't accept e notation with hex - const value = new Decimal(sign + bytesToHex(mantissa), 16) + const value = new Decimal(`${sign}0x${bytesToHex(mantissa)}`) .times('1e' + exponent); return new this(value, currency, issuer); } mantissa[0] &= 0x3F; - const drops = new Decimal(sign + bytesToHex(mantissa), 16); + const drops = new Decimal(`${sign}0x${bytesToHex(mantissa)}`); const xrpValue = drops.dividedBy('1e6'); return new this(xrpValue, Currency.XRP); } diff --git a/src/types/blob.js b/src/types/blob.js index 5626758..7d6a3c9 100644 --- a/src/types/blob.js +++ b/src/types/blob.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {parseBytes} = require('../utils/bytes-utils'); const {SerializedType} = require('./serialized-type'); diff --git a/src/types/currency.js b/src/types/currency.js index a0ea69d..d96f2d1 100644 --- a/src/types/currency.js +++ b/src/types/currency.js @@ -1,5 +1,3 @@ -'use strict'; - const _ = require('lodash'); const makeClass = require('../utils/make-class'); const {slice} = require('../utils/bytes-utils'); diff --git a/src/types/hash-128.js b/src/types/hash-128.js index 6b7b6cf..bb29417 100644 --- a/src/types/hash-128.js +++ b/src/types/hash-128.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {Hash} = require('./hash'); diff --git a/src/types/hash-160.js b/src/types/hash-160.js index ddc8f5d..8a96875 100644 --- a/src/types/hash-160.js +++ b/src/types/hash-160.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {Hash} = require('./hash'); diff --git a/src/types/hash-256.js b/src/types/hash-256.js index 89f1d89..4a4bfb2 100644 --- a/src/types/hash-256.js +++ b/src/types/hash-256.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {Hash} = require('./hash'); diff --git a/src/types/hash.js b/src/types/hash.js index a8e3a11..6536b9e 100644 --- a/src/types/hash.js +++ b/src/types/hash.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const makeClass = require('../utils/make-class'); const {Comparable, SerializedType} = require('./serialized-type'); diff --git a/src/types/index.js b/src/types/index.js index 9f340e2..7df5c8b 100644 --- a/src/types/index.js +++ b/src/types/index.js @@ -1,5 +1,3 @@ -'use strict'; - const enums = require('../enums'); const {Field} = enums; const {AccountID} = require('./account-id'); diff --git a/src/types/serialized-type.js b/src/types/serialized-type.js index 63c30fd..2bf61da 100644 --- a/src/types/serialized-type.js +++ b/src/types/serialized-type.js @@ -1,5 +1,3 @@ -'use strict'; - const {bytesToHex, slice} = require('../utils/bytes-utils'); const {BytesList} = require('../serdes/binary-serializer'); diff --git a/src/types/st-array.js b/src/types/st-array.js index dd99f76..66c9a47 100644 --- a/src/types/st-array.js +++ b/src/types/st-array.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {ensureArrayLikeIs, SerializedType} = require('./serialized-type'); const {Field} = require('../enums'); diff --git a/src/types/st-object.js b/src/types/st-object.js index 8ffd2df..4ac921e 100644 --- a/src/types/st-object.js +++ b/src/types/st-object.js @@ -1,6 +1,4 @@ -'use strict'; - -// const assert = require('assert'); +const assert = require('assert'); const _ = require('lodash'); const makeClass = require('../utils/make-class'); const {Field} = require('../enums'); @@ -44,9 +42,11 @@ const STObject = makeClass({ return Object.keys(this).map((k) => Field[k]).filter(Boolean); }, toJSON() { + // Otherwise seemingly result will have same prototype as `this` + const accumulator = {}; // of only `own` properties return _.transform(this, (result, value, key) => { result[key] = value && value.toJSON ? value.toJSON() : value; - }); + }, accumulator); }, toBytesSink(sink, filter = () => true) { const serializer = new BinarySerializer(sink); diff --git a/src/types/uint-16.js b/src/types/uint-16.js index f9ee3b1..c6547ca 100644 --- a/src/types/uint-16.js +++ b/src/types/uint-16.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {UInt} = require('./uint'); diff --git a/src/types/uint-32.js b/src/types/uint-32.js index 7e958f0..2865608 100644 --- a/src/types/uint-32.js +++ b/src/types/uint-32.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {UInt} = require('./uint'); diff --git a/src/types/uint-64.js b/src/types/uint-64.js index fc4ca2a..fd731a1 100644 --- a/src/types/uint-64.js +++ b/src/types/uint-64.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const BN = require('bn.js'); const makeClass = require('../utils/make-class'); diff --git a/src/types/uint-8.js b/src/types/uint-8.js index 31e36e9..2f261e1 100644 --- a/src/types/uint-8.js +++ b/src/types/uint-8.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {UInt} = require('./uint'); diff --git a/src/types/uint.js b/src/types/uint.js index f88bc73..60a069b 100644 --- a/src/types/uint.js +++ b/src/types/uint.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const BN = require('bn.js'); const makeClass = require('../utils/make-class'); diff --git a/src/types/vector-256.js b/src/types/vector-256.js index 85f2245..a3d4989 100644 --- a/src/types/vector-256.js +++ b/src/types/vector-256.js @@ -1,5 +1,3 @@ -'use strict'; - const makeClass = require('../utils/make-class'); const {Hash256} = require('./hash-256'); const {ensureArrayLikeIs, SerializedType} = require('./serialized-type'); diff --git a/src/utils/bytes-utils.js b/src/utils/bytes-utils.js index 7a48238..7daba22 100644 --- a/src/utils/bytes-utils.js +++ b/src/utils/bytes-utils.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); function signum(a, b) { diff --git a/src/utils/make-class.js b/src/utils/make-class.js index ae0947d..d51b984 100644 --- a/src/utils/make-class.js +++ b/src/utils/make-class.js @@ -1,5 +1,3 @@ -'use strict'; - const _ = require('lodash'); const inherits = require('inherits'); diff --git a/test/amount-test.js b/test/amount-test.js index ab59aa6..1b1f8b0 100644 --- a/test/amount-test.js +++ b/test/amount-test.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert-diff'); const {Amount} = require('../src/coretypes'); diff --git a/test/binary-json-test.js b/test/binary-json-test.js index 848982a..521795b 100644 --- a/test/binary-json-test.js +++ b/test/binary-json-test.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const fixtures = require('./fixtures/codec-fixtures.json'); const {decode, encode} = require('../src'); diff --git a/test/binary-parser-test.js b/test/binary-parser-test.js index f90355b..3962b73 100644 --- a/test/binary-parser-test.js +++ b/test/binary-parser-test.js @@ -1,7 +1,5 @@ /* eslint-disable func-style */ -'use strict'; - const coreTypes = require('../src/coretypes'); const _ = require('lodash'); @@ -157,11 +155,19 @@ function transactionParsingTests() { } assert(parser.end()); }); + it('can be done with higher level apis', () => { const parser = makeParser(transaction.binary); const jsonFromBinary = readJSON(parser); assert.deepEqual(jsonFromBinary, tx_json); }); + + it('readJSON (binary.decode) does not return STObject ', () => { + const parser = makeParser(transaction.binary); + const jsonFromBinary = readJSON(parser); + assert((jsonFromBinary instanceof coreTypes.STObject) === false); + assert(_.isPlainObject(jsonFromBinary)); + }); } function amountParsingTests() { @@ -322,35 +328,8 @@ function pathSetBinaryTests() { }); } -function parseLedger4320278() { - let ripple = require('ripple-lib'); - if (ripple._DEPRECATED) { - ripple = ripple._DEPRECATED; - } - ripple.Amount.strict_mode = false; - ripple = false; - - it(`can parse object`, () => { - this.timeout(30e3); - const json = loadFixture('as-ledger-4320278.json'); - - json.forEach((e, i) => { - const expected = e.json; - const actual = readJSON(makeParser(e.binary)); - actual.index = expected.index; - // const actual = new ripple.SerializedObject(e.binary).to_json(); - try { - assert.deepEqual(actual, expected); - } catch (error) { - console.log('error', i, !ripple && error); - } - }); - }); -} - describe('BinaryParser', function() { function dataDrivenTests() { - describe.skip('as-ledger-4320278.json', parseLedger4320278); describe('Amount parsing tests', amountParsingTests); describe('Field Tests', fieldParsingTests); describe('Parsing nested objects', nestedObjectTests); diff --git a/test/binary-serializer-test.js b/test/binary-serializer-test.js index f0fec91..5fd01fa 100644 --- a/test/binary-serializer-test.js +++ b/test/binary-serializer-test.js @@ -1,7 +1,5 @@ /* eslint-disable func-style */ -'use strict'; - const BN = require('bn.js'); const assert = require('assert-diff'); const lib = require('../src/coretypes'); @@ -78,7 +76,7 @@ function UIntTest() { function parseLedger4320278() { - it(`can parse object`, done => { + it('can parse object', done => { this.timeout(30e3); const json = loadFixture('as-ledger-4320278.json'); json.forEach(e => { @@ -89,7 +87,7 @@ function parseLedger4320278() { } function deliverMinTest() { - it(`can serialize DeliverMin`, () => { + it('can serialize DeliverMin', () => { assert.strictEqual(encode(deliverMinTx), deliverMinTxBinary); }); } diff --git a/test/bytes-utils-test.js b/test/bytes-utils-test.js index 93eb72c..023eccf 100644 --- a/test/bytes-utils-test.js +++ b/test/bytes-utils-test.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const bytesUtils = require('../src/utils/bytes-utils'); const {slice, compareBytes, parseBytes, bytesToHex} = bytesUtils; diff --git a/test/fixtures/data-driven-tests.json b/test/fixtures/data-driven-tests.json index 23deb32..fb747c0 100644 --- a/test/fixtures/data-driven-tests.json +++ b/test/fixtures/data-driven-tests.json @@ -926,7 +926,7 @@ }, { "type_name": "Vector256", - "name": "Features", + "name": "Amendments", "nth_of_type": 3, "type": 19, "expected_hex": "0313" diff --git a/test/hash-test.js b/test/hash-test.js index e35ad6e..549e397 100644 --- a/test/hash-test.js +++ b/test/hash-test.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert-diff'); const {Hash160, Hash256, Currency, AccountID} = require('../src/coretypes'); diff --git a/test/ledger-test.js b/test/ledger-test.js index 66365e3..6f6a938 100644 --- a/test/ledger-test.js +++ b/test/ledger-test.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const {loadFixture} = require('./utils'); const ledgerHashes = require('../src/ledger-hashes'); diff --git a/test/mocha.opts b/test/mocha.opts index ef2c5c9..26f1db9 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1 +1 @@ ---reporter spec --slow 500 --compilers js:babel/register +--reporter spec --slow 500 --compilers js:babel-register diff --git a/test/quality-test.js b/test/quality-test.js index 5cae1ca..ae5b89b 100644 --- a/test/quality-test.js +++ b/test/quality-test.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert-diff'); const {quality, binary: {bytesToHex}} = require('../src/coretypes'); diff --git a/test/shamap-test.js b/test/shamap-test.js index 433f5c9..9f68369 100644 --- a/test/shamap-test.js +++ b/test/shamap-test.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert-diff'); const {ShaMap} = require('../src/shamap.js'); const {binary: {serializeObject}, Hash256, HashPrefix} diff --git a/test/signing-data-encoding-test.js b/test/signing-data-encoding-test.js index 0985032..a41ef8d 100644 --- a/test/signing-data-encoding-test.js +++ b/test/signing-data-encoding-test.js @@ -1,5 +1,3 @@ -'use strict'; - const _ = require('lodash'); const assert = require('assert-diff'); const {encodeForSigning, encodeForMultisigning} = require('../src'); diff --git a/test/types-test.js b/test/types-test.js index e76d14c..eb89d2c 100644 --- a/test/types-test.js +++ b/test/types-test.js @@ -1,5 +1,3 @@ -'use strict'; - const _ = require('lodash'); const assert = require('assert'); const coreTypes = require('../src/types'); diff --git a/test/uint-test.js b/test/uint-test.js index d6f6601..a01fb65 100644 --- a/test/uint-test.js +++ b/test/uint-test.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('assert'); const coreTypes = require('../src/coretypes'); /* eslint-disable no-unused-vars */ diff --git a/test/utils.js b/test/utils.js index f83c25c..a2ec9a1 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,5 +1,3 @@ -'use strict'; - const intercept = require('intercept-stdout'); const fs = require('fs'); const fsExtra = require('fs-extra');