Solidity: Governor absolute quorum values accepted by validation generate code that does not compile

Aperta
#895 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@RaphaelFakhri ci sta già lavorando.

Dal 27/10/2026.

  • #896 di @RaphaelFakhri — aperta
  • #899 di @ninglinLiu — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
solidity, typescript
Ambito
blockchain

Direzione di ricerca

Start with the Governor option validation: numberPattern and the quorum() code generation, where ${quorumAbsolute}e${decimals} is printed, both in the Solidity generator in this repository. Reproduce each row of the table (for example 1e3, 010, and 1.5 with erc721votes) and check the generated line against solc. Done when those inputs either produce a valid literal (such as return 1e21; for 1e3 with 18 decimals) or are rejected with an option error like premint's Too many decimals.

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

Descrizione

The Governor quorumAbsolute option is checked against numberPattern (/^(?!$)(\d*)(?:\.(\d+))?(?:e(\d+))?$/), and the value is then printed into quorum() as ${quorumAbsolute}e${decimals}, or as-is when decimals is 0 or votes is erc721votes. Some values that pass validation produce a literal that solc rejects:

Options Generated line solc 0.8.26 error
quorumAbsolute: '1e3' (18 decimals) return 1e3e18; Identifier-start is not allowed at end of a number.
quorumAbsolute: '010' (18 decimals) return 010e18; Octal numbers not allowed.
quorumAbsolute: '1.5', votes: 'erc721votes' (or decimals: 0) return 1.5; Return argument type rational_const 3 / 2 is not implicitly convertible to expected type ... uint256.

The UI's absolute quorum field is a text input, so these values can be typed in the Governor tab and produce a contract that does not compile, with no error shown.

Expected behavior

Values in scientific notation or with leading zeros generate a valid literal (for example return 1e21; for 1e3 with 18 decimals), and a quorum that is not a whole number of votes is rejected with an option error, as premint does with Too many decimals.

Lingua principale
TypeScript
Stelle
296
Fork
188
Merge medio
3h 24m
PR unite (30g)
11

Preparare l'ambiente

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/contracts-wizard

Tutte le issue di OpenZeppelin/contracts-wizard

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.