{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../src/MultichainAssetsController/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AAEvD,6KAA6K;AAC7K,2DAA2D;AAC3D;;;;;;;;;GASG;AACH,uBAAuB;AACvB,MAAM,UAAU,iBAAiB,CAC/B,UAAiC;IAEjC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CACpC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,QAAQ,CACpB,CAAC;IAE1C,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC","sourcesContent":["import type {\n  Caveat,\n  PermissionConstraint,\n} from '@metamask/permission-controller';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\n\n// TODO: this is a duplicate of https://github.com/MetaMask/snaps/blob/362208e725db18baed550ade99087d44e7b537ed/packages/snaps-rpc-methods/src/endowments/name-lookup.ts#L151\n// To be removed once core has snaps-rpc-methods dependency\n/**\n * Getter function to get the chainIds caveat from a permission.\n *\n * This does basic validation of the caveat, but does not validate the type or\n * value of the namespaces object itself, as this is handled by the\n * `PermissionsController` when the permission is requested.\n *\n * @param permission - The permission to get the `chainIds` caveat from.\n * @returns An array of `chainIds` that the snap supports.\n */\n// istanbul ignore next\nexport function getChainIdsCaveat(\n  permission?: PermissionConstraint,\n): string[] | null {\n  if (!permission?.caveats) {\n    return null;\n  }\n\n  const caveat = permission.caveats.find(\n    (permCaveat) => permCaveat.type === SnapCaveatType.ChainIds,\n  ) as Caveat<string, string[]> | undefined;\n\n  return caveat ? caveat.value : null;\n}\n"]}