From 2d88dd77951c2c971d7117cb1fc697018ea658fc Mon Sep 17 00:00:00 2001 From: Tochukwu Victor Date: Mon, 30 Mar 2026 15:50:51 -0700 Subject: [PATCH] feat(routing): add immutable RoutingResult class for routing resolution --- .../lib/src/routing/routing_result.dart | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 packages/core-dart/lib/src/routing/routing_result.dart diff --git a/packages/core-dart/lib/src/routing/routing_result.dart b/packages/core-dart/lib/src/routing/routing_result.dart new file mode 100644 index 0000000..1101424 --- /dev/null +++ b/packages/core-dart/lib/src/routing/routing_result.dart @@ -0,0 +1,41 @@ +import 'result.dart'; + +/// Immutable result object returned from routing resolution. +/// +/// Holds the [source] tag indicating how the route was resolved, +/// an optional numeric [id] extracted from the address or memo, +/// and any [warnings] emitted during resolution. +final class RoutingResult { + final RoutingSource source; + final BigInt? id; + final List warnings; + + RoutingResult({ + required this.source, + this.id, + List? warnings, + }) : warnings = List.unmodifiable(warnings ?? const []); + + @override + String toString() => + 'RoutingResult(source: $source, id: $id, warnings: $warnings)'; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is RoutingResult && + source == other.source && + id == other.id && + _listEquals(warnings, other.warnings); + + @override + int get hashCode => Object.hash(source, id, Object.hashAll(warnings)); + + static bool _listEquals(List a, List b) { + if (a.length != b.length) return false; + for (var i = 0; i < a.length; i++) { + if (a[i] != b[i]) return false; + } + return true; + } +} \ No newline at end of file