renderer: amount fields lose precision because the transform goes through Number()

Aperta
#262 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
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend, web-dev

Direzione di ricerca

Read packages/renderer/src/utils/formUtils.ts, especially the amount and number transforms at lines 87 and 209–210, to trace how form values are converted. The issue identifies precision loss and suggests emitting amounts as strings, but says this needs a plan across both this repository and the adapters before implementation. Done means an agreed cross-repository approach that preserves the submitted amount exactly.

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

Descrizione

cla: allowlist

createTransformForFieldType maps 'amount' to the same transform as 'number' (formUtils.ts#L209-L210). That transform's output step is Number(value) (formUtils.ts#L87), so renderer forms round any amount that doesn't fit in a JS number before handing it on.

two examples:

  • Number('1.000000000000000001') gives 1
  • Number('12345678901234567890') gives 12345678901234567000

With 18-decimal tokens this is easy to hit. The user types one amount and the form submits a different one.

I think the fix is to emit the amount as a string instead of a number. That changes what the adapters get from renderer forms, though, so it can't land in this repo on its own. it needs a plan across both repos first. Happy to hear other ideas on the shape.

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

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/openzeppelin-ui

Tutte le issue di OpenZeppelin/openzeppelin-ui

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.