Skip to content

Commit 5ff8b7e

Browse files
committed
Merge branch 'dev' into feat/account-api-v2
2 parents 206c6b9 + e08edc4 commit 5ff8b7e

36 files changed

+1653
-365
lines changed

.github/workflows/build-lint-test.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
node-version: [21.x]
23+
node-version: [22.x]
2424
outputs:
2525
child-workspace-package-names: ${{ steps.workspace-package-names.outputs.child-workspace-package-names }}
2626
steps:
2727
- name: Checkout and setup environment
2828
uses: MetaMask/action-checkout-and-setup@v1
2929
with:
3030
is-high-risk-environment: false
31-
cache-node-modules: ${{ matrix.node-version == '21.x' }}
31+
cache-node-modules: ${{ matrix.node-version == '22.x' }}
3232
- name: Fetch workspace package names
3333
id: workspace-package-names
3434
run: |
@@ -42,7 +42,7 @@ jobs:
4242
- prepare
4343
strategy:
4444
matrix:
45-
node-version: [21.x]
45+
node-version: [22.x]
4646
steps:
4747
- name: Checkout and setup environment
4848
uses: MetaMask/action-checkout-and-setup@v1
@@ -64,7 +64,7 @@ jobs:
6464
- prepare
6565
strategy:
6666
matrix:
67-
node-version: [21.x]
67+
node-version: [22.x]
6868
steps:
6969
- name: Checkout and setup environment
7070
uses: MetaMask/action-checkout-and-setup@v1
@@ -83,7 +83,6 @@ jobs:
8383
key: gator-permissions-${{ runner.os }}-${{ github.sha }}
8484
- name: Cache manifests
8585
uses: actions/cache@v4
86-
if: ${{ github.base_ref == 'dev' }}
8786
with:
8887
path: |
8988
./packages/gator-permissions-snap/snap.manifest.json
@@ -92,18 +91,9 @@ jobs:
9291
- name: Require clean working directory
9392
shell: bash
9493
run: |
95-
# Check if target branch is 'dev' and exclude snap.manifest.json files if so
96-
if [[ "${{ github.base_ref }}" == "dev" || "${{ github.ref_name }}" == "dev" ]]; then
97-
echo "Target branch is 'dev', ignoring changes to snap.manifest.json files"
98-
if ! git diff --exit-code -- . ':!**/snap.manifest.json'; then
99-
echo "Working tree dirty at end of job (excluding snap.manifest.json)"
100-
exit 1
101-
fi
102-
else
103-
if ! git diff --exit-code; then
104-
echo "Working tree dirty at end of job"
105-
exit 1
106-
fi
94+
if ! git diff --exit-code; then
95+
echo "Working tree dirty at end of job"
96+
exit 1
10797
fi
10898
10999
lint:
@@ -113,7 +103,7 @@ jobs:
113103
- prepare
114104
strategy:
115105
matrix:
116-
node-version: [21.x]
106+
node-version: [22.x]
117107
steps:
118108
- name: Checkout and setup environment
119109
uses: MetaMask/action-checkout-and-setup@v1
@@ -136,7 +126,7 @@ jobs:
136126
- build
137127
strategy:
138128
matrix:
139-
node-version: [21.x]
129+
node-version: [22.x]
140130
steps:
141131
- name: Checkout and setup environment
142132
uses: MetaMask/action-checkout-and-setup@v1
@@ -154,7 +144,6 @@ jobs:
154144
key: gator-permissions-${{ runner.os }}-${{ github.sha }}
155145
- name: Restore manifests
156146
uses: actions/cache@v4
157-
if: ${{ github.base_ref == 'dev' }}
158147
with:
159148
path: |
160149
./packages/gator-permissions-snap/snap.manifest.json
@@ -165,16 +154,7 @@ jobs:
165154
- name: Require clean working directory
166155
shell: bash
167156
run: |
168-
# Check if target branch is 'dev' and exclude snap.manifest.json files if so
169-
if [[ "${{ github.base_ref }}" == "dev" || "${{ github.ref_name }}" == "dev" ]]; then
170-
echo "Target branch is 'dev', ignoring changes to snap.manifest.json files"
171-
if ! git diff --exit-code -- . ':!**/snap.manifest.json'; then
172-
echo "Working tree dirty at end of job (excluding snap.manifest.json)"
173-
exit 1
174-
fi
175-
else
176-
if ! git diff --exit-code; then
177-
echo "Working tree dirty at end of job"
178-
exit 1
179-
fi
157+
if ! git diff --exit-code; then
158+
echo "Working tree dirty at end of job"
159+
exit 1
180160
fi

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ node_modules/
7878
.yarn/build-state.yml
7979
.yarn/install-state.gz
8080
.pnp.*
81+
82+
# Generated manifest files
83+
packages/*/snap.manifest.json

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.17.0
1+
v22.19.0

docs/manifest-management.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Manifest Management Guide
2+
3+
The 7715 permissions snaps use environment-based manifest configuration via `SNAP_ENV`.
4+
5+
## Quick Start
6+
7+
### Local Development
8+
```bash
9+
# Build or start with development environment
10+
SNAP_ENV=local yarn start
11+
```
12+
13+
### Production Build
14+
```bash
15+
# Default is production
16+
yarn build
17+
18+
# Or explicit
19+
SNAP_ENV=production yarn build
20+
```
21+
22+
## Configuration
23+
24+
| Environment | Gator Snap | Kernel Snap |
25+
|------------|------------|-------------|
26+
| `local`/`development` | Adds localhost:8081 | Adds localhost:8082 + gator snap |
27+
| `production` (default) | Only kernel snap connection | No connections |
28+
29+
30+
## How It Works
31+
32+
1. Each snap has a `snap.manifest.ts` file that defines the manifest using the `defineSnapManifest` helper
33+
2. The shared `generate-snap-manifest` command (provided by `@metamask/7715-permissions-shared`) compiles and executes the TypeScript file to generate `snap.manifest.json`
34+
3. The build/start commands automatically run this generation command
35+
36+
## Available Commands
37+
38+
### From individual snap packages:
39+
```bash
40+
# Generate manifest for current package
41+
yarn generate-snap-manifest .
42+
43+
# Build with manifest generation
44+
yarn build
45+
46+
# Start with manifest generation
47+
yarn start
48+
```
49+
50+
## File Structure
51+
52+
```
53+
packages/
54+
├── shared/
55+
│ └── src/
56+
│ └── scripts/
57+
│ └── generate-manifest.ts # Shared manifest generation script
58+
├── gator-permissions-snap/
59+
│ ├── snap.manifest.ts # TypeScript manifest definition (source of truth)
60+
│ └── snap.manifest.json # Generated from .ts file (git ignored)
61+
└── permissions-kernel-snap/
62+
├── snap.manifest.ts # TypeScript manifest definition (source of truth)
63+
└── snap.manifest.json # Generated from .ts file (git ignored)
64+
```
65+
66+
## Environment Variables
67+
68+
- `SNAP_ENV` - Controls which manifest template to use
69+
- `local` or `development` - Uses dev manifest
70+
- `production` (default) - Uses production manifest
71+
- Any other value - Falls back to production
72+
73+
## CI/CD Example
74+
75+
```yaml
76+
- name: Build for production
77+
env:
78+
SNAP_ENV: production
79+
run: yarn build
80+
```
81+

packages/gator-permissions-snap/docs/architecture.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ This document outlines the architecture of the Permissions Provider Snap system
5151

5252
### UI Components
5353

54-
- **HomePage**: Component that builds the snap's homepage, showing feature introduction, as well as granted permissions. This is only part of the pre-production feature, as the snap will be pre-installed in which case the homepage is not accessible.
5554
- **ConfirmationDialogFactory**: Creates confirmation dialogs for permission requests.
5655
- **ConfirmationDialog**: Manages the lifecycle and user interaction of confirmation dialogs.
5756

@@ -80,7 +79,6 @@ src/
8079
├── services/ # Business logic services (token prices, metadata)
8180
├── clients/ # External API clients (Account API, Price API, blockchain)
8281
├── profileSync/ # Cross-device permission storage synchronization
83-
├── homepage/ # Snap homepage UI component
8482
├── ui/ # Reusable UI components and utilities
8583
├── utils/ # Static utility functions
8684
└── permissions/ # Permission-specific implementations
@@ -103,8 +101,6 @@ src/
103101

104102
- **`profileSync/`**: Manages encrypted storage and synchronization of granted permissions across devices using MetaMask's profile sync infrastructure.
105103

106-
- **`homepage/`**: Class-based component that builds the snap's homepage interface, displaying account information and granted permissions.
107-
108104
- **`ui/`**: Reusable UI components and utilities used across different permission types and dialogs.
109105

110106
- **`utils/`**: Static utility functions for common operations like address formatting, validation, time handling, and value conversion.
@@ -201,7 +197,7 @@ The EntryPoint serves as the main initialization and configuration point for the
201197
- Core services (TokenMetadataService, TokenPricesService, AccountController)
202198
- State management (StateManager for snap persistence)
203199
- Profile sync (ProfileSyncManager for cross-device permission sync)
204-
- UI components (HomePage, ConfirmationDialogFactory, UserEventDispatcher)
200+
- UI components (ConfirmationDialogFactory, UserEventDispatcher)
205201
- Permission handling (PermissionHandlerFactory, PermissionRequestLifecycleOrchestrator)
206202
- RPC handling (createRpcHandler for processing requests)
207203

@@ -212,8 +208,7 @@ The EntryPoint serves as the main initialization and configuration point for the
212208
3. Handling lifecycle events:
213209
- `onRpcRequest`: Processes incoming JSON-RPC requests with origin validation
214210
- `onUserInput`: Handles user input events via UserEventDispatcher
215-
- `onHomePage`: Returns the snap's homepage content
216-
- `onInstall`: Shows welcome screen and handles local development setup
211+
- `onInstall`: Handles local development setup
217212

218213
4. Managing dependencies and configuration:
219214
- Uses dependency injection to create and wire up components

packages/gator-permissions-snap/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727
"scripts": {
2828
"allow-scripts": "yarn workspace root allow-scripts",
29-
"build": "mm-snap build && yarn build:preinstalled-snap",
29+
"build": "yarn generate-snap-manifest . && mm-snap build && yarn build:preinstalled-snap",
3030
"build:clean": "yarn clean && yarn build",
3131
"build:pack": "yarn build:clean && yarn pack --filename ../../deps/snap-b-0.1.0.tgz",
3232
"build:preinstalled-snap": "node scripts/build-preinstalled-snap.js",
@@ -43,7 +43,7 @@
4343
"lint:misc": "prettier '**/*.json' '**/*.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern",
4444
"prepublishOnly": "mm-snap manifest",
4545
"serve": "mm-snap serve",
46-
"start": "mm-snap watch",
46+
"start": "yarn generate-snap-manifest . && mm-snap watch",
4747
"test": "TZ=UTC jest"
4848
},
4949
"dependencies": {

packages/gator-permissions-snap/snap.manifest.json

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
/* eslint-disable no-restricted-globals */
3+
4+
import type { SnapManifest } from '@metamask/7715-permissions-shared/types';
5+
6+
const kernelSnapId = process.env.KERNEL_SNAP_ID;
7+
8+
const manifest: SnapManifest = {
9+
version: '0.2.1',
10+
description: 'Grants 7715 permissions from a DeleGator smart account',
11+
proposedName: 'Gator Permissions',
12+
repository: {
13+
type: 'git',
14+
url: 'https://github.com/MetaMask/snap-7715-permissions.git',
15+
},
16+
source: {
17+
shasum: 'tQRss8KLZ2+OlG2QQyH81XYBcTLsWUzYXf/Xy0cHZsk=',
18+
location: {
19+
npm: {
20+
filePath: 'dist/bundle.js',
21+
iconPath: 'images/icon.svg',
22+
packageName: '@metamask/gator-permissions-snap',
23+
registry: 'https://registry.npmjs.org/',
24+
},
25+
},
26+
},
27+
initialPermissions: {
28+
'endowment:rpc': {
29+
dapps: false,
30+
snaps: true,
31+
},
32+
snap_manageState: {},
33+
'endowment:ethereum-provider': {},
34+
'endowment:network-access': {},
35+
snap_dialog: {},
36+
'endowment:lifecycle-hooks': {},
37+
snap_getPreferences: {},
38+
},
39+
platformVersion: '8.1.0',
40+
manifestVersion: '0.1',
41+
};
42+
43+
if (kernelSnapId) {
44+
manifest.initialConnections = {
45+
[kernelSnapId]: {},
46+
};
47+
}
48+
49+
export default manifest;

0 commit comments

Comments
 (0)