regolith-labs / ore

ORE is a proof-of-work token everyone can mine.
https://ore.supply
658 stars 225 forks source link

Make a separate API crate #33

Closed kevinheavey closed 2 months ago

kevinheavey commented 5 months ago

I've been meaning to demonstrate what it looks like to have separate crates for a Solana program and its API, and the Ore code is really clean so I chose Ore. Up to you if you wanna merge obviously (if not I'll point people to my fork as a demo), but if you do merge you get the following benefits:

What this PR does:

Btw if you want to regenerate the shank IDL, the command is now shank idl -r crates/api

HardhatChad commented 2 months ago

I like the intent. Would it be cleaner to do this by keeping a single crate and using a feature flag instead?

kevinheavey commented 2 months ago

No, if anything feature flags are overused in the Rust ecosystem. I've been meaning to write a piece about this, but here are some problems with that approach:

Sometimes feature flags are kinda unavoidable, like if you want to optionally derive(Serialize) on a struct. That's not something you can achieve with crate splitting, but it's also not something that affects this PR.

HardhatChad commented 2 months ago

Implemented this pattern for the new v2 build. Closing this now