mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
de955f3faa
* snaps-monorepo@0.24.0 * Fix imports and regen LavaMoat policies * Bump iframe-execution-environment * Fix tests * Add permissions * Bump patch * Bump test-snaps * [FLASK] Fix update e2e test to catch snaps with caveats (#16546) * changed snap to update to bip32 * small changes to test * Fix lint * Fix E2E * Update copy * Update icon Co-authored-by: Bowen Sanders <bowensanders@gmail.com>
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
import { flatMap } from '@metamask/snaps-utils';
|
|
import { coinTypeToProtocolName } from '../../../helpers/utils/util';
|
|
|
|
export function getSnapInstallWarnings(permissions, targetSubjectMetadata, t) {
|
|
const bip32EntropyPermissions =
|
|
permissions &&
|
|
Object.entries(permissions)
|
|
.filter(([key]) => key === 'snap_getBip32Entropy')
|
|
.map(([, value]) => value);
|
|
|
|
const bip44EntropyPermissions =
|
|
permissions &&
|
|
Object.entries(permissions)
|
|
.filter(([key]) => key === 'snap_getBip44Entropy')
|
|
.map(([, value]) => value);
|
|
|
|
return [
|
|
...flatMap(bip32EntropyPermissions, (permission, i) =>
|
|
permission.caveats[0].value.map(({ path, curve }) => ({
|
|
id: `key-access-bip32-${path
|
|
.join('-')
|
|
.replace(/'/gu, 'h')}-${curve}-${i}`,
|
|
message: t('snapInstallWarningKeyAccess', [
|
|
targetSubjectMetadata.name,
|
|
`${path.join('/')} (${curve})`,
|
|
]),
|
|
})),
|
|
),
|
|
...flatMap(bip44EntropyPermissions, (permission, i) =>
|
|
permission.caveats[0].value.map(({ coinType }) => ({
|
|
id: `key-access-bip44-${coinType}-${i}`,
|
|
message: t('snapInstallWarningKeyAccess', [
|
|
targetSubjectMetadata.name,
|
|
coinTypeToProtocolName(coinType) ||
|
|
t('unrecognizedProtocol', [coinType]),
|
|
]),
|
|
})),
|
|
),
|
|
];
|
|
}
|