Input undefined -- library use case for Truffle

Aperta
#393 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
node.js, solidity, typescript

Direzione di ricerca

Start with the README's raw docgen example and the buildSite path in site.js, then inspect clone.js where originalBuild.input is parsed. Reproduce the Truffle build/contracts/CurrencyManager.json input with the supplied docify.js script; done means the documented raw-input form no longer fails, or the README clearly states the required input shape and supported limitation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Trying to get solidity-docgen (installed from npm, specified as '^0.6.0-beta.17' in package.json) to compile files for me, without transitioning from Truffle to Hardhat, by using the following script:

const { docgen } = require('solidity-docgen');
const fs = require("fs");

const json = JSON.parse(fs.readFileSync('build/contracts/CurrencyManager.json'));
// console.log(json);
docgen([{ output: json }]).then(res => {
    console.log(res);
});

Note that the CurrencyManager.json file is the json output after truffle compiled -- it does have an 'ast' field present, as indicated by the readme. To my understanding, this this script is equivalent the current readme example usage, although I am of course confused by what exactly the 'output' parameter needs to be. The error I get if I run this:

undefined:1
undefined
^

SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at clone (/home/miko/solidity/karmaToken/node_modules/solidity-docgen/dist/utils/clone.js:9:29)
    at buildSite (/home/miko/solidity/karmaToken/node_modules/solidity-docgen/dist/site.js:27:41)
    at main (/home/miko/solidity/karmaToken/node_modules/solidity-docgen/dist/main.js:20:39)
    at Object.<anonymous> (/home/miko/solidity/karmaToken/docify.js:6:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

Taking a look at the offending function in site.js, I get the following -- the error occurs when we try to pass originalBuild.input to some function clone, where originalBuild is actually the element inside the array I passed in the config. The error seems to be happening because the code required the 'input' field to be json-parseable, while it is recommended to be undefined in the readme.

function buildSite(builds, siteConfig) {
    var _a;
    const assign = typeof siteConfig.pages === 'string' ? exports.pageAssigner[siteConfig.pages] : siteConfig.pages;
    const seen = new Set();
    const items = [];
    const pages = {};
    for (const originalBuild of builds) {
        // Clone because we will mutate in order to add item context.
        const output = (0, clone_1.clone)(originalBuild.output);
        const input = (0, clone_1.clone)(originalBuild.input);
        const deref = (0, utils_1.astDereferencer)(output);
        const build = { input, output, deref };
        for (const { ast: file } of Object.values(build.output.sources)) {

I understand that this project is mostly concerned with supporting the hardhat use-case. Was hoping for clarification if this raw use-case is even possible and, if so, how we should go about doing it.

👍👍 Thanks for supporting!

Lingua principale
TypeScript
Stelle
460
Fork
111
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenZeppelin/solidity-docgen

Tutte le issue di OpenZeppelin/solidity-docgen

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.