xclud / web3dart

Ethereum library, written in Dart.
https://pub.dev/packages/web3dart
MIT License
171 stars 94 forks source link

hexToInt raises exception on null string or "0x". #31

Open aegisdino opened 2 years ago

aegisdino commented 2 years ago

When hex string is null string or 0x hexToInt raises exception. So, hexToInt should be changed like the following.

///Takes the hexadecimal input and creates a [BigInt].
BigInt hexToInt(String hex) {
  if (hex == '' || hex == '0x') return BigInt.from(0);
  return BigInt.parse(strip0x(hex), radix: 16);
}
TheGreatAxios commented 2 years ago

@aegisdino Please create a PR