copyWithFee<T extends FeeInformation> method

TransferIntent<T> copyWithFee<T extends FeeInformation>(
  1. T feeInfo, {
  2. Amount? balance,
})

Copy the transfer intent with a new fee If balance is provided, the target amount will be recalculated

Implementation

TransferIntent<T> copyWithFee<T extends FeeInformation>(
  T feeInfo, {
  Amount? balance,
}) {
  final newTargetValue = switch ((balance, feeInfo)) {
    (Amount balance, EvmFeeInformation info)
        when token.isERC20 == false && info.maxFee != null =>
      _calcTargetAmount(balance, info.maxFee!),
    (Amount balance, TronFeeInformation info) when token.isERC20 == false =>
      _calcTargetAmount(balance, info.feeLimit),
    _ => amount,
  };

  return TransferIntent(
    recipient: recipient,
    amount: newTargetValue,
    feeInfo: feeInfo,
    token: token,
    memo: memo,
    accessList: accessList,
  );
}