Skip to content

Commit fc56a67

Browse files
Update subject metadata
1 parent 2c2a96a commit fc56a67

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/snaps-controllers/src/snaps/SnapController.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6861,7 +6861,7 @@ describe('SnapController', () => {
68616861
);
68626862

68636863
expect(snapControllerOptions.messenger.call).toHaveBeenNthCalledWith(
6864-
6,
6864+
7,
68656865
'PermissionController:grantPermissions',
68666866
{
68676867
approvedPermissions: {

packages/snaps-controllers/src/snaps/SnapController.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,32 @@ export class SnapController extends BaseController<
14751475
isNonEmptyArray(Object.keys(newPermissions)) ||
14761476
isNonEmptyArray(Object.keys(unusedPermissions))
14771477
) {
1478+
const { proposedName } = getLocalizedSnapManifest(
1479+
snap.manifest,
1480+
'en',
1481+
snap.localizationFiles ?? [],
1482+
);
1483+
1484+
// Recover the SVG icon from the constructor argument.
1485+
// Theoretically this may be out of date, but this is the best we can do.
1486+
const preinstalledSnap = preinstalledSnaps.find(
1487+
(potentialSnap) => potentialSnap.snapId === snap.id,
1488+
);
1489+
const { iconPath } = snap.manifest.source.location.npm;
1490+
const svgIcon =
1491+
iconPath && preinstalledSnap
1492+
? preinstalledSnap.files.find((file) => file.path === iconPath)
1493+
: undefined;
1494+
1495+
// If the permissions are out of sync, it is possible that the SubjectMetadataController also is.
1496+
this.messenger.call('SubjectMetadataController:addSubjectMetadata', {
1497+
subjectType: SubjectType.Snap,
1498+
name: proposedName,
1499+
origin: snap.id,
1500+
version: snap.version,
1501+
svgIcon: svgIcon ? new VirtualFile(svgIcon).toString() : null,
1502+
});
1503+
14781504
this.#updatePermissions({
14791505
snapId: snap.id,
14801506
newPermissions,

0 commit comments

Comments
 (0)