diff --git a/content/_code-samples/tx-serialization/js/index.js b/content/_code-samples/tx-serialization/js/index.js index 3e56d3542b..bdf3d656b7 100644 --- a/content/_code-samples/tx-serialization/js/index.js +++ b/content/_code-samples/tx-serialization/js/index.js @@ -8,9 +8,16 @@ const TxSerializer = require('./tx-serializer') // Main serialization logic can function main(rawJson, verbose) { const json = JSON.parse(rawJson) - const serializer = new TxSerializer(verbose) - const serializedTx = serializer.serializeTx(json) + console.log('\x1b[33m%s\x1b[0m', '\nXRPL Transaction Serialization Example') + console.log('\x1b[33m%s\x1b[0m', '--------------------------------------') + console.log('\x1b[37m%s\x1b[0m', '\nSerializing the following transaction:') + console.log(json) + if (verbose) console.log('') + const serializer = new TxSerializer(verbose) + + const serializedTx = serializer.serializeTx(json) + console.log('\x1b[37m%s\x1b[0m', '\nSerialized Transaction:') console.log(serializedTx.toUpperCase()) } diff --git a/content/_code-samples/tx-serialization/js/tx-serializer.js b/content/_code-samples/tx-serialization/js/tx-serializer.js index a07b7556ae..8b2672fdc8 100644 --- a/content/_code-samples/tx-serialization/js/tx-serializer.js +++ b/content/_code-samples/tx-serialization/js/tx-serializer.js @@ -273,7 +273,7 @@ class TxSerializer { amount[1] |= (exponentByte & 0x03) << 6 } - this._logger("Issued amount: " + amount.toString("hex")) + this._logger("Issued amount: " + amount.toString("hex").toUpperCase()) const currencyCode = this.currencyCodeToBytes(value["currency"]) @@ -453,7 +453,7 @@ class TxSerializer { if (this.definitions["FIELDS"][fieldName]["isSerialized"]) { const fieldValue = object[fieldName] const fieldBytes = this.fieldToBytes(fieldName, fieldValue) - this._logger(fieldName + ": " + fieldBytes) + this._logger(fieldName + ": " + fieldBytes.toUpperCase()) fieldsAsBytes.push(fieldBytes) } } @@ -484,7 +484,7 @@ class TxSerializer { for (let [key, path] of Object.entries(pathset)) { const pathBytes = this.pathToBytes(path) - this._logger("Path " + path + ": " + pathBytes) + this._logger("Path " + path + ": " + pathBytes.toUpperCase()) pathsAsHexBytes += pathBytes if (parseInt(key) + 1 === pathset.length) { @@ -585,12 +585,12 @@ class TxSerializer { this._logger("Serializing field " + fieldName + " of type " + fieldType) const idPrefix = this.fieldId(fieldName) - this._logger("ID Prefix is: " + idPrefix) + this._logger("ID Prefix is: " + idPrefix.toUpperCase()) // Special case: convert from string to UInt16 if (fieldName === "TransactionType") { const fieldBytes = this.txTypeToBytes(fieldValue) - this._logger(fieldName + ' : ' + fieldBytes) + this._logger(fieldName + ' : ' + fieldBytes.toUpperCase()) return idPrefix + fieldBytes } @@ -612,7 +612,7 @@ class TxSerializer { const fieldBytes = dispatch[fieldType](fieldValue) - this._logger(fieldName + ': ' + fieldBytes) + this._logger(fieldName + ': ' + fieldBytes.toUpperCase()) return idPrefix.toString("hex") + fieldBytes }