mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 11:45:50 +00:00
- Made output more user-friendly
This commit is contained in:
@@ -8,9 +8,16 @@ const TxSerializer = require('./tx-serializer') // Main serialization logic can
|
|||||||
|
|
||||||
function main(rawJson, verbose) {
|
function main(rawJson, verbose) {
|
||||||
const json = JSON.parse(rawJson)
|
const json = JSON.parse(rawJson)
|
||||||
const serializer = new TxSerializer(verbose)
|
console.log('\x1b[33m%s\x1b[0m', '\nXRPL Transaction Serialization Example')
|
||||||
const serializedTx = serializer.serializeTx(json)
|
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())
|
console.log(serializedTx.toUpperCase())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ class TxSerializer {
|
|||||||
amount[1] |= (exponentByte & 0x03) << 6
|
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"])
|
const currencyCode = this.currencyCodeToBytes(value["currency"])
|
||||||
|
|
||||||
@@ -453,7 +453,7 @@ class TxSerializer {
|
|||||||
if (this.definitions["FIELDS"][fieldName]["isSerialized"]) {
|
if (this.definitions["FIELDS"][fieldName]["isSerialized"]) {
|
||||||
const fieldValue = object[fieldName]
|
const fieldValue = object[fieldName]
|
||||||
const fieldBytes = this.fieldToBytes(fieldName, fieldValue)
|
const fieldBytes = this.fieldToBytes(fieldName, fieldValue)
|
||||||
this._logger(fieldName + ": " + fieldBytes)
|
this._logger(fieldName + ": " + fieldBytes.toUpperCase())
|
||||||
fieldsAsBytes.push(fieldBytes)
|
fieldsAsBytes.push(fieldBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -484,7 +484,7 @@ class TxSerializer {
|
|||||||
|
|
||||||
for (let [key, path] of Object.entries(pathset)) {
|
for (let [key, path] of Object.entries(pathset)) {
|
||||||
const pathBytes = this.pathToBytes(path)
|
const pathBytes = this.pathToBytes(path)
|
||||||
this._logger("Path " + path + ": " + pathBytes)
|
this._logger("Path " + path + ": " + pathBytes.toUpperCase())
|
||||||
pathsAsHexBytes += pathBytes
|
pathsAsHexBytes += pathBytes
|
||||||
|
|
||||||
if (parseInt(key) + 1 === pathset.length) {
|
if (parseInt(key) + 1 === pathset.length) {
|
||||||
@@ -585,12 +585,12 @@ class TxSerializer {
|
|||||||
this._logger("Serializing field " + fieldName + " of type " + fieldType)
|
this._logger("Serializing field " + fieldName + " of type " + fieldType)
|
||||||
|
|
||||||
const idPrefix = this.fieldId(fieldName)
|
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
|
// Special case: convert from string to UInt16
|
||||||
if (fieldName === "TransactionType") {
|
if (fieldName === "TransactionType") {
|
||||||
const fieldBytes = this.txTypeToBytes(fieldValue)
|
const fieldBytes = this.txTypeToBytes(fieldValue)
|
||||||
this._logger(fieldName + ' : ' + fieldBytes)
|
this._logger(fieldName + ' : ' + fieldBytes.toUpperCase())
|
||||||
|
|
||||||
return idPrefix + fieldBytes
|
return idPrefix + fieldBytes
|
||||||
}
|
}
|
||||||
@@ -612,7 +612,7 @@ class TxSerializer {
|
|||||||
|
|
||||||
const fieldBytes = dispatch[fieldType](fieldValue)
|
const fieldBytes = dispatch[fieldType](fieldValue)
|
||||||
|
|
||||||
this._logger(fieldName + ': ' + fieldBytes)
|
this._logger(fieldName + ': ' + fieldBytes.toUpperCase())
|
||||||
|
|
||||||
return idPrefix.toString("hex") + fieldBytes
|
return idPrefix.toString("hex") + fieldBytes
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user