Skip to content

Commit

Permalink
feat(daemon): GetHardForks RPC method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ez3kiel-dev committed Aug 1, 2024
1 parent 637adb2 commit 46cec04
Show file tree
Hide file tree
Showing 7 changed files with 309 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ JSON-RPC Clients to interact with daemon and wallet API.
- splitAddress
- extractKeyFromAddress
- getMinerWork
- getHardForks

#### Wallet

Expand Down
1 change: 1 addition & 0 deletions lib/src/data_transfer_objects/dtos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export 'get_block_template/get_block_template_result.dart';
export 'get_blocks_at_height/get_blocks_at_height_params.dart';
export 'get_dev_fee_thresholds/get_dev_fee_threshold_result.dart';
export 'get_difficulty/get_difficulty_result.dart';
export 'get_hard_forks/get_hard_forks_result.dart';
export 'get_info/get_info_result.dart';
export 'get_mempool_cache/get_mempool_cache_params.dart';
export 'get_mempool_cache/get_mempool_cache_result.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// ignore_for_file: invalid_annotation_target

import 'package:freezed_annotation/freezed_annotation.dart';

part 'get_hard_forks_result.freezed.dart';

part 'get_hard_forks_result.g.dart';

/// @nodoc
@freezed
class GetHardForksResult with _$GetHardForksResult {
/// @nodoc
const factory GetHardForksResult({
@JsonKey(name: 'height') required int height,
@JsonKey(name: 'version') required int version,
@JsonKey(name: 'changelog') required String changelog,
@JsonKey(name: 'version_requirement') String? versionRequirement,
}) = _GetHardForksResult;

/// @nodoc
factory GetHardForksResult.fromJson(Map<String, dynamic> json) =>
_$GetHardForksResultFromJson(json);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/src/repositories/daemon/daemon_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ enum DaemonMethod implements XelisJsonKey {
extractKeyFromAddress('extract_key_from_address'),

/// Get miner Work
getMinerWork('get_miner_work');
getMinerWork('get_miner_work'),

/// Get hard forks
getHardForks('get_hard_forks');

/// Creates a new [DaemonMethod] instance.
const DaemonMethod(this.jsonKey);
Expand Down
8 changes: 8 additions & 0 deletions lib/src/repositories/daemon/daemon_rpc_methods_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,12 @@ extension DaemonRpcMethodsExtension on DaemonClient {
);
return GetMinerWorkResult.fromJson(result as Map<String, dynamic>);
}

/// Get hard forks
Future<List<GetHardForksResult>> getHardForks() async {
final result = await sendRequest(DaemonMethod.getHardForks);
return (result as List)
.map((e) => GetHardForksResult.fromJson(e as Map<String, dynamic>))
.toList();
}
}

0 comments on commit 46cec04

Please sign in to comment.