{
  "version": 3,
  "sources": ["../../src/providers/strategies/helpers/signTransactions/helpers/calculateFeeLimit.ts"],
  "sourcesContent": ["import BigNumber from 'bignumber.js';\nimport {\n  EXTRA_GAS_LIMIT_GUARDED_TX,\n  GAS_LIMIT,\n  GAS_PRICE\n} from 'constants/mvx.constants';\nimport { Transaction, Address, TransactionComputer } from 'lib/sdkCore';\nimport { stringIsFloat, stringIsInteger, ZERO } from 'lib/sdkDappUtils';\nimport { isGuardianTx } from 'utils/transactions/isGuardianTx';\n\nexport interface CalculateFeeLimitType {\n  gasLimit: string;\n  gasPrice: string;\n  data: string;\n  gasPerDataByte: string;\n  gasPriceModifier: string;\n  chainId: string;\n  minGasLimit?: string;\n  defaultGasPrice?: string;\n  from: string;\n  to: string;\n}\nexport function calculateFeeLimit({\n  from,\n  to,\n  minGasLimit = String(GAS_LIMIT),\n  gasLimit,\n  gasPrice,\n  data: inputData,\n  gasPerDataByte,\n  gasPriceModifier,\n  defaultGasPrice = String(GAS_PRICE),\n  chainId\n}: CalculateFeeLimitType) {\n  const data = inputData || '';\n  const validGasLimit = stringIsInteger(gasLimit) ? gasLimit : minGasLimit;\n\n  // We need to add extra gas fee for guardian transactions\n  const extraGasLimit = isGuardianTx({ data }) ? EXTRA_GAS_LIMIT_GUARDED_TX : 0;\n  const usedGasLimit = new BigNumber(validGasLimit)\n    .plus(extraGasLimit)\n    .toNumber();\n\n  const validGasPrice = stringIsFloat(gasPrice) ? gasPrice : defaultGasPrice;\n  const transaction = new Transaction({\n    nonce: BigInt(0),\n    value: BigInt(0),\n    receiver: new Address(to),\n    sender: new Address(from),\n    gasPrice: BigInt(validGasPrice),\n    gasLimit: BigInt(usedGasLimit),\n    data: Buffer.from(data.trim()),\n    chainID: chainId,\n    version: 1\n  });\n\n  try {\n    const transactionComputer = new TransactionComputer();\n    const bNfee = transactionComputer.computeTransactionFee(transaction, {\n      gasPerDataByte: BigInt(gasPerDataByte),\n      minGasLimit: BigInt(minGasLimit),\n      gasPriceModifier: parseFloat(gasPriceModifier),\n      chainID: chainId\n    });\n    return bNfee.toString(10);\n  } catch (err) {\n    console.error(err);\n    return ZERO;\n  }\n}\n"],
  "mappings": "8MAAA,OAAOA,MAAe,eAsBf,SAASC,EAAkB,CAChC,KAAAC,EACA,GAAAC,EACA,YAAAC,EAAc,OAAO,GAAS,EAC9B,SAAAC,EACA,SAAAC,EACA,KAAMC,EACN,eAAAC,EACA,iBAAAC,EACA,gBAAAC,EAAkB,OAAO,GAAS,EAClC,QAAAC,CACF,EAA0B,CACxB,IAAMC,EAAOL,GAAa,GACpBM,EAAgBC,EAAgBT,CAAQ,EAAIA,EAAWD,EAGvDW,EAAgBC,EAAa,CAAE,KAAAJ,CAAK,CAAC,EAAI,IAA6B,EACtEK,EAAe,IAAIC,EAAUL,CAAa,EAC7C,KAAKE,CAAa,EAClB,SAAS,EAENI,EAAgBC,EAAcd,CAAQ,EAAIA,EAAWI,EACrDW,EAAc,IAAIC,EAAY,CAClC,MAAO,OAAO,CAAC,EACf,MAAO,OAAO,CAAC,EACf,SAAU,IAAIC,EAAQpB,CAAE,EACxB,OAAQ,IAAIoB,EAAQrB,CAAI,EACxB,SAAU,OAAOiB,CAAa,EAC9B,SAAU,OAAOF,CAAY,EAC7B,KAAM,OAAO,KAAKL,EAAK,KAAK,CAAC,EAC7B,QAASD,EACT,QAAS,CACX,CAAC,EAED,GAAI,CAQF,OAP4B,IAAIa,EAAoB,EAClB,sBAAsBH,EAAa,CACnE,eAAgB,OAAOb,CAAc,EACrC,YAAa,OAAOJ,CAAW,EAC/B,iBAAkB,WAAWK,CAAgB,EAC7C,QAASE,CACX,CAAC,EACY,SAAS,EAAE,CAC1B,OAASc,EAAK,CACZ,eAAQ,MAAMA,CAAG,EACVC,CACT,CACF",
  "names": ["BigNumber", "calculateFeeLimit", "from", "to", "minGasLimit", "gasLimit", "gasPrice", "inputData", "gasPerDataByte", "gasPriceModifier", "defaultGasPrice", "chainId", "data", "validGasLimit", "stringIsInteger", "extraGasLimit", "isGuardianTx", "usedGasLimit", "BigNumber", "validGasPrice", "stringIsFloat", "transaction", "Transaction", "Address", "TransactionComputer", "err", "ZERO"]
}
