diff --git a/CHANGELOG.md b/CHANGELOG.md index 621db43c..05b6ba17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.7.2 + +* Minor improvements. + ## 2.7.1 * Nullable topics. diff --git a/lib/src/core/client.dart b/lib/src/core/client.dart index 0ec5d9db..0dfde224 100644 --- a/lib/src/core/client.dart +++ b/lib/src/core/client.dart @@ -49,12 +49,6 @@ class Web3Client { bool printErrors = false; Future makeRPCCall(String function, [List? params]) async { - return await _makeRPCCall(function, params); - } - - // TODO: Remove - @Deprecated('Use the public makeRPCCall') - Future _makeRPCCall(String function, [List? params]) async { try { final data = await _jsonRpc.call(function, params); // ignore: only_throw_errors @@ -101,7 +95,7 @@ class Web3Client { /// Returns the version of the client we're sending requests to. Future getClientVersion() { - return _makeRPCCall('web3_clientVersion'); + return makeRPCCall('web3_clientVersion'); } /// Returns the id of the network the client is currently connected to. @@ -114,27 +108,27 @@ class Web3Client { /// 4: Rinkeby Testnet /// 42: Kovan Testnet Future getNetworkId() { - return _makeRPCCall('net_version').then(int.parse); + return makeRPCCall('net_version').then(int.parse); } Future getChainId() { - return _makeRPCCall('eth_chainId').then(BigInt.parse); + return makeRPCCall('eth_chainId').then(BigInt.parse); } /// Returns true if the node is actively listening for network connections. Future isListeningForNetwork() { - return _makeRPCCall('net_listening'); + return makeRPCCall('net_listening'); } /// Returns the amount of Ethereum nodes currently connected to the client. Future getPeerCount() async { - final hex = await _makeRPCCall('net_peerCount'); + final hex = await makeRPCCall('net_peerCount'); return hexToInt(hex).toInt(); } /// Returns the version of the Ethereum-protocol the client is using. Future getEtherProtocolVersion() async { - final hex = await _makeRPCCall('eth_protocolVersion'); + final hex = await makeRPCCall('eth_protocolVersion'); return hexToInt(hex).toInt(); } @@ -143,7 +137,7 @@ class Web3Client { /// /// If so, progress information is returned via [SyncInformation]. Future getSyncStatus() async { - final data = await _makeRPCCall('eth_syncing'); + final data = await makeRPCCall('eth_syncing'); if (data is Map) { final startingBlock = hexToInt(data['startingBlock'] as String).toInt(); @@ -157,19 +151,18 @@ class Web3Client { } Future coinbaseAddress() async { - final hex = await _makeRPCCall('eth_coinbase'); + final hex = await makeRPCCall('eth_coinbase'); return EthereumAddress.fromHex(hex); } /// Returns true if the connected client is currently mining, false if not. Future isMining() { - return _makeRPCCall('eth_mining'); + return makeRPCCall('eth_mining'); } /// Returns the amount of hashes per second the connected node is mining with. Future getMiningHashrate() { - return _makeRPCCall('eth_hashrate') - .then((s) => hexToInt(s).toInt()); + return makeRPCCall('eth_hashrate').then((s) => hexToInt(s).toInt()); } /// Returns the amount of Ether typically needed to pay for one unit of gas. @@ -177,14 +170,14 @@ class Web3Client { /// Although not strictly defined, this value will typically be a sensible /// amount to use. Future getGasPrice() async { - final data = await _makeRPCCall('eth_gasPrice'); + final data = await makeRPCCall('eth_gasPrice'); return EtherAmount.fromBigInt(EtherUnit.wei, hexToInt(data)); } /// Returns the number of the most recent block on the chain. Future getBlockNumber() { - return _makeRPCCall('eth_blockNumber') + return makeRPCCall('eth_blockNumber') .then((s) => hexToInt(s).toInt()); } @@ -192,7 +185,7 @@ class Web3Client { String blockNumber = 'latest', bool isContainFullObj = true, }) { - return _makeRPCCall>( + return makeRPCCall>( 'eth_getBlockByNumber', [blockNumber, isContainFullObj], ).then((json) => BlockInformation.fromJson(json)); @@ -205,7 +198,7 @@ class Web3Client { Future getBalance(EthereumAddress address, {BlockNum? atBlock}) { final blockParam = _getBlockParam(atBlock); - return _makeRPCCall('eth_getBalance', [address.hex, blockParam]) + return makeRPCCall('eth_getBalance', [address.hex, blockParam]) .then((data) { return EtherAmount.fromBigInt(EtherUnit.wei, hexToInt(data)); }); @@ -224,7 +217,7 @@ class Web3Client { }) { final blockParam = _getBlockParam(atBlock); - return _makeRPCCall('eth_getStorageAt', [ + return makeRPCCall('eth_getStorageAt', [ address.hex, '0x${position.toRadixString(16)}', blockParam, @@ -241,7 +234,7 @@ class Web3Client { }) { final blockParam = _getBlockParam(atBlock); - return _makeRPCCall( + return makeRPCCall( 'eth_getTransactionCount', [address.hex, blockParam], ).then((hex) => hexToInt(hex).toInt()); @@ -252,7 +245,7 @@ class Web3Client { Future getTransactionByHash( String transactionHash, ) async { - final map = await _makeRPCCall?>( + final map = await makeRPCCall?>( 'eth_getTransactionByHash', [transactionHash], ); @@ -262,7 +255,7 @@ class Web3Client { /// Returns an receipt of a transaction based on its hash. Future getTransactionReceipt(String hash) { - return _makeRPCCall?>( + return makeRPCCall?>( 'eth_getTransactionReceipt', [hash], ).then((s) => s != null ? TransactionReceipt.fromMap(s) : null); @@ -273,7 +266,7 @@ class Web3Client { /// This function allows specifying a custom block mined in the past to get /// historical data. By default, [BlockNum.current] will be used. Future getCode(EthereumAddress address, {BlockNum? atBlock}) { - return _makeRPCCall( + return makeRPCCall( 'eth_getCode', [address.hex, _getBlockParam(atBlock)], ).then(hexToBytes); @@ -286,7 +279,7 @@ class Web3Client { /// - https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs Future> getLogs(FilterOptions options) { final filter = _EventFilter(options); - return _makeRPCCall>( + return makeRPCCall>( 'eth_getLogs', [filter._createParamsObject(true)], ).then((logs) { @@ -302,7 +295,7 @@ class Web3Client { }) { final blockParam = _getBlockParam(atBlock); - return _makeRPCCall>( + return makeRPCCall>( 'eth_feeHistory', [blockCount, blockParam, rewardPercentiles], ).then((history) { @@ -361,7 +354,7 @@ class Web3Client { /// included in a mined block, can be used to obtain detailed information /// about the transaction. Future sendRawTransaction(Uint8List signedTransaction) async { - return _makeRPCCall('eth_sendRawTransaction', [ + return makeRPCCall('eth_sendRawTransaction', [ bytesToHex(signedTransaction, include0x: true, padToEvenLength: true), ]); } @@ -436,7 +429,7 @@ class Web3Client { Uint8List? data, @Deprecated('Parameter is ignored') BlockNum? atBlock, }) async { - final amountHex = await _makeRPCCall( + final amountHex = await makeRPCCall( 'eth_estimateGas', [ { @@ -489,7 +482,7 @@ class Web3Client { if (sender != null) 'from': sender.hex, }; - return _makeRPCCall('eth_call', [call, _getBlockParam(atBlock)]); + return makeRPCCall('eth_call', [call, _getBlockParam(atBlock)]); } /// Listens for new blocks that are added to the chain. The stream will emit diff --git a/pubspec.yaml b/pubspec.yaml index eb3d00d4..e8cb7eb9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: web3dart description: Dart library to connect to Ethereum clients. Send transactions and interact with smart contracts! -version: 2.7.1 +version: 2.7.2 homepage: https://pwa.ir repository: https://github.com/xclud/web3dart