Deploying larger compiled packages can fail during base64 encoding
- 主要語言
- TypeScript
- 星號
- 2
- 分支
- 2
- PR 合併指標
- 30 天內沒有已合併 PR
描述
## 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`.
貢獻指南
研究方向
查看 ContractList 元件中 contract.packageBytes 被轉換為 base64 的地方。問題在於使用了 String.fromCharCode(...contract.packageBytes)。尋找或建立一個用於安全地對大型 Uint8Array 進行 base64 編碼的實用函數,或許可以放在共用的 utils 檔案中。透過模擬大型套件的部署來測試修復。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript
- 領域
- cli, frontend
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 活躍
- 描述清晰度
- 描述清楚
- 新手友好度
- 75/100