TokenAmount.fromToken constructor

TokenAmount.fromToken(
  1. dynamic amount,
  2. TokenDetails token
)

Implementation

TokenAmount.fromToken(dynamic amount, TokenDetails token) {
  BigInt parsedAmount;
  if (amount is BigInt) {
    parsedAmount = amount;
  } else if (amount is int) {
    parsedAmount = BigInt.from(amount);
  } else if (amount is String) {
    parsedAmount = BigInt.parse(amount);
  } else {
    throw ArgumentError('Invalid type, must be BigInt, string or int');
  }

  this.value = parsedAmount;
  this.token = token;
}