{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB;AACpD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,yBAAyB;AAC1D,OAAO,EAAE,KAAK,EAAE,wBAAwB;AAExC;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,EAAE,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;QAC1E,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,YAAY,GAAG,CAAC,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,mBAAmB;QAC5D,IAAI,OAAO,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;YACnC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { TransactionFactory } from '@ethereumjs/tx';\nimport { bytesToHex, hexToBytes } from '@ethereumjs/util';\nimport { add0x } from '@metamask/utils';\n\n/**\n * Returns the 4-byte selector from raw serialized transaction hex or undefined if not present.\n * Supports legacy RLP and EIP-2718 typed transactions (via `@ethereumjs/tx`).\n *\n * @param rawTxHex - Raw serialized transaction hex (with or without `0x` prefix).\n * @returns The selector (`0x` + 8 hex digits, lowercased) or undefined if parsing fails or no calldata.\n */\nexport function getTransactionSelector(rawTxHex: string): string | undefined {\n  try {\n    const prefixedHex = add0x(rawTxHex);\n    const tx = TransactionFactory.fromSerializedData(hexToBytes(prefixedHex));\n    const dataHex = bytesToHex(tx.data);\n    const selectorSize = 2 /* 0x */ + 4 * 2; /* 4 bytes (hex) */\n    if (dataHex.length >= selectorSize) {\n      return dataHex.slice(0, selectorSize).toLowerCase();\n    }\n  } catch {\n    // ignore parse errors\n  }\n  return undefined;\n}\n"]}