Forráskód Böngészése

Document AccountState

* Don't use option_env
* Fix 'cargo test' (it was failing on ambiguous module names)
Csongor Kiss 3 éve
szülő
commit
ff15ca3a67

+ 8 - 8
solana/bridge/program/src/accounts.rs

@@ -7,11 +7,11 @@ pub mod posted_vaa;
 pub mod sequence;
 pub mod signature_set;
 
-pub use bridge::*;
-pub use claim::*;
-pub use fee_collector::*;
-pub use guardian_set::*;
-pub use posted_message::*;
-pub use posted_vaa::*;
-pub use sequence::*;
-pub use signature_set::*;
+pub use self::bridge::*;
+pub use self::claim::*;
+pub use self::fee_collector::*;
+pub use self::guardian_set::*;
+pub use self::posted_message::*;
+pub use self::posted_vaa::*;
+pub use self::sequence::*;
+pub use self::signature_set::*;

+ 1 - 4
solana/bridge/program/src/api/governance.rs

@@ -42,10 +42,7 @@ fn verify_governance<'a, T>(vaa: &ClaimableVAA<'a, T>) -> Result<()>
 where
     T: DeserializePayload,
 {
-    let expected_emitter = std::option_env!("EMITTER_ADDRESS").ok_or_else(|| {
-        sol_log("EMITTER_ADDRESS not set at compile-time");
-        ProgramError::UninitializedAccount
-    })?;
+    let expected_emitter = std::env!("EMITTER_ADDRESS");
     let current_emitter = format!(
         "{}",
         Pubkey::new_from_array(vaa.message.meta().emitter_address)

+ 15 - 0
solana/solitaire/program/src/types/accounts.rs

@@ -34,6 +34,21 @@ use crate::{
 /// A short alias for AccountInfo.
 pub type Info<'r> = AccountInfo<'r>;
 
+/// Represents an account's state in terms of initialization, which we use as
+/// preconditions in our instructions.
+///
+/// * An [`Initialized`] account is one that has some data stored in it. If we
+/// (the program) own the account, this means that we had written that data in
+/// the first place. For security reasons, initialisation check should always be
+/// in conjuction with an appropriate ownership check.
+/// * An [`Uninitialized`] account is an account that has no data inside of it.
+/// We may require an account to be [`Uninitialized`] when we want to initialize
+/// it ourselves. Once initialized, an account's size and owner are immutable
+/// (as guaranteed by the Solana runtime), so when we initialize a previously
+/// uninitialized account, we will want to make sure to assign the right size
+/// and owner.
+/// * A [`MaybeInitialized`] account can be in either state. The instruction can
+/// then query the state of the account and decide on a next step based on it.
 #[derive(Debug, Eq, PartialEq)]
 pub enum AccountState {
     Initialized,