@@ -619,4 +619,54 @@ impl Hypermap {
619
619
. collect :: < Vec < _ > > ( ) ,
620
620
)
621
621
}
622
+
623
+ /// Gets the list of delegate addresses stored via the standard Hypermap access control pattern.
624
+ /// This involves reading the `~access-list` note for the given `entry_path` to find the
625
+ /// namehash of the permissions note, then reading that permissions note to get the
626
+ /// ABI-encoded `Vec<Address>` of delegates.
627
+ ///
628
+ /// # Arguments
629
+ /// * `entry_path` - The base hypermap path (e.g., "myname.hypr") for which to find delegates.
630
+ ///
631
+ /// # Returns
632
+ /// A `Result<Vec<Address>, EthError>` containing the list of delegate addresses if found
633
+ /// and decoded successfully, or an error otherwise.
634
+ pub fn get_access_list_delegates ( & self , entry_path : & str ) -> Result < Vec < Address > , EthError > {
635
+ // 1. Construct the path to the ~access-list note
636
+ let access_list_path = format ! ( "~access-list.{}" , entry_path) ;
637
+
638
+ // 2. Get the ~access-list note data (expecting a B256 namehash)
639
+ let ( _tba, _owner, access_list_data_opt) = self . get ( & access_list_path) ?;
640
+
641
+ let access_list_data = access_list_data_opt. ok_or_else ( || {
642
+ // Note not found or has no data - considered a malformed/unexpected response
643
+ EthError :: RpcMalformedResponse
644
+ } ) ?;
645
+
646
+ // 3. Decode the data as the permissions note hash (B256)
647
+ // We expect the raw bytes stored in the note to be exactly 32 bytes.
648
+ if access_list_data. len ( ) != 32 {
649
+ // Invalid data length - malformed response
650
+ return Err ( EthError :: RpcMalformedResponse ) ;
651
+ }
652
+ let perms_note_hash = B256 :: from_slice ( access_list_data. as_ref ( ) ) ;
653
+ let perms_note_hash_str = format ! ( "0x{}" , hex:: encode( perms_note_hash) ) ;
654
+
655
+ // 4. Get the permissions note using the hash
656
+ let ( _perms_tba, _perms_owner, perms_data_opt) =
657
+ self . get_hash ( & perms_note_hash_str) ?;
658
+
659
+ let perms_data = perms_data_opt. ok_or_else ( || {
660
+ // Permissions note not found or has no data - malformed/unexpected response
661
+ EthError :: RpcMalformedResponse
662
+ } ) ?;
663
+
664
+ // 5. Decode the permissions data as Vec<Address>
665
+ let delegates = Vec :: < Address > :: abi_decode ( & perms_data, true ) . map_err ( |_e| {
666
+ // Failed to decode Vec<Address> - malformed response
667
+ EthError :: RpcMalformedResponse
668
+ } ) ?;
669
+
670
+ Ok ( delegates)
671
+ }
622
672
}
0 commit comments