Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Get GH XRPL Tx Types

node v10.24.1
version: 7.0.0
endpointsharetweet
const Fetch = require('node-fetch') const getTransactionTypes = async () => { const dirList = await Fetch('https://api.github.com/repos/ripple/xrpl-dev-portal/contents/content/references/protocol-reference/transactions/transaction-types').then(r => r.json()) const relevantFiles = dirList.filter(r => r.name.match(/^[a-zA-Z]+\.md$/)) return Promise.all(relevantFiles.map(async f => { const source = await Fetch(f.download_url).then(r => r.text()) return { transactionType: source.match(/^# ([a-zA-Z]+)/gm)[0].slice(2), docLink: 'https://xrpl.org/' + f.name.split('.')[0] + '.html', codeSamples: source.split(`\n`).join(' ').match(/```.+?```/gm) .map(s => s.split('```')[1].trim().replace(/^json[\n]*/gm, '')) .map(s => s.replace(/,[ \t\n\\t\\n]*}$/, '}')) .map(s => { try { return JSON.parse(s) } catch (e) { return s } }) } })) } const transactionTypes = await getTransactionTypes() console.log(transactionTypes)
Loading…

no comments

    sign in to comment