Skip to content

Commit

Permalink
Add interface to change trusted signer (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfornet authored Aug 6, 2021
1 parent fe6ed9e commit 14d8932
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions contracts/near/eth-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use admin_controlled::Mask;
use borsh::{BorshDeserialize, BorshSerialize};
use eth_types::*;
use near_sdk::collections::UnorderedMap;
use near_sdk::AccountId;
use near_sdk::{assert_self, AccountId};
use near_sdk::{env, near_bindgen, PanicOnDefault};

#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -211,8 +211,9 @@ impl EthClient {
let header: BlockHeader = rlp::decode(block_header.as_slice()).unwrap();

if let Some(trusted_signer) = &self.trusted_signer {
assert!(
&env::signer_account_id() == trusted_signer,
assert_eq!(
&env::signer_account_id(),
trusted_signer,
"Eth-client is deployed as trust mode, only trusted_signer can add a new header"
);
} else {
Expand All @@ -229,6 +230,15 @@ impl EthClient {

self.record_header(header);
}

pub fn update_trusted_signer(&mut self, trusted_signer: Option<AccountId>) {
assert_self();
self.trusted_signer = trusted_signer;
}

pub fn get_trusted_signer(&self) -> Option<AccountId> {
self.trusted_signer.clone()
}
}

impl EthClient {
Expand Down
Binary file modified contracts/near/res/eth_client.wasm
Binary file not shown.

0 comments on commit 14d8932

Please sign in to comment.