Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/snap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ For local development, you need to add `http://localhost:3000` to the `allowedOr

- **`yarn build`** - Standard build for production (only allows production origins)
- **`yarn build:local`** - Build for local development (automatically adds localhost:3000 to allowedOrigins)
- **`yarn build:prePublish`** - Pre-publish build that ensures `allowedOrigins` is reset to `["https://webzjs.chainsafe.dev"]` and then runs `mm-snap build`

The `build:local` script will:
1. Create a backup of the original `snap.manifest.json`
2. Modify the manifest to include `http://localhost:3000` in allowedOrigins
3. Run the build process

The `build:prePublish` script will:
1. Overwrite `allowedOrigins` in `snap.manifest.json` to only `["https://webzjs.chainsafe.dev"]`
2. Run the production build via `mm-snap build`

### Development Steps

1. Install dependencies with `yarn install`
Expand Down
19 changes: 19 additions & 0 deletions packages/snap/build_prePublish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Ensure allowedOrigins only contains the production URL, then build the snap.

set -euo pipefail

MANIFEST_FILE="snap.manifest.json"

echo "Ensuring allowedOrigins only contains https://webzjs.chainsafe.dev..."

jq '.initialPermissions."endowment:rpc".allowedOrigins = ["https://webzjs.chainsafe.dev"]' "$MANIFEST_FILE" > "$MANIFEST_FILE.tmp"
mv "$MANIFEST_FILE.tmp" "$MANIFEST_FILE"

echo "Running mm-snap build..."
mm-snap build

echo "build_prePublish completed."


1 change: 1 addition & 0 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"allow-scripts": "yarn workspace root allow-scripts",
"build": "mm-snap build",
"build:clean": "yarn clean && yarn build",
"build:prePublish": "bash ./build_prePublish.sh",
"build:local": "./build_local.sh",
"clean": "rimraf dist",
"lint": "eslint --color --ext .ts src/",
Expand Down
6 changes: 4 additions & 2 deletions packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/ChainSafe/WebZjs.git"
},
"source": {
"shasum": "m7tPwL0uBJEK4GoRksJUBkDixneKcyYOY8oxoZGmY5k=",
"shasum": "wTPZl0jiwxyFr3cUhss5/b0WjFGdZP9y/VIPafGtDAM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand All @@ -22,7 +22,9 @@
"endowment:lifecycle-hooks": {},
"endowment:webassembly": {},
"endowment:rpc": {
"allowedOrigins": ["https://webzjs.chainsafe.dev"]
"allowedOrigins": [
"https://webzjs.chainsafe.dev"
]
},
"snap_getBip44Entropy": [
{
Expand Down