Skip to main content

jam_null_authorizer/
lib.rs

1#![cfg_attr(any(target_arch = "riscv32", target_arch = "riscv64"), no_std)]
2
3extern crate alloc;
4use alloc::string::String;
5use jam_pvm_common::{is_authorized::*, *};
6use jam_types::*;
7
8#[allow(dead_code)]
9struct Authorizer;
10jam_pvm_common::declare_authorizer!(Authorizer);
11
12impl jam_pvm_common::Authorizer for Authorizer {
13	fn is_authorized(param: AuthConfig, package: WorkPackage, core_index: CoreIndex) -> AuthTrace {
14		info!(
15			"Null Authorizer, [{core_index}], {} gas, {param} param, {} token",
16			gas(),
17			package.authorization
18		);
19		if package.authorization.0 != param.0 {
20			panic!("Authorization failed")
21		}
22		let m = String::from_utf8_lossy(&package.authorization);
23		alloc::format!("Auth=<{m}>").as_bytes().to_vec().into()
24	}
25}