You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.3 KiB
38 lines
1.3 KiB
import { flatMap } from '@metamask/snap-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('/')}-${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]),
|
|
]),
|
|
})),
|
|
),
|
|
];
|
|
}
|
|
|