MetaMask / MetaMask/snaps

Enable shipping WebAssembly source code alongside main Snap bundle

Open
#774 0 comments 0 reactions 0 assignees View on GitHub
area-developing area-publishing type-enhancement
Dominant language
TypeScript
Stars
853
Forks
662
Avg merge
2d 8h
Merged PRs (30d)
8

Description

Snaps that use WebAssembly (WASM) currently have two options for loading their WASM source at runtime:
1. Host it somewhere and fetch it at runtime (e.g. [here](https://github.com/0xPARC/cabal/blob/ebab0001cfdf7ebac8b44153e56e0c3dd3190deb/snap/src/snark_utils/generate_proof.js))
2. Turn the WASM source into a byte string, bundle that into the JavaScript source and convert it to a buffer at runtime

(1) requires network access - which makes it harder to trust the snap - while (2) is clunky and may make the JavaScript bundle impractically large. We need to provide a way for snaps to ship their `.wasm` files alongside the main JavaScript bundle and load them at runtime.

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by tracing how the main JavaScript bundle is produced and how Snaps load runtime resources, then define the packaging and loading path for a separate .wasm file. Done means a Snap can ship its WASM source alongside the bundle and load it without network access or embedding it as a byte string.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, wasm
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.