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

Feat: change private methods to admin methods #676

Merged
merged 5 commits into from
Mar 1, 2023
Merged
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
19 changes: 16 additions & 3 deletions engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ mod contract {
#[no_mangle]
pub extern "C" fn factory_update_address_version() {
let mut io = Runtime;
// The function is only set to be private, otherwise callback error will happen.
io.assert_private_call().sdk_unwrap();
let check_deploy: Result<(), &[u8]> = match io.promise_result_check() {
Some(true) => Ok(()),
Expand Down Expand Up @@ -583,7 +584,11 @@ mod contract {
pub extern "C" fn new_eth_connector() {
let io = Runtime;
// Only the owner can initialize the EthConnector
io.assert_private_call().sdk_unwrap();
let is_private = io.assert_private_call();
if is_private.is_err() {
let state = state::get_state(&io).sdk_unwrap();
require_owner_only(&state, &io.predecessor_account_id());
}

let args: InitCallArgs = io.read_input_borsh().sdk_unwrap();
let owner_id = io.current_account_id();
Expand All @@ -595,7 +600,11 @@ mod contract {
pub extern "C" fn set_eth_connector_contract_data() {
let mut io = Runtime;
// Only the owner can set the EthConnector contract data
io.assert_private_call().sdk_unwrap();
let is_private = io.assert_private_call();
if is_private.is_err() {
let state = state::get_state(&io).sdk_unwrap();
require_owner_only(&state, &io.predecessor_account_id());
}

let args: SetContractDataCallArgs = io.read_input_borsh().sdk_unwrap();
connector::set_contract_data(&mut io, args).sdk_unwrap();
Expand Down Expand Up @@ -872,7 +881,11 @@ mod contract {
#[no_mangle]
pub extern "C" fn set_paused_flags() {
let io = Runtime;
io.assert_private_call().sdk_unwrap();
let is_private = io.assert_private_call();
if is_private.is_err() {
let state = state::get_state(&io).sdk_unwrap();
require_owner_only(&state, &io.predecessor_account_id());
}
let args: PauseEthConnectorCallArgs = io.read_input_borsh().sdk_unwrap();
EthConnectorContract::init_instance(io)
.sdk_unwrap()
Expand Down