Use procedural macro to generate static public keys (#7219)

automerge
This commit is contained in:
Justin Starry
2019-12-03 20:55:18 -05:00
committed by Grimes
parent a66a49d384
commit 7cfff75c3e
13 changed files with 384 additions and 231 deletions

View File

@@ -1,3 +1,6 @@
// Allows macro expansion of `use ::solana_sdk::*` to work within this crate
extern crate self as solana_sdk;
pub mod account;
pub mod account_utils;
pub mod bpf_loader;
@@ -24,6 +27,29 @@ pub mod system_program;
pub mod sysvar;
pub mod timing;
/// Convenience macro to declare a static public key and functions to interact with it
///
/// Input: a single literal base58 string representation of a program's id
///
/// # Example
///
/// ```
/// # // wrapper is used so that the macro invocation occurs in the item position
/// # // rather than in the statement position which isn't allowed.
/// use std::str::FromStr;
/// use solana_sdk::{declare_id, pubkey::Pubkey};
///
/// # mod item_wrapper {
/// # use solana_sdk::declare_id;
/// declare_id!("My11111111111111111111111111111111111111111");
/// # }
/// # use item_wrapper::id;
///
/// let my_id = Pubkey::from_str("My11111111111111111111111111111111111111111").unwrap();
/// assert_eq!(id(), my_id);
/// ```
pub use solana_sdk_macro::declare_id;
// On-chain program specific modules
pub mod account_info;
pub mod entrypoint;
@@ -52,5 +78,4 @@ pub mod transport;
#[macro_use]
extern crate serde_derive;
pub extern crate bs58;
pub extern crate lazy_static;
extern crate log as logger;