FeeInformation.fromJson constructor

FeeInformation.fromJson(
  1. Map json
)

Implementation

factory FeeInformation.fromJson(Map json) {
  return switch (json) {
    {
      'gasLimit': int gasLimit,
      'gasPrice': Map gasPrice,
    } =>
      EvmFeeInformation(
        gasLimit: gasLimit,
        gasPrice: EvmLegacyGasPrice(gasPrice: Amount.fromJson(gasPrice)),
      ),
    {
      'gasLimit': int gasLimit,
      'maxFeePerGas': Map maxFeePerGas,
      'maxPriorityFeePerGas': Map maxPriorityFeePerGas,
    } =>
      EvmFeeInformation(
        gasLimit: gasLimit,
        gasPrice: EvmType2GasPrice(
          maxFeePerGas: Amount.fromJson(maxFeePerGas),
          maxPriorityFeePerGas: Amount.fromJson(maxPriorityFeePerGas),
        ),
      ),
    {
      'feePerByte': Map feePerByte,
      'fee': Map? fee,
    } =>
      UtxoFeeInformation(
        feePerByte: Amount.fromJson(feePerByte),
        fee: fee != null ? Amount.fromJson(fee) : null,
      ),
    {
      'feeLimit': Map feeLimit,
    } =>
      TronFeeInformation(
        feeLimit: Amount.fromJson(feeLimit),
      ),
    _ => throw FormatException('Unknown FeeInformation'),
  };
}