mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
d6f58bceb0
* allow SnapController to call `ApprovalController:updateRequestState` action * combine popups * show only autorship pill on result * lint * update `snaps-monorepo@0.31.0` and regen policies * dedupe deps and fix fencing * fix update button text * fix fencing * Update a bunch of e2es * address requested changes * update policy * bump key-tree * fix lint * Update RPC E2E * fix locales * Remove wrong instance of window handle polling * design changes and address pr comments * remove unused imports * fix lint * fix fencing * remove unused locales * fence things * re-add redirection * bump test-snaps version * Fix update e2e * fix redirecting logic and address requested changes * force update metamask state on approved * move force update --------- Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
import React from 'react';
|
|
import { Text } from '../../../components/component-library';
|
|
import {
|
|
Color,
|
|
FONT_WEIGHT,
|
|
TextVariant,
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
import {
|
|
coinTypeToProtocolName,
|
|
getSnapName,
|
|
getSnapDerivationPathName,
|
|
} 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 [
|
|
...bip32EntropyPermissions.flatMap((permission, i) =>
|
|
permission.caveats[0].value.map(({ path, curve }) => ({
|
|
id: `key-access-bip32-${path
|
|
.join('-')
|
|
.replace(/'/gu, 'h')}-${curve}-${i}`,
|
|
message: t('snapInstallWarningKeyAccess', [
|
|
<Text
|
|
key="1"
|
|
color={Color.primaryDefault}
|
|
fontWeight={FONT_WEIGHT.BOLD}
|
|
variant={TextVariant.bodySm}
|
|
as="span"
|
|
>
|
|
{getSnapName(targetSubjectMetadata.origin)}
|
|
</Text>,
|
|
<b key="2">
|
|
{getSnapDerivationPathName(path, curve) ??
|
|
`${path.join('/')} (${curve})`}
|
|
</b>,
|
|
]),
|
|
})),
|
|
),
|
|
...bip44EntropyPermissions.flatMap((permission, i) =>
|
|
permission.caveats[0].value.map(({ coinType }) => ({
|
|
id: `key-access-bip44-${coinType}-${i}`,
|
|
message: t('snapInstallWarningKeyAccess', [
|
|
<Text
|
|
key="1"
|
|
color={Color.primaryDefault}
|
|
fontWeight={FONT_WEIGHT.BOLD}
|
|
variant={TextVariant.bodySm}
|
|
as="span"
|
|
>
|
|
{getSnapName(targetSubjectMetadata.origin)}
|
|
</Text>,
|
|
<b key="2">
|
|
{coinTypeToProtocolName(coinType) ||
|
|
t('unrecognizedProtocol', [coinType])}
|
|
</b>,
|
|
]),
|
|
})),
|
|
),
|
|
];
|
|
}
|