From f119b77d64858636d8020b066c0e4ceca26463b3 Mon Sep 17 00:00:00 2001 From: gabaldon Date: Mon, 26 May 2025 11:58:43 +0200 Subject: [PATCH 1/2] feat: add `stakingPriority` method --- CHANGELOG.md | 3 +++ lib/src/network/explorer/explorer_client.dart | 11 +++++++++++ pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eabb985..3e70700 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.5.0 +- Add `stakingPriority` method + ## 0.4.5 - Create `StakeRewardsInfo` diff --git a/lib/src/network/explorer/explorer_client.dart b/lib/src/network/explorer/explorer_client.dart index fbac234..d5ea96e 100644 --- a/lib/src/network/explorer/explorer_client.dart +++ b/lib/src/network/explorer/explorer_client.dart @@ -714,4 +714,15 @@ class ExplorerClient { code: e.code, message: '{"priority": "${e.message}"}'); } } + + Future stakingPriority() async { + try { + return PrioritiesEstimate.fromJson( + await client.get(api('transaction/priority', {"key": "st"}))); + } on ExplorerException catch (e) { + print(e); + throw ExplorerException( + code: e.code, message: '{"priority": "${e.message}"}'); + } + } } diff --git a/pubspec.yaml b/pubspec.yaml index 22ba063..e0589c1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: A library to interface with the Witnet Protocol. - communicate with a rust node or wallet server - communicate with the explorer -version: 0.4.5 +version: 0.5.0 homepage: https://github.com/witnet/witnet.dart repository: https://github.com/witnet/witnet.dart From 2aa342ab68e45cb5bfb7168bd39a2d3d9c9ce94a Mon Sep 17 00:00:00 2001 From: gabaldon Date: Mon, 26 May 2025 12:31:08 +0200 Subject: [PATCH 2/2] fix: adjust to match explorer --- lib/src/network/explorer/explorer_api.dart | 60 +++++++------------ lib/src/network/explorer/explorer_client.dart | 10 ++-- 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/lib/src/network/explorer/explorer_api.dart b/lib/src/network/explorer/explorer_api.dart index 32cd7c2..cf2b283 100644 --- a/lib/src/network/explorer/explorer_api.dart +++ b/lib/src/network/explorer/explorer_api.dart @@ -2672,28 +2672,18 @@ class HashInfo { class PrioritiesEstimate { PrioritiesEstimate({ - // required this.drtStinky, - // required this.drtLow, - // required this.drtMedium, - // required this.drtHigh, - // required this.drtOpulent, - required this.vttStinky, - required this.vttLow, - required this.vttMedium, - required this.vttHigh, - required this.vttOpulent, + required this.stinky, + required this.low, + required this.medium, + required this.high, + required this.opulent, }); - // final PriorityEstimate drtStinky; - // final PriorityEstimate drtLow; - // final PriorityEstimate drtMedium; - // final PriorityEstimate drtHigh; - // final PriorityEstimate drtOpulent; - final PriorityEstimate vttStinky; - final PriorityEstimate vttLow; - final PriorityEstimate vttMedium; - final PriorityEstimate vttHigh; - final PriorityEstimate vttOpulent; + final PriorityEstimate stinky; + final PriorityEstimate low; + final PriorityEstimate medium; + final PriorityEstimate high; + final PriorityEstimate opulent; factory PrioritiesEstimate.fromRawJson(String str) => PrioritiesEstimate.fromJson(json.decode(str)); @@ -2702,29 +2692,19 @@ class PrioritiesEstimate { factory PrioritiesEstimate.fromJson(Map json) { return PrioritiesEstimate( - // drtStinky: PriorityEstimate.fromJson(json["drt_stinky"]), - // drtLow: PriorityEstimate.fromJson(json["drt_low"]), - // drtMedium: PriorityEstimate.fromJson(json["drt_medium"]), - // drtHigh: PriorityEstimate.fromJson(json["drt_high"]), - // drtOpulent: PriorityEstimate.fromJson(json["drt_opulent"]), - vttStinky: PriorityEstimate.fromJson(json["vtt_stinky"]), - vttLow: PriorityEstimate.fromJson(json["vtt_low"]), - vttMedium: PriorityEstimate.fromJson(json["vtt_medium"]), - vttHigh: PriorityEstimate.fromJson(json["vtt_high"]), - vttOpulent: PriorityEstimate.fromJson(json["vtt_opulent"])); + stinky: PriorityEstimate.fromJson(json["stinky"]), + low: PriorityEstimate.fromJson(json["low"]), + medium: PriorityEstimate.fromJson(json["medium"]), + high: PriorityEstimate.fromJson(json["high"]), + opulent: PriorityEstimate.fromJson(json["opulent"])); } Map jsonMap() => { - // "drt_stinky": drtStinky, - // "drt_low": drtLow, - // "drt_medium": drtMedium, - // "drt_high": drtHigh, - // "drt_opulent": drtOpulent, - "vtt_stinky": vttStinky, - "vtt_low": vttLow, - "vtt_medium": vttMedium, - "vtt_high": vttHigh, - "vtt_opulent": vttOpulent, + "stinky": stinky, + "low": low, + "medium": medium, + "high": high, + "opulent": opulent, }; } diff --git a/lib/src/network/explorer/explorer_client.dart b/lib/src/network/explorer/explorer_client.dart index d5ea96e..745ca83 100644 --- a/lib/src/network/explorer/explorer_client.dart +++ b/lib/src/network/explorer/explorer_client.dart @@ -706,8 +706,9 @@ class ExplorerClient { Future valueTransferPriority() async { try { - return PrioritiesEstimate.fromJson( - await client.get(api('transaction/priority', {"key": "vtt"}))); + final result = + await client.get(api('transaction/priority', {"key": "vtt"})); + return PrioritiesEstimate.fromJson(result['vtt']); } on ExplorerException catch (e) { print(e); throw ExplorerException( @@ -717,8 +718,9 @@ class ExplorerClient { Future stakingPriority() async { try { - return PrioritiesEstimate.fromJson( - await client.get(api('transaction/priority', {"key": "st"}))); + final result = + await client.get(api('transaction/priority', {"key": "st"})); + return PrioritiesEstimate.fromJson(result['st']); } on ExplorerException catch (e) { print(e); throw ExplorerException(