mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 12:15:50 +00:00
- Changed test-cases README.md examples from python-cli to node-cli
- added input handling from --stdin - wrapped some logic in callback function in main file as new --stind option works asynchronously
This commit is contained in:
@@ -636,10 +636,19 @@ class TxSerializer {
|
||||
|
||||
// Startup stuff begin
|
||||
|
||||
function main(rawJson) {
|
||||
const json = JSON.parse(rawJson)
|
||||
const serializer = new TxSerializer(json)
|
||||
const serializedTx = serializer.serializeTx(json)
|
||||
|
||||
console.log(serializedTx.toUpperCase())
|
||||
}
|
||||
|
||||
const args = parseArgs(process.argv.slice(2), {
|
||||
alias: {
|
||||
'f': 'filename',
|
||||
'j': 'json',
|
||||
's': 'stdin',
|
||||
'v': 'verbose',
|
||||
},
|
||||
default: {
|
||||
@@ -659,12 +668,20 @@ const logger = function(verbose, value) {
|
||||
let rawJson
|
||||
if (args.json) {
|
||||
rawJson = args.json
|
||||
main(rawJson)
|
||||
} else if (args.stdin) {
|
||||
const stdin = process.openStdin();
|
||||
|
||||
let data = ""
|
||||
|
||||
stdin.on('data', function(chunk) {
|
||||
data += chunk
|
||||
});
|
||||
|
||||
stdin.on('end', function() {
|
||||
main(data)
|
||||
});
|
||||
} else {
|
||||
rawJson = fs.readFileSync(args.filename, 'utf8')
|
||||
}
|
||||
|
||||
const json = JSON.parse(rawJson)
|
||||
const serializer = new TxSerializer(json)
|
||||
const serializedTx = serializer.serializeTx(json)
|
||||
|
||||
console.log(serializedTx.toUpperCase())
|
||||
main(rawJson)
|
||||
}
|
||||
Reference in New Issue
Block a user