-
Notifications
You must be signed in to change notification settings - Fork 0
/
SignerStorage.sol
39 lines (28 loc) · 1.2 KB
/
SignerStorage.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../interfaces/core/ISignerAddress.sol";
import "../core/SignerOwnable.sol";
// SignerStorage is the simple collective signer address storage contract.
// This is used on sidechains only. Mainchain uses DKG contract instead.
contract SignerStorage is Initializable, ISignerAddress, SignerOwnable {
address private signer;
event SignerUpdated(address signer);
function initialize(address _signer) external initializer {
_setSignerGetter(address(this));
signer = _signer;
}
// setAddress updates signer address
function setAddress(address _newSigner) public payable onlySigner {
signer = _newSigner;
uint256 _value = msg.value;
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = _newSigner.call{value: _value, gas: 21000}("");
require(success, "SignerStorage: transfer value failed");
emit SignerUpdated(_newSigner);
}
// getSignerAddress implements ISignerAddress interface
function getSignerAddress() public view returns (address) {
return signer;
}
}