{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../src/middleware/multichain/utils.ts"],"names":[],"mappings":";;;AAIA,mFAAiG;AAKjG;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,KAAwB;IACvD,MAAM,YAAY,GAAG;QACnB,GAAG,KAAK,CAAC,cAAc;QACvB,GAAG,KAAK,CAAC,cAAc;KAC4C,CAAC;IAEtE,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAEpD,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,SAAS,GAAG,KAA+B,CAAC;QAClD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC9D,WAAW,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;QAC3D,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,IAAA,4CAAsB,EAAC,KAAK,EAAE;QACnC,yBAAyB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC;KAC3D,CAAC,CAAC;AACL,CAAC;AAnBD,4CAmBC","sourcesContent":["import type {\n  Caip25CaveatValue,\n  InternalScopeObject,\n} from '@metamask/chain-agnostic-permission';\nimport { getSessionScopes as getMergedSessionScopes } from '@metamask/chain-agnostic-permission';\nimport type { CaipChainId, JsonRpcRequest } from '@metamask/utils';\n\nexport type ScopedJsonRpcRequest = JsonRpcRequest & { scope?: CaipChainId };\n\n/**\n * Get a session scopes value that can be used for simulation, by injecting non-EVM methods into the returned session scopes\n * directly from the caveat.\n *\n * @param value The caveat value.\n * @returns The session scopes.\n */\nexport function getSessionScopes(value: Caip25CaveatValue) {\n  const mergedScopes = {\n    ...value.requiredScopes,\n    ...value.optionalScopes,\n  } as Record<CaipChainId, InternalScopeObject & { methods: string[] }>;\n\n  const nonEvmMethods = Object.keys(mergedScopes).reduce<\n    Record<CaipChainId, string[]>\n  >((accumulator, scope) => {\n    const castScope = scope as CaipChainId | 'wallet';\n    if (!castScope.startsWith('eip155') && castScope !== 'wallet') {\n      accumulator[castScope] = mergedScopes[castScope].methods;\n    }\n    return accumulator;\n  }, {});\n\n  return getMergedSessionScopes(value, {\n    getNonEvmSupportedMethods: (scope) => nonEvmMethods[scope],\n  });\n}\n"]}