Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit 45aa3a6

Browse files
authored
Merge pull request #315 from maticnetwork/mat-1927
overriden owner in upgradable proxy (mat-1980)
2 parents beba192 + 8e1096c commit 45aa3a6

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

contracts/common/misc/UpgradableProxy.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import {DelegateProxy} from "./DelegateProxy.sol";
44

55
contract UpgradableProxy is DelegateProxy {
66
event ProxyUpdated(address indexed _new, address indexed _old);
7-
event OwnerUpdate(address _new, address _old);
7+
event ProxyOwnerUpdate(address _new, address _old);
88

99
bytes32 constant IMPLEMENTATION_SLOT = keccak256("matic.network.proxy.implementation");
1010
bytes32 constant OWNER_SLOT = keccak256("matic.network.proxy.owner");
1111

1212
constructor(address _proxyTo) public {
13-
setOwner(msg.sender);
13+
setProxyOwner(msg.sender);
1414
setImplementation(_proxyTo);
1515
}
1616

@@ -21,15 +21,15 @@ contract UpgradableProxy is DelegateProxy {
2121
}
2222

2323
modifier onlyProxyOwner() {
24-
require(loadOwner() == msg.sender, "NOT_OWNER");
24+
require(loadProxyOwner() == msg.sender, "NOT_OWNER");
2525
_;
2626
}
2727

28-
function owner() external view returns(address) {
29-
return loadOwner();
28+
function proxyOwner() external view returns(address) {
29+
return loadProxyOwner();
3030
}
3131

32-
function loadOwner() internal view returns(address) {
32+
function loadProxyOwner() internal view returns(address) {
3333
address _owner;
3434
bytes32 position = OWNER_SLOT;
3535
assembly {
@@ -51,13 +51,13 @@ contract UpgradableProxy is DelegateProxy {
5151
return _impl;
5252
}
5353

54-
function transferOwnership(address newOwner) public onlyProxyOwner {
54+
function transferProxyOwnership(address newOwner) public onlyProxyOwner {
5555
require(newOwner != address(0), "ZERO_ADDRESS");
56-
emit OwnerUpdate(newOwner, loadOwner());
57-
setOwner(newOwner);
56+
emit ProxyOwnerUpdate(newOwner, loadProxyOwner());
57+
setProxyOwner(newOwner);
5858
}
5959

60-
function setOwner(address newOwner) private {
60+
function setProxyOwner(address newOwner) private {
6161
bytes32 position = OWNER_SLOT;
6262
assembly {
6363
sstore(position, newOwner)

contracts/staking/validatorShare/ValidatorShareFactory.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ contract ValidatorShareFactory {
1010
function create(uint256 validatorId, address loggerAddress, address registry) public returns (address) {
1111
ValidatorShareProxy proxy = new ValidatorShareProxy(registry);
1212

13-
proxy.transferOwnership(msg.sender);
13+
proxy.transferProxyOwnership(msg.sender);
1414

1515
address proxyAddr = address(proxy);
1616
(bool success, bytes memory data) = proxyAddr.call.gas(gasleft())(

test/units/UpgradableProxy.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,25 @@ contract('UpgradableProxy', function() {
6464
})
6565
})
6666

67-
describe('transferOwnership', function() {
67+
describe('transferProxyOwnership', function() {
6868
before(doDeploy)
6969
before(async function() {
7070
this.newOwner = wallets[1].getChecksumAddressString()
7171
})
7272

7373
describe('when from is not owner', function() {
7474
it('reverts', async function() {
75-
await expectRevert(this.proxy.transferOwnership(this.newOwner, { from: this.newOwner }), 'NOT_OWNER')
75+
await expectRevert(this.proxy.transferProxyOwnership(this.newOwner, { from: this.newOwner }), 'NOT_OWNER')
7676
})
7777
})
7878

7979
describe('when from is owner', function() {
8080
it('must update owner', async function() {
81-
await this.proxy.transferOwnership(this.newOwner)
81+
await this.proxy.transferProxyOwnership(this.newOwner)
8282
})
8383

8484
it('must have correct owner', async function() {
85-
const owner = await this.proxy.owner()
85+
const owner = await this.proxy.proxyOwner()
8686
owner.should.be.equal(this.newOwner)
8787
})
8888
})

0 commit comments

Comments
 (0)