I'm trying to integrate Raydium into my program. They have different config for devnet and production address based on a feature flag as below:
#[cfg(feature = "devnet")]
declare_id!("CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW");
#[cfg(not(feature = "devnet"))]
declare_id!("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C");
Now I add the Raydium program as a dependency in my own program:
raydium-cp-swap = { git = "https://github.com/raydium-io/raydium-cp-swap", features = [
"cpi",
"devnet",
] }
AFAIK, the devnet
feature will only be enabled if I manually specify it in the build command, e.g anchor build -- --features "devnet"
, but in reality it's always enabled, whether I specify the flag or not. The only way for it to not be enabled is to remove the "devnet" flag in the dependency, which is very inconvenient. When I try to print the address, in VSCode it shows the devnet is enabled too:
Does anyone here have a solution to this? basically I want the "devnet" flag to only be enabled if I explicitly specify it in the build command. I want to use the program with both devnet/without devnet configurations.