From f6e4f38cceedae2ed28221d09eef4444605539ed Mon Sep 17 00:00:00 2001 From: mzxyz <8177474+mzxyz@users.noreply.github.com> Date: Fri, 18 Aug 2023 08:58:21 +1200 Subject: [PATCH] Enable VSQToken and Settings to be upgradeable (#227) --- contracts/Settings.sol | 6 ++---- contracts/VSQToken.sol | 12 +++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/contracts/Settings.sol b/contracts/Settings.sol index 0bf8cd3e..33371dd1 100644 --- a/contracts/Settings.sol +++ b/contracts/Settings.sol @@ -3,12 +3,12 @@ pragma solidity 0.8.15; -import '@openzeppelin/contracts/access/Ownable.sol'; +import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import './interfaces/ISettings.sol'; import './Constants.sol'; -contract Settings is ISettings, Ownable, Constants { +contract Settings is ISettings, OwnableUpgradeable, Constants { address public sqToken; address public staking; address public stakingManager; @@ -28,8 +28,6 @@ contract Settings is ISettings, Ownable, Constants { address public stateChannel; address public consumerRegistry; - constructor() Ownable() {} - function setProjectAddresses( address _indexerRegistry, address _queryRegistry, diff --git a/contracts/VSQToken.sol b/contracts/VSQToken.sol index 18ccbc91..18538f70 100644 --- a/contracts/VSQToken.sol +++ b/contracts/VSQToken.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.15; +import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; @@ -10,7 +11,7 @@ import './interfaces/ISettings.sol'; import './interfaces/IStaking.sol'; import './interfaces/IVesting.sol'; -contract VSQToken is Initializable { +contract VSQToken is Initializable, OwnableUpgradeable { string private _name = 'VotingSubQueryToken'; string private _symbol = 'VSQT'; uint8 private _decimals = 18; @@ -20,6 +21,15 @@ contract VSQToken is Initializable { settings = _settings; } + /** + * @notice Update setting state. + * @param _settings ISettings contract + */ + function setSettings(ISettings _settings) external onlyOwner { + settings = _settings; + } + + function name() public view returns (string memory) { return _name; }