Skip to content

Commit

Permalink
chore: use owner account in engine authorizer (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss authored Apr 3, 2023
1 parent 4d04777 commit 9e672bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,11 +1025,11 @@ pub fn compute_block_hash(chain_id: [u8; 32], block_height: u64, account_id: &[u
}

#[must_use]
pub fn get_authorizer() -> EngineAuthorizer {
// TODO: a temporary account until the engine adapts std with near-plugins
let account = AccountId::new("aurora").expect("Failed to parse account from string");

EngineAuthorizer::from_accounts(once(account))
pub fn get_authorizer<I: IO>(io: &I) -> EngineAuthorizer {
// TODO: a temporary use the owner account only until the engine adapts std with near-plugins
state::get_state(io)
.map(|state| EngineAuthorizer::from_accounts(once(state.owner_id)))
.unwrap_or_default()
}

pub fn refund_unused_gas<I: IO>(
Expand Down
2 changes: 1 addition & 1 deletion engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ mod contract {
#[no_mangle]
pub extern "C" fn pause_precompiles() {
let io = Runtime;
let authorizer: pausables::EngineAuthorizer = engine::get_authorizer();
let authorizer: pausables::EngineAuthorizer = engine::get_authorizer(&io);

if !authorizer.is_authorized(&io.predecessor_account_id()) {
sdk::panic_utf8(b"ERR_UNAUTHORIZED");
Expand Down

0 comments on commit 9e672bc

Please sign in to comment.