call<T> method

Future<T> call<T>(
  1. String method, [
  2. List args = const []
])

Call Ethers provider method with args.

To return the result of excecuting transaction, use Provider.rawCall instead.

Implementation

Future<T> call<T>(String method, [List<dynamic> args = const []]) async {
  try {
    switch (T) {
      case BigInt:
        return (await call<BigNumber>(method, args)).toBigInt as T;
      default:
        return await promiseToFuture<T>(callMethod(impl, method, args));
    }
  } catch (error) {
    final err = dartify(error);
    switch (err['code']) {
      case 4001:
        throw EthereumUserRejected();
      default:
        if (err['message'] != null)
          throw EthereumException(err['code'], err['message'], err['data']);
        else if (err['reason'] != null)
          throw EthersException(
            err['code'],
            err['reason'],
            err as Map<String, dynamic>,
          );
        else
          rethrow;
    }
  }
}