mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-04-11 21:53:48 +00:00
Merge 9a342732225c3b5c14a4635086f154b2de330f5b into 42a2f04cd52779b109750e86dcd2f5486ec3ec4f
This commit is contained in:
commit
e3c58749d5
@ -126,6 +126,11 @@ pub struct AccountWithMetadata {
|
||||
pub account: Account,
|
||||
pub is_authorized: bool,
|
||||
pub account_id: AccountId,
|
||||
/// The program that owns this account. Programs can use this to verify
|
||||
/// that an input account is owned by themselves, preventing spoofing attacks.
|
||||
/// See: https://github.com/logos-blockchain/logos-execution-zone/issues/347
|
||||
#[serde(default)]
|
||||
pub owner_program_id: Option<crate::program::ProgramId>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "host")]
|
||||
@ -135,8 +140,14 @@ impl AccountWithMetadata {
|
||||
account,
|
||||
is_authorized,
|
||||
account_id: account_id.into(),
|
||||
owner_program_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_owner_program_id(mut self, program_id: crate::program::ProgramId) -> Self {
|
||||
self.owner_program_id = Some(program_id);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
|
||||
@ -112,11 +112,20 @@ impl PublicTransaction {
|
||||
.account_ids
|
||||
.iter()
|
||||
.map(|account_id| {
|
||||
let account = state.get_account_by_id(*account_id);
|
||||
let owner_program_id = account.program_owner;
|
||||
let is_default_owner = owner_program_id == nssa_core::program::DEFAULT_PROGRAM_ID;
|
||||
AccountWithMetadata::new(
|
||||
state.get_account_by_id(*account_id),
|
||||
account,
|
||||
signer_account_ids.contains(account_id),
|
||||
*account_id,
|
||||
)
|
||||
.with_owner_program_id(if is_default_owner {
|
||||
// Uninitialized accounts have no meaningful owner
|
||||
nssa_core::program::DEFAULT_PROGRAM_ID
|
||||
} else {
|
||||
owner_program_id
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user