mirror of
https://github.com/status-im/contracts.git
synced 2025-02-22 11:38:49 +00:00
Migration contract example
This commit is contained in:
parent
c642e4bf94
commit
b499627b38
36
contracts/communication/MessageTributeMigrated.sol
Normal file
36
contracts/communication/MessageTributeMigrated.sol
Normal file
@ -0,0 +1,36 @@
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
import "./MessageTribute.sol";
|
||||
|
||||
/**
|
||||
* @notice Defines migration contract of MessageTribute
|
||||
*/
|
||||
contract MessageTributeMigrated is MessageTribute {
|
||||
mapping(address => bool) private migrated;
|
||||
MessageTribute public previousVersion;
|
||||
|
||||
/**
|
||||
* @notice Defines the previous contract to load unset users
|
||||
* @param _previousVersion Contract to read unset tributes
|
||||
*/
|
||||
constructor(MessageTribute _previousVersion) public {
|
||||
require(address(_previousVersion) != address(0), "Previous version not provided");
|
||||
previousVersion = _previousVersion;
|
||||
}
|
||||
/**
|
||||
* @notice Obtain required tribute to talk with `_of` from `previousVersion` if `_of` never set on this one
|
||||
* @param _of Account to lookup
|
||||
* @return value of tribute
|
||||
*/
|
||||
function getTribute(address _of) external view
|
||||
returns (uint256)
|
||||
{
|
||||
return migrated[_of] ? tributeCatalog[_of] : previousVersion.getTribute(_of);
|
||||
}
|
||||
|
||||
function setTribute(address _of, uint256 _value) internal {
|
||||
migrated[_of] = true;
|
||||
super.setTribute(_of, _value);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user