Ganache JSON-RPC Documentation
${preamble}
import { join } from "path"; import { readFileSync, writeFileSync } from "fs"; const { execSync } = require("child_process"); const marked = require("marked"); const hljs = require("highlight.js"); const highlight = () => { const raw = {} as any; return { raw, fn: function (code: string, language: string) { raw.code = code; raw.language = language; const validLanguage = hljs.getLanguage(language) ? language : "plaintext"; return hljs.highlight(validLanguage, code).value; } }; }; const markedOptions = { highlight: highlight().fn }; type Category = { title: string; children: number[]; }; type Group = { title: string; kind: number; children: Child[]; categories: Category[]; }; type Child = { children: Child[]; groups: Group[]; } & Method; const api = JSON.parse( readFileSync(join(__dirname, "../../docs/typedoc/api.json"), "utf8") ) as Child; const ethereum = api.children[0]; function x(unsafe: string) { return unsafe .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } function e(s: string) { return encodeURIComponent(s); } type Tag = { tag: string; text: string; }; type Type = { name: string; type: string; types: Type[]; typeArguments: Type[]; elements: Type[]; elementType: Type; value?: any; declaration?: Child; }; type Comment = { shortText: string; text: string; tags: Tag[]; returns: string; }; type Method = { id: number; name: string; signatures: { name: string; type: Type; parameters: { name: string; type: Type; flags: { isOptional: boolean; }; comment?: Comment; }[]; comment: Comment; }[]; type: Type; kindString: string; flags: any; sources: any[]; }; function renderReturns(method: Method) { const comment = method.signatures[0].comment && method.signatures[0].comment.returns ? method.signatures[0].comment.returns : null; let returnType = renderReturnType(method); if (returnType.includes("Quantity")) { returnType = "QUANTITY"; } if (returnType.includes("Data")) { returnType = "DATA"; } const returnTypeHtml = marked( `\`\`\`typescript function g(): ${returnType} \`\`\``, markedOptions ) .replace( 'function g(): ', "" ) .replace(/<\/?pre>/g, ""); let returnHtml = returnTypeHtml.replace(/\n/g, "") + (comment ? marked.parse(": " + comment, markedOptions) : ""); return `
${preamble}