Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions solana/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions solana/modules/wormhole-anchor-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wormhole-anchor-sdk"
version = "0.31.0"
version = "1.0.0"
description = "SDK using Anchor interfaces to interact with Wormhole Solana Programs"
edition = "2021"
authors = ["W7"]
Expand All @@ -9,18 +9,24 @@ homepage = "https://github.com/wormhole-foundation/wormhole-scaffolding"
repository = "https://github.com/wormhole-foundation/wormhole-scaffolding"

[features]
default = ["mainnet"]
mainnet = []
solana-devnet = []
tilt-devnet = []
fogo-testnet = []
bridge-address-from-env = []
token-bridge = []
default = ["chain-id"]
mainnet = ["wormhole-svm-definitions/solana"]
solana-devnet = ["wormhole-svm-definitions/solana", "wormhole-svm-definitions/testnet"]
tilt-devnet = ["wormhole-svm-definitions/solana", "wormhole-svm-definitions/localnet"]
from-env = ["wormhole-svm-definitions/from-env"]
chain-id = ["wormhole-svm-definitions/chain-id"]
token-bridge = ["wormhole-svm-definitions/token-bridge"]
idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]

# for older anchors that don't support the custom discriminator. the IDL will
# not be correct then, but at least it builds
no-custom-discriminator = []

[dependencies]
anchor-lang = { workspace = true }
anchor-spl = { workspace = true }
anchor-lang = { version = "0" }
anchor-spl = { version = "0" }
# NOTE: this is the `main` commit at the time of writing.
wormhole-svm-definitions = { git = "https://github.com/wormhole-foundation/wormhole", rev = "325cca4b628f17536f54b079eeb82b41247bfbef" }
cfg-if = "1.0.0"
wormhole-io = { workspace = true }

Expand Down
1 change: 0 additions & 1 deletion solana/modules/wormhole-anchor-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ pub mod wormhole;
#[cfg(feature = "token-bridge")]
pub mod token_bridge;

#[macro_use]
extern crate cfg_if;
20 changes: 3 additions & 17 deletions solana/modules/wormhole-anchor-sdk/src/token_bridge/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,10 @@ use anchor_lang::prelude::*;
#[derive(Debug, Clone)]
pub struct TokenBridge;

pub static ID: Pubkey = wormhole_svm_definitions::TOKEN_BRIDGE_PROGRAM_ID;

impl Id for TokenBridge {
fn id() -> Pubkey {
use std::str::FromStr;
cfg_if! {
if #[cfg(feature = "mainnet")] {
let pubkey = "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb";
} else if #[cfg(feature = "solana-devnet")] {
let pubkey = "DZnkkTmCiFWfYTfT41X3Rd1kDgozqzxWaHqsw6W4x2oe";
} else if #[cfg(feature = "tilt-devnet")] {
let pubkey = "B6RHG3mfcckmrYN1UhmJzyS1XX3fZKbkeUcpJe9Sy3FE";
} else if #[cfg(feature = "fogo-testnet")] {
let pubkey = "78HdStBqCMioGii9D8mF3zQaWDqDZBQWTUwjjpdmbJKX";
} else if #[cfg(feature = "bridge-address-from-env")]{
let pubkey = env!("TOKEN_BRIDGE_ADDRESS");
} else {
compile_error!("network not specified");
}
};
Pubkey::from_str(pubkey).unwrap()
ID
}
}
8 changes: 4 additions & 4 deletions solana/modules/wormhole-anchor-sdk/src/wormhole/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,22 +273,22 @@ impl<D: AnchorDeserialize + AnchorSerialize> Owner for PostedVaa<D> {
}
}

#[cfg(feature = "idl-build")]
#[cfg(all(feature = "idl-build", not(feature = "no-custom-discriminator")))]
impl Discriminator for BridgeData {
const DISCRIMINATOR: &'static [u8] = &[];
}

#[cfg(feature = "idl-build")]
#[cfg(all(feature = "idl-build", not(feature = "no-custom-discriminator")))]
impl Discriminator for FeeCollector {
const DISCRIMINATOR: &'static [u8] = &[];
}

#[cfg(feature = "idl-build")]
#[cfg(all(feature = "idl-build", not(feature = "no-custom-discriminator")))]
impl Discriminator for SequenceTracker {
const DISCRIMINATOR: &'static [u8] = &[];
}

#[cfg(feature = "idl-build")]
#[cfg(all(feature = "idl-build", not(feature = "no-custom-discriminator")))]
impl<T: AnchorSerialize + AnchorDeserialize> Discriminator for PostedVaa<T> {
const DISCRIMINATOR: &'static [u8] = &[];
}
Expand Down
20 changes: 3 additions & 17 deletions solana/modules/wormhole-anchor-sdk/src/wormhole/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,10 @@ use anchor_lang::prelude::*;
#[derive(Debug, Clone)]
pub struct Wormhole;

pub static ID: Pubkey = wormhole_svm_definitions::CORE_BRIDGE_PROGRAM_ID;

impl Id for Wormhole {
fn id() -> Pubkey {
use std::str::FromStr;
cfg_if! {
if #[cfg(feature = "mainnet")] {
let pubkey = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth";
} else if #[cfg(feature = "solana-devnet")] {
let pubkey = "3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5";
} else if #[cfg(feature = "tilt-devnet")]{
let pubkey = "Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o";
} else if #[cfg(feature = "fogo-testnet")] {
let pubkey = "BhnQyKoQQgpuRTRo6D8Emz93PvXCYfVgHhnrR4T3qhw4";
} else if #[cfg(feature = "bridge-address-from-env")]{
let pubkey = env!("BRIDGE_ADDRESS");
} else {
compile_error!("network not specified");
}
};
Pubkey::from_str(pubkey).unwrap()
ID
}
}