Skip to content

Commit

Permalink
Allow TSS to call updateTssAndConnectorAddresses
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-janon committed Jun 29, 2022
1 parent db87337 commit 0035046
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/protocol-contracts/contracts/Zeta.non-eth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract ZetaNonEth is ERC20Burnable, ZetaErrors {
}

function updateTssAndConnectorAddresses(address tssAddress_, address connectorAddress_) external {
if (msg.sender != tssAddressUpdater) revert CallerIsNotTssUpdater(msg.sender);
if (msg.sender != tssAddressUpdater && msg.sender != tssAddress) revert CallerIsNotTssOrUpdater(msg.sender);
if (tssAddress_ == address(0) || connectorAddress_ == address(0)) revert InvalidAddress();

tssAddress = tssAddress_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface ZetaErrors {

error CallerIsNotTssUpdater(address caller);

error CallerIsNotTssOrUpdater(address caller);

error InvalidAddress();

error ZetaTransferError();
Expand Down
17 changes: 14 additions & 3 deletions packages/protocol-contracts/test/Zeta.non-eth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ describe("ZetaNonEth tests", () => {
});

describe("updateTssAndConnectorAddresses", () => {
it("Should revert if the caller is not tssAddressUpdater", async () => {
it("Should revert if the caller is not tssAddressUpdater or TSS", async () => {
expect(
zetaTokenNonEthContract
.connect(randomSigner)
.updateTssAndConnectorAddresses(tssSigner.address, zetaConnectorNonEthContract.address)
).to.be.revertedWith(`CallerIsNotTssUpdater("${randomSigner.address}")`);
.updateTssAndConnectorAddresses(randomSigner.address, zetaConnectorNonEthContract.address)
).to.be.revertedWith(`CallerIsNotTssOrUpdater("${randomSigner.address}")`);
});

it("Should change the addresses if the caller is tssAddressUpdater", async () => {
Expand All @@ -73,6 +73,17 @@ describe("ZetaNonEth tests", () => {
expect(await zetaTokenNonEthContract.tssAddress()).to.equal(randomSigner.address);
expect(await zetaTokenNonEthContract.connectorAddress()).to.equal(randomSigner.address);
});

it("Should change the addresses if the caller is TSS", async () => {
await (
await zetaTokenNonEthContract
.connect(tssSigner)
.updateTssAndConnectorAddresses(randomSigner.address, randomSigner.address)
).wait();

expect(await zetaTokenNonEthContract.tssAddress()).to.equal(randomSigner.address);
expect(await zetaTokenNonEthContract.connectorAddress()).to.equal(randomSigner.address);
});
});

describe("renounceTssAddressUpdater", () => {
Expand Down

0 comments on commit 0035046

Please sign in to comment.