const tx = {
TransactionType : 'Payment',
Destination: 'rncjeoo4xeqKtrrqVHsxQjrV6CyZ93Wkvm',
Amount: String(10000),
Memos: [
{ Memo: {
MemoData: Buffer.from('Hi there! How are things?', 'utf8').toString('hex')
} },
{ Memo: {
MemoData: Buffer.from('Anything else?', 'utf8').toString('hex'),
MemoType: Buffer.from('something 123', 'utf8').toString('hex'),
MemoFormat: Buffer.from('some/mimetype', 'utf8').toString('hex')
} }
]
}
if (typeof tx.Memos !== 'undefined' && Array.isArray(tx.Memos)) {
tx.Memos = tx.Memos
.filter(m => typeof m.Memo === 'object' && m.Memo !== null)
.map(m => {
return {
Memo: Object.keys(m.Memo).reduce((a, b) => {
if (typeof m.Memo[b] === 'string') {
Object.assign(a, {
[b]: m.Memo[b].toUpperCase()
})
}
return a
}, {})
}
})
}
console.log(tx.Memos)