simolus3 / web3dart

Ethereum library, written in Dart.
MIT License
442 stars 273 forks source link

g.dart of Erc20 abi have duplicated method name `transfer` #153

Closed benzsuankularb closed 3 years ago

benzsuankularb commented 3 years ago

Erc20.g.dart cause an error because it has 2 transfer methods.

/// Returns a live stream of all Transfer events emitted by this contract.
  Stream<Transfer> transfer({_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) {
    final event = self.event('Transfer');
    final filter = _i1.FilterOptions.events(
        contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock);
    return client.events(filter).map((_i1.FilterEvent result) {
      final decoded = event.decodeResults(result.topics!, result.data!);
      return Transfer(decoded);
    });
  }
/// Moves [amount] tokens from the caller's account to [recipient]. Returns a boolean value indicating whether the operation succeeded. Emits a [Transfer] event.
  Future<String> transfer(_i1.EthereumAddress recipient, BigInt amount,
      {required _i1.Credentials credentials}) async {
    final function = self.function('transfer');
    final params = [recipient, amount];
    final transaction = _i1.Transaction.callContract(
        contract: self, function: function, parameters: params);
    return write(credentials, transaction);
  }
benzsuankularb commented 3 years ago

Suggestion:

Change:lib/src/builder/generator.dart, line: 291 to

..name = '${name.substring(0, 1).toLowerCase()}${name.substring(1)}Event'
simolus3 commented 3 years ago

Thanks for the report, and sorry for this embarrassing issue. I really should have caught that earlier. I've fixed the problem in b666eeb4f355a2757fde67825d90acba1cf1fe8d and added an integration test in 2d4e2f85e3a76f6152a83444aed8bd01741c9b40.

benzsuankularb commented 3 years ago

@simolus3 Nothing embarrassing, And thanks so much for updating the repo.