0xMiden / 0xMiden/takeoff

Deploying larger compiled packages can fail during base64 encoding

Abierto Apto para principiantes
#8 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
2
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

## Summary

Deploying a compiled contract can fail before `useDeploy()` is called when the compiled package is large enough.

`ContractList` converts `contract.packageBytes` to base64 with:

```ts
btoa(String.fromCharCode(...contract.packageBytes))
```

Spreading a large `Uint8Array` into `String.fromCharCode()` is limited by the JavaScript engine's maximum argument count. Once the compiled package crosses that threshold, the click handler throws synchronously with `RangeError: Maximum call stack size exceeded` and the deploy flow never starts.

## Repro

This is the same conversion pattern used by the deploy button:

```sh
node -e "const b=new Uint8Array(200000); String.fromCharCode(...b)"
```

It fails with:

```text
RangeError: Maximum call stack size exceeded
```

## Impact

A contract can compile successfully and still be impossible to deploy from the UI solely because its `.masp` package is too large for the spread call. The deploy hook already accepts base64, so this is only an encoding issue in the UI boundary.

## Suggested fix

Encode the `Uint8Array` in chunks, or move a safe `uint8ArrayToBase64()` helper into a shared utility and use it from `ContractList`.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Observe el componente ContractList donde contract.packageBytes se convierte a base64. El problema está en el uso de String.fromCharCode(...contract.packageBytes). Busque o cree una función de utilidad para la codificación base64 segura de Uint8Arrays grandes, quizás en un archivo de utilidades compartido. Pruebe la solución simulando una implementación de paquete grande.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
cli, frontend
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Activo
Claridad
Bien especificado
Aptitud para principiantes
75/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.