mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-22 12:45:50 +00:00
- Added --raw CLI option
This commit is contained in:
@@ -7,16 +7,16 @@ const TxSerializer = require('./tx-serializer')
|
||||
|
||||
function main(rawJson, verbose) {
|
||||
const json = JSON.parse(rawJson)
|
||||
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('')
|
||||
_pretty('\nXRPL Transaction Serialization Example', '\x1b[33m%s\x1b[0m')
|
||||
_pretty('--------------------------------------', '\x1b[33m%s\x1b[0m')
|
||||
_pretty('\nSerializing the following transaction:', '\x1b[37m%s\x1b[0m')
|
||||
_pretty(json)
|
||||
if (verbose) _pretty('')
|
||||
|
||||
const serializer = new TxSerializer(verbose)
|
||||
|
||||
const serializedTx = serializer.serializeTx(json)
|
||||
console.log('\x1b[37m%s\x1b[0m', '\nSerialized Transaction:')
|
||||
_pretty('\nSerialized Transaction:', '\x1b[37m%s\x1b[0m')
|
||||
console.log(serializedTx.toUpperCase())
|
||||
}
|
||||
|
||||
@@ -24,15 +24,23 @@ const args = parseArgs(process.argv.slice(2), {
|
||||
alias: {
|
||||
'f': 'filename',
|
||||
'j': 'json',
|
||||
'r': 'raw',
|
||||
's': 'stdin',
|
||||
'v': 'verbose',
|
||||
},
|
||||
default: {
|
||||
'f': 'test-cases/tx1.json',
|
||||
'r': false,
|
||||
'v': false
|
||||
}
|
||||
})
|
||||
|
||||
function _pretty(message, color) {
|
||||
if (!args.raw) {
|
||||
console.log(color, message)
|
||||
}
|
||||
}
|
||||
|
||||
let rawJson
|
||||
if (args.json) {
|
||||
rawJson = args.json
|
||||
|
||||
Reference in New Issue
Block a user