0xMiden / 0xMiden/takeoff

Deploying larger compiled packages can fail during base64 encoding

Open Beginner friendly
#8 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

## 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`.

Contributor guide

Open the contributing guide

Research direction

Look at the ContractList component where contract.packageBytes is converted to base64. The issue is in the use of String.fromCharCode(...contract.packageBytes). Find or create a utility function for safe base64 encoding of large Uint8Arrays, perhaps in a shared utils file. Test the fix by simulating a large package deployment.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.