`toString` throws on any datum or output that holds an integer

Aberta
#685 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
55/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
node.js, typescript
Domínio
backend, devtools

Direção de pesquisa

Start with InlineDatum.ts and Inspectable.format, then compare the toJSON implementations in UTxO.ts, TxOut.ts, TransactionOutput.ts, and Redeemer.ts. Check how integers, byte strings, and maps are represented and whether the behavior is consistent across these classes. Done means toString and toJSON render data containing those values without throwing or losing their contents.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug

new InlineDatum.InlineDatum({ data: Data.int(1n) }).toString() throws TypeError: Do not know how to serialize a BigInt. String(...), a template string and JSON.stringify on the same value throw it too, and so does toString() on a UTxO, TxOut, TransactionOutput or Redeemer whose data holds an integer anywhere. Every constructor holds one, since its index is a bigint, so an InlineDatum of Data.constr(0n, []) throws as well. Data without integers renders, but wrongly: the byte string ab shows as {"0": 171} and the map {1: 2} as {}. console.log works, because it prints through NodeInspectSymbol: { _tag: 'InlineDatum', data: 1n }.

InlineDatum.toJSON returns the data as it is (InlineDatum.ts:18-20), and toString passes that to Inspectable.format (InlineDatum.ts:26-27), which is JSON.stringify with no handling for bigint, Uint8Array or Map. UTxO.toJSON (UTxO.ts:32-46) and TxOut.toJSON (TxOut.ts:44-51) embed datumOption.toJSON(), BabbageTransactionOutput.toJSON embeds the datum object (TransactionOutput.ts:95-103), and Redeemer.toJSON returns data as it is (Redeemer.ts:93-101).

The failure does not depend on depth. Any integer or constructor anywhere in the data triggers it, so toString fails on every datum, UTxO, output or redeemer whose data uses a constructor. A log line or error message that puts one of these values in a template string throws a TypeError instead of printing. The behavior is the same before and after #677.

toString and toJSON on these classes should render any datum, with its integers, byte strings and maps.

Linguagem predominante
TypeScript
Estrelas
22
Forks
33
Merge médio
21h 38min
PRs com merge (30d)
55

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de IntersectMBO/evolution-sdk

Todas as issues de IntersectMBO/evolution-sdk

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.