Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use owner account in engine authorizer #736

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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