mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-04-12 06:03:08 +00:00
feat: populate owner_program_id in public transaction pre_states
Now AccountWithMetadata.owner_program_id is set from the account's
actual program_owner when building pre_states for execution.
Programs can now reliably check account ownership:
if let Some(owner) = account.owner_program_id {
assert_eq!(owner, SELF_PROGRAM_ID);
}
Refs #347
This commit is contained in:
parent
cc43721cac
commit
9a34273222
@ -109,11 +109,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