Skip to content

Conversation

febo
Copy link

@febo febo commented Apr 2, 2025

Problem

Currently the solana-security-txt is dependent of the std library. When writing no_std programs, it creates a conflict due to the differences in how the panic handler behaves when the std is present:

error[E0152]: found duplicate lang item `panic_impl`
  --> program/src/entrypoint.rs:20:1
   |
20 | pinocchio::nostd_panic_handler!();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the lang item is first defined in crate `std` (which `solana_security_txt` depends on)

Solution

Remove the std dependency. This is achieved by:

  • Replacinfg the use of std::collections::HashMap by hashbrown::HashMap
  • Bump dependencies to use no_std compatible versions
  • Add alloc as an external crate
  • Use Vec and String types from alloc
  • Fix clippy warnings: upercase static variable name (SECURITY_TXT) and implement TryFrom<&str> for Contact

These changes have no impact on the logic of the macro – the result is the same:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants