{"version":3,"file":"getComputeUnits.cjs","sources":["../../../../src/transactions/getComputeUnits.ts"],"sourcesContent":["import {\n  type BaseTransactionMessage,\n  type Rpc,\n  type SolanaRpcApi,\n  type TransactionMessageWithFeePayer,\n} from \"@solana/kit\";\nimport { estimateComputeUnitLimitFactory } from \"@solana-program/compute-budget\";\nimport { GetComputeUnitsOpts } from \"./types\";\n\nexport type GetComputeUnitsFn = (\n  message: BaseTransactionMessage & TransactionMessageWithFeePayer,\n  opts?: GetComputeUnitsOpts\n) => Promise<number>;\n\nexport const makeGetComputeUnits = (\n  raw: Rpc<SolanaRpcApi>\n): GetComputeUnitsFn => {\n  const estimateFn = estimateComputeUnitLimitFactory({\n    rpc: raw,\n  });\n\n  return async (\n    message,\n    { min = 1_000, bufferPct = 0.1 }: GetComputeUnitsOpts = {}\n  ) => {\n    const rawUnits = await estimateFn(message);\n    const units = Number(rawUnits);\n\n    return Math.max(min, Math.ceil(units * (1 + bufferPct)));\n  };\n};\n"],"names":["estimateComputeUnitLimitFactory"],"mappings":";;;;AAcO,MAAM,mBAAmB,GAAG,CACjC,GAAsB,KACD;IACrB,MAAM,UAAU,GAAGA,6CAA+B,CAAC;AACjD,QAAA,GAAG,EAAE,GAAG;AACT,KAAA,CAAC;AAEF,IAAA,OAAO,OACL,OAAO,EACP,EAAE,GAAG,GAAG,IAAK,EAAE,SAAS,GAAG,GAAG,EAAA,GAA0B,EAAE,KACxD;AACF,QAAA,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;AAC1C,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC;AAE9B,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AAC1D,IAAA,CAAC;AACH;;;;"}