Skip to content

Commit 6840fc8

Browse files
committed
Merge branch 'main' into feat/account-api-v2
2 parents 2aca66e + fa3178f commit 6840fc8

File tree

7 files changed

+49
-48
lines changed

7 files changed

+49
-48
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const manifest: SnapManifest = {
3333
'endowment:ethereum-provider': {},
3434
'endowment:network-access': {},
3535
snap_dialog: {},
36-
'endowment:lifecycle-hooks': {},
3736
snap_getPreferences: {},
3837
},
3938
platformVersion: '8.1.0',

packages/gator-permissions-snap/src/index.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable no-restricted-globals */
2-
import type { GetSnapsResponse } from '@metamask/7715-permissions-shared/types';
32
import { logger } from '@metamask/7715-permissions-shared/utils';
43
import {
54
AuthType,
@@ -8,7 +7,6 @@ import {
87
UserStorage,
98
} from '@metamask/profile-sync-controller/sdk';
109
import {
11-
type OnInstallHandler,
1210
type Json,
1311
type JsonRpcParams,
1412
type OnRpcRequestHandler,
@@ -230,30 +228,3 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
230228
*/
231229
export const onUserInput: OnUserInputHandler =
232230
userEventDispatcher.createUserInputEventHandler();
233-
234-
export const onInstall: OnInstallHandler = async () => {
235-
/**
236-
* Local Development Only
237-
*
238-
* The message signing snap must be installed and the gator permissions snap must
239-
* have permission to communicate with the message signing snap, or the request is rejected.
240-
*
241-
* Since the message signing snap is preinstalled in production, and has
242-
* initialConnections configured to automatically connect to the gator snap, this is not needed in production.
243-
*/
244-
// eslint-disable-next-line no-restricted-globals
245-
if (snapEnv === 'local' && isStorePermissionsFeatureEnabled) {
246-
const installedSnaps = (await snap.request({
247-
method: 'wallet_getSnaps',
248-
})) as unknown as GetSnapsResponse;
249-
if (!installedSnaps[messageSigningSnapId]) {
250-
logger.debug('Installing local message signing snap');
251-
await snap.request({
252-
method: 'wallet_requestSnaps',
253-
params: {
254-
[messageSigningSnapId]: {},
255-
},
256-
});
257-
}
258-
}
259-
};

packages/permissions-kernel-snap/snap.manifest.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* eslint-disable no-restricted-globals */
22
import type { SnapManifest } from '@metamask/7715-permissions-shared/types';
33

4-
const gatorSnapId = process.env.GATOR_PERMISSIONS_PROVIDER_SNAP_ID;
5-
64
const manifest: SnapManifest = {
75
version: '0.2.0',
86
description: 'Manage onchain 7715 permissions',
@@ -25,16 +23,11 @@ const manifest: SnapManifest = {
2523
initialPermissions: {
2624
'endowment:rpc': {
2725
dapps: true,
28-
snaps: true,
26+
snaps: false,
2927
},
3028
},
3129
platformVersion: '8.1.0',
3230
manifestVersion: '0.1',
3331
};
3432

35-
if (gatorSnapId) {
36-
manifest.initialConnections = {
37-
[gatorSnapId]: {},
38-
};
39-
}
4033
export default manifest;

packages/site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "GATSBY_TELEMETRY_DISABLED=1 gatsby build",
99
"clean": "rimraf public",
1010
"lint": "yarn lint:eslint && yarn lint:misc --check",
11-
"lint:eslint": "npx eslint . --cache --ext js,ts",
11+
"lint:eslint": "yarn eslint . --cache --ext js,ts",
1212
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
1313
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path .gitignore",
1414
"start": "GATSBY_TELEMETRY_DISABLED=1 gatsby develop"

packages/site/src/components/Buttons.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ export const ConnectButton = (
9494
);
9595
};
9696

97+
export const InstallButton = (
98+
props: ComponentProps<typeof Button> & { $isInstalled?: boolean },
99+
) => {
100+
return (
101+
<Button {...props}>
102+
<FlaskFox />
103+
<ButtonText>{props.$isInstalled ? 'Installed' : 'Install'}</ButtonText>
104+
</Button>
105+
);
106+
};
107+
97108
export const CustomMessageButton = (
98109
props: ComponentProps<typeof Button> & { $text?: string },
99110
) => {

packages/site/src/pages/index.tsx

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as chains from 'viem/chains';
1818

1919
import {
2020
ConnectButton,
21+
InstallButton,
2122
InstallFlaskButton,
2223
CustomMessageButton,
2324
Card,
@@ -29,6 +30,11 @@ import {
2930
NativeTokenPeriodicForm,
3031
ERC20TokenPeriodicForm,
3132
} from '../components/permissions';
33+
import {
34+
kernelSnapOrigin,
35+
gatorSnapOrigin,
36+
messageSigningSnapOrigin,
37+
} from '../config';
3238
import {
3339
Container,
3440
Heading,
@@ -41,7 +47,6 @@ import {
4147
ResponseContainer,
4248
CopyButton,
4349
} from '../styles';
44-
import { kernelSnapOrigin, gatorSnapOrigin } from '../config';
4550
import {
4651
useMetaMask,
4752
useMetaMaskContext,
@@ -97,6 +102,8 @@ const Index = () => {
97102
const { isFlask, snapsDetected, installedSnaps, provider } = useMetaMask();
98103
const requestKernelSnap = useRequestSnap(kernelSnapOrigin);
99104
const requestPermissionSnap = useRequestSnap(gatorSnapOrigin);
105+
const requestMessageSigningSnap = useRequestSnap(messageSigningSnapOrigin);
106+
100107
const { delegateAccount } = useDelegateAccount({ chain: selectedChain });
101108
const { bundlerClient, getFeePerGas } = useBundlerClient({
102109
chain: selectedChain,
@@ -124,6 +131,9 @@ const Index = () => {
124131

125132
const isKernelSnapReady = Boolean(installedSnaps[kernelSnapOrigin]);
126133
const isGatorSnapReady = Boolean(installedSnaps[gatorSnapOrigin]);
134+
const isMessageSigningSnapReady = Boolean(
135+
installedSnaps[messageSigningSnapOrigin],
136+
);
127137

128138
const chainId = selectedChain.id;
129139
const [permissionType, setPermissionType] = useState('native-token-stream');
@@ -175,13 +185,13 @@ const Index = () => {
175185
if (!delegateAccount) {
176186
throw new Error('Delegate account not found');
177187
}
178-
188+
179189
// Generate a unique identifier for this redemption request
180190
const requestId = `redeem-${Date.now()}-${Math.random()}`;
181-
191+
182192
// Add this request to pending requests
183193
setPendingPermissionRequests(prev => new Set(prev).add(requestId));
184-
194+
185195
setReceipt(null);
186196
setPermissionResponseError(null);
187197

@@ -267,10 +277,10 @@ const Index = () => {
267277

268278
// Generate a unique identifier for this permission request
269279
const requestId = `${type}-${Date.now()}-${Math.random()}`;
270-
280+
271281
// Add this request to pending requests
272282
setPendingPermissionRequests(prev => new Set(prev).add(requestId));
273-
283+
274284
setPermissionResponse(null);
275285
setReceipt(null);
276286
setPermissionResponseError(null);
@@ -497,6 +507,23 @@ const Index = () => {
497507
/>
498508
)}
499509

510+
<Card
511+
content={{
512+
title: 'Message Signing Snap',
513+
description:
514+
'Set up by installing and authorizing the message signing snap.',
515+
button: (
516+
<InstallButton
517+
onClick={requestMessageSigningSnap}
518+
disabled={!isMetaMaskReady || isMessageSigningSnapReady}
519+
$isInstalled={isMessageSigningSnapReady}
520+
/>
521+
),
522+
}}
523+
fullWidth
524+
disabled={!isMetaMaskReady}
525+
/>
526+
500527
<Card
501528
content={{
502529
title: `${isKernelSnapReady ? 'Reconnect' : 'Connect'}(kernel)`,

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7204,13 +7204,13 @@ __metadata:
72047204
linkType: hard
72057205

72067206
"axios@npm:^1.6.4":
7207-
version: 1.11.0
7208-
resolution: "axios@npm:1.11.0"
7207+
version: 1.12.1
7208+
resolution: "axios@npm:1.12.1"
72097209
dependencies:
72107210
follow-redirects: ^1.15.6
72117211
form-data: ^4.0.4
72127212
proxy-from-env: ^1.1.0
7213-
checksum: 0a33dc600b588bfd3111b198d5985527ed89f722817455d7cdb66c1d055e5f8859cc2bebb7320888957fc8458ebe77d5f83af02af9cd260217c91c4e92b6dfb6
7213+
checksum: 5160cf4e319ecd22de2bc4ad263881b5fb4cea1dfd9b8032ce349609fff041e0434f14e72bf2571b37ea88d1860f3456a95f3f40f2c14e84edfb6e81e5f27c4d
72147214
languageName: node
72157215
linkType: hard
72167216

0 commit comments

Comments
 (0)