mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-03-03 11:30:43 +00:00
rename BackupOwner -> FundsOwner and add event for it
This commit is contained in:
parent
ee89f3da98
commit
a659db086d
@ -20,6 +20,7 @@ contract ENSSubdomainRegistry is Controlled {
|
|||||||
mapping (bytes32 => Domain) public domains;
|
mapping (bytes32 => Domain) public domains;
|
||||||
mapping (bytes32 => Account) public accounts;
|
mapping (bytes32 => Account) public accounts;
|
||||||
|
|
||||||
|
event FundsOwner(bytes32 indexed subdomainhash, address fundsOwner);
|
||||||
event DomainPrice(bytes32 indexed namehash, uint256 price);
|
event DomainPrice(bytes32 indexed namehash, uint256 price);
|
||||||
event DomainMoved(bytes32 indexed namehash, address newRegistry);
|
event DomainMoved(bytes32 indexed namehash, address newRegistry);
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ contract ENSSubdomainRegistry is Controlled {
|
|||||||
struct Account {
|
struct Account {
|
||||||
uint256 tokenBalance;
|
uint256 tokenBalance;
|
||||||
uint256 creationTime;
|
uint256 creationTime;
|
||||||
address backupOwner;
|
address fundsOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,7 +134,7 @@ contract ENSSubdomainRegistry is Controlled {
|
|||||||
ens.setResolver(subdomainHash, address(0));
|
ens.setResolver(subdomainHash, address(0));
|
||||||
ens.setOwner(subdomainHash, address(0));
|
ens.setOwner(subdomainHash, address(0));
|
||||||
} else {
|
} else {
|
||||||
require(msg.sender == account.backupOwner);
|
require(msg.sender == account.fundsOwner);
|
||||||
}
|
}
|
||||||
delete accounts[subdomainHash];
|
delete accounts[subdomainHash];
|
||||||
if (account.tokenBalance > 0) {
|
if (account.tokenBalance > 0) {
|
||||||
@ -201,11 +202,11 @@ contract ENSSubdomainRegistry is Controlled {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notice updates backup owner useful in case of opt-out domain move to new registry.
|
* @notice updates funds owner useful to move subdomain account to new registry.
|
||||||
* @param _userHash `msg.sender` owned subdomain hash
|
* @param _userHash `msg.sender` owned subdomain hash
|
||||||
* @param _domainHash choosen contract owned domain hash
|
* @param _domainHash choosen contract owned domain hash
|
||||||
**/
|
**/
|
||||||
function updateBackupOwner(
|
function updateFundsOwner(
|
||||||
bytes32 _userHash,
|
bytes32 _userHash,
|
||||||
bytes32 _domainHash
|
bytes32 _domainHash
|
||||||
)
|
)
|
||||||
@ -215,7 +216,9 @@ contract ENSSubdomainRegistry is Controlled {
|
|||||||
require(accounts[subdomainHash].creationTime > 0);
|
require(accounts[subdomainHash].creationTime > 0);
|
||||||
require(msg.sender == ens.owner(subdomainHash));
|
require(msg.sender == ens.owner(subdomainHash));
|
||||||
require(ens.owner(_domainHash) == address(this));
|
require(ens.owner(_domainHash) == address(this));
|
||||||
accounts[subdomainHash].backupOwner = msg.sender;
|
accounts[subdomainHash].fundsOwner = msg.sender;
|
||||||
|
emit FundsOwner(subdomainHash, msg.sender);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,11 +250,11 @@ contract ENSSubdomainRegistry is Controlled {
|
|||||||
require(ens.owner(_domainHash) == address(_newRegistry));
|
require(ens.owner(_domainHash) == address(_newRegistry));
|
||||||
require(address(this) == _newRegistry.parentRegistry());
|
require(address(this) == _newRegistry.parentRegistry());
|
||||||
bytes32 subdomainHash = keccak256(_domainHash, _userHash);
|
bytes32 subdomainHash = keccak256(_domainHash, _userHash);
|
||||||
require(msg.sender == accounts[subdomainHash].backupOwner);
|
require(msg.sender == accounts[subdomainHash].fundsOwner);
|
||||||
Account memory account = accounts[subdomainHash];
|
Account memory account = accounts[subdomainHash];
|
||||||
delete accounts[subdomainHash];
|
delete accounts[subdomainHash];
|
||||||
token.approve(_newRegistry, account.tokenBalance);
|
token.approve(_newRegistry, account.tokenBalance);
|
||||||
_newRegistry.migrateAccount(_userHash, _domainHash, account.tokenBalance, account.creationTime, account.backupOwner);
|
_newRegistry.migrateAccount(_userHash, _domainHash, account.tokenBalance, account.creationTime, account.fundsOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,20 +277,20 @@ contract ENSSubdomainRegistry is Controlled {
|
|||||||
* @param _domainHash choosen contract owned domain hash
|
* @param _domainHash choosen contract owned domain hash
|
||||||
* @param _tokenBalance amount being transferred
|
* @param _tokenBalance amount being transferred
|
||||||
* @param _creationTime any value coming from parent
|
* @param _creationTime any value coming from parent
|
||||||
* @param _backupOwner backupOwner for opt-out/release at domain move
|
* @param _fundsOwner fundsOwner for opt-out/release at domain move
|
||||||
**/
|
**/
|
||||||
function migrateAccount(
|
function migrateAccount(
|
||||||
bytes32 _userHash,
|
bytes32 _userHash,
|
||||||
bytes32 _domainHash,
|
bytes32 _domainHash,
|
||||||
uint256 _tokenBalance,
|
uint256 _tokenBalance,
|
||||||
uint256 _creationTime,
|
uint256 _creationTime,
|
||||||
address _backupOwner
|
address _fundsOwner
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
{
|
{
|
||||||
require(msg.sender == parentRegistry);
|
require(msg.sender == parentRegistry);
|
||||||
bytes32 subdomainHash = keccak256(_domainHash, _userHash);
|
bytes32 subdomainHash = keccak256(_domainHash, _userHash);
|
||||||
accounts[subdomainHash] = Account(_tokenBalance, _creationTime, _backupOwner);
|
accounts[subdomainHash] = Account(_tokenBalance, _creationTime, _fundsOwner);
|
||||||
if (_tokenBalance > 0) {
|
if (_tokenBalance > 0) {
|
||||||
require(token.transferFrom(parentRegistry, address(this), _tokenBalance));
|
require(token.transferFrom(parentRegistry, address(this), _tokenBalance));
|
||||||
}
|
}
|
||||||
@ -310,12 +313,12 @@ contract ENSSubdomainRegistry is Controlled {
|
|||||||
accountBalance = accounts[_subdomainHash].tokenBalance;
|
accountBalance = accounts[_subdomainHash].tokenBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBackupOwner(bytes32 _subdomainHash)
|
function getFundsOwner(bytes32 _subdomainHash)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
returns(address backupOwner)
|
returns(address fundsOwner)
|
||||||
{
|
{
|
||||||
backupOwner = accounts[_subdomainHash].backupOwner;
|
fundsOwner = accounts[_subdomainHash].fundsOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user