Code4rena Botrace Utils
Various utilities for Code4rena Bot Races
Getting Started
Installation
Node.js 18 or higher is required.
Install via npm: npm i -g @code4rena/botrace-utils
Or use npx to run the package directly: npx @code4rena/botrace-utils --help
Command line
Once installed the c4bru
command will be available. See c4bru --help
for full usage.
JSON validation
To validate a local file named report.json
:
c4bru validate ./report.json
By default, this uses the currently recommended schema version. See the --help
docs for how to change the target schema.
Markdown Rendering
You can generate Markdown from your JSON report as it will be rendered for Github.
Note: Prior to generating the markdown the JSON report will be run through validation.
c4bru ./report.json > report.md
As a library
JSON validation
import {
defaultVersion,
schemas,
validateReport,
} from "@code4rena/botrace-utils";
const validate = (reportJson) => {
return validateReport(reportJson);
return validateReport(reportJson, schemas[defaultVersion]);
return validateReport(reportJson, schemas["0.2.0"]);
};
Markdown Rendering
Note: the api does not validate before rendering, it's recommended you run validation prior to rendering
import {
renderReport,
} from "@code4rena/botrace-utils";
const toMarkdown = (reportJson, winningBotName) => {
return renderReport(reportJson);
return renderReport(reportJson, winningBotName);
};