Skip to content

Commit

Permalink
solana: make network flags mutually exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
kcsongor committed Feb 26, 2024
1 parent 1516fc7 commit f78b859
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ yargs(hideBin(process.argv))
const objectFile = "example_native_token_transfers.so";
const programId = "nttiK1SepaQt6sZ4WGW5whvc9tEnGXGxuKeptcQPCcS";
assertNetwork(network);
await $`cargo build-sbf --manifest-path=${dir}/Cargo.toml --features "${cargoNetworkFeature(network)}"`
await $`cargo build-sbf --manifest-path=${dir}/Cargo.toml --no-default-features --features "${cargoNetworkFeature(network)}"`
await $`solana program deploy --program-id ${programId} ${dir}/target/deploy/${objectFile} --keypair ${keypair} -u ${solanaMoniker(network)}`
})
.demandCommand()
Expand Down
11 changes: 11 additions & 0 deletions solana/programs/example-native-token-transfers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
use anchor_lang::prelude::*;

// TODO: is there a more elegant way of checking that these 3 features are mutually exclusive?

#[cfg(all(feature = "mainnet", feature = "solana-devnet"))]
compile_error!("Cannot enable both mainnet and solana-devnet features at the same time");

#[cfg(all(feature = "mainnet", feature = "tilt-devnet"))]
compile_error!("Cannot enable both mainnet and tilt-devnet features at the same time");

#[cfg(all(feature = "solana-devnet", feature = "tilt-devnet"))]
compile_error!("Cannot enable both solana-devnet and tilt-devnet features at the same time");

pub mod bitmap;
pub mod clock;
pub mod config;
Expand Down

0 comments on commit f78b859

Please sign in to comment.