Skip to content

Commit 07bc421

Browse files
authored
fix: missing tss update in erc20custody, zetaConnector and gatewayEVM (#363)
1 parent 60cadbb commit 07bc421

File tree

93 files changed

+4904
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4904
-79
lines changed

v2/contracts/evm/ERC20Custody.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ contract ERC20Custody is IERC20Custody, ReentrancyGuard, AccessControl, Pausable
5858
_unpause();
5959
}
6060

61+
/// @notice Update tss address
62+
/// @param newTSSAddress new tss address
63+
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
64+
if (newTSSAddress == address(0)) revert ZeroAddress();
65+
66+
_revokeRole(WITHDRAWER_ROLE, tssAddress);
67+
_revokeRole(WHITELISTER_ROLE, tssAddress);
68+
69+
_grantRole(WITHDRAWER_ROLE, newTSSAddress);
70+
_grantRole(WHITELISTER_ROLE, newTSSAddress);
71+
72+
tssAddress = newTSSAddress;
73+
74+
emit UpdatedCustodyTSSAddress(newTSSAddress);
75+
}
76+
6177
/// @notice Unpause contract.
6278
function setSupportsLegacy(bool _supportsLegacy) external onlyRole(DEFAULT_ADMIN_ROLE) {
6379
supportsLegacy = _supportsLegacy;

v2/contracts/evm/GatewayEVM.sol

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ contract GatewayEVM is
7171
/// @param newImplementation Address of the new implementation.
7272
function _authorizeUpgrade(address newImplementation) internal override onlyRole(DEFAULT_ADMIN_ROLE) { }
7373

74+
/// @dev Internal function to execute a call to a destination address.
75+
/// @param destination Address to call.
76+
/// @param data Calldata to pass to the call.
77+
/// @return The result of the call.
78+
function _execute(address destination, bytes calldata data) internal returns (bytes memory) {
79+
(bool success, bytes memory result) = destination.call{ value: msg.value }(data);
80+
if (!success) revert ExecutionFailed();
81+
82+
return result;
83+
}
84+
85+
/// @notice Update tss address
86+
/// @param newTSSAddress new tss address
87+
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
88+
if (newTSSAddress == address(0)) revert ZeroAddress();
89+
90+
_revokeRole(TSS_ROLE, tssAddress);
91+
_grantRole(TSS_ROLE, newTSSAddress);
92+
93+
tssAddress = newTSSAddress;
94+
95+
emit UpdatedGatewayTSSAddress(newTSSAddress);
96+
}
97+
7498
/// @notice Pause contract.
7599
function pause() external onlyRole(PAUSER_ROLE) {
76100
_pause();

v2/contracts/evm/ZetaConnectorBase.sol

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ abstract contract ZetaConnectorBase is IZetaConnectorEvents, ReentrancyGuard, Pa
2424
IGatewayEVM public immutable gateway;
2525
/// @notice The address of the Zeta token.
2626
address public immutable zetaToken;
27+
/// @notice The address of the TSS (Threshold Signature Scheme) contract.
28+
address public tssAddress;
2729

2830
/// @notice New role identifier for withdrawer role.
2931
bytes32 public constant WITHDRAWER_ROLE = keccak256("WITHDRAWER_ROLE");
@@ -40,13 +42,30 @@ abstract contract ZetaConnectorBase is IZetaConnectorEvents, ReentrancyGuard, Pa
4042
}
4143
gateway = IGatewayEVM(gateway_);
4244
zetaToken = zetaToken_;
45+
tssAddress = tssAddress_;
4346

4447
_grantRole(DEFAULT_ADMIN_ROLE, admin_);
4548
_grantRole(WITHDRAWER_ROLE, tssAddress_);
4649
_grantRole(TSS_ROLE, tssAddress_);
4750
_grantRole(PAUSER_ROLE, admin_);
4851
}
4952

53+
/// @notice Update tss address
54+
/// @param newTSSAddress new tss address
55+
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
56+
if (newTSSAddress == address(0)) revert ZeroAddress();
57+
58+
_revokeRole(WITHDRAWER_ROLE, tssAddress);
59+
_revokeRole(TSS_ROLE, tssAddress);
60+
61+
_grantRole(WITHDRAWER_ROLE, newTSSAddress);
62+
_grantRole(TSS_ROLE, newTSSAddress);
63+
64+
tssAddress = newTSSAddress;
65+
66+
emit UpdatedZetaConnectorTSSAddress(newTSSAddress);
67+
}
68+
5069
/// @notice Pause contract.
5170
function pause() external onlyRole(PAUSER_ROLE) {
5271
_pause();

v2/contracts/evm/interfaces/IERC20Custody.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ interface IERC20CustodyEvents {
4040

4141
/// @notice Emitted in legacy deposit method.
4242
event Deposited(bytes recipient, IERC20 indexed asset, uint256 amount, bytes message);
43+
44+
/// @notice Emitted when tss address is updated
45+
/// @param newTSSAddress new tss address
46+
event UpdatedCustodyTSSAddress(address newTSSAddress);
4347
}
4448

4549
/// @title IERC20CustodyErrors

v2/contracts/evm/interfaces/IGatewayEVM.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ interface IGatewayEVMEvents {
4949
/// @param payload The calldata passed to the call.
5050
/// @param revertOptions Revert options.
5151
event Called(address indexed sender, address indexed receiver, bytes payload, RevertOptions revertOptions);
52+
53+
/// @notice Emitted when tss address is updated
54+
/// @param newTSSAddress new tss address
55+
event UpdatedGatewayTSSAddress(address newTSSAddress);
5256
}
5357

5458
/// @title IGatewayEVMErrors

v2/contracts/evm/interfaces/IZetaConnector.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ interface IZetaConnectorEvents {
2323
/// @param data The calldata passed to the contract call.
2424
/// @param revertContext Revert context to pass to onRevert.
2525
event WithdrawnAndReverted(address indexed to, uint256 amount, bytes data, RevertContext revertContext);
26+
27+
/// @notice Emitted when tss address is updated
28+
/// @param newTSSAddress new tss address
29+
event UpdatedZetaConnectorTSSAddress(address newTSSAddress);
2630
}

v2/docs/src/contracts/Revert.sol/interface.Revertable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Revertable
2-
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/Revert.sol)
2+
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/5f09d7eb47b707c65cea167574b26d208e366094/contracts/Revert.sol)
33

44
Interface for contracts that support revertable calls.
55

v2/docs/src/contracts/Revert.sol/struct.RevertContext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# RevertContext
2-
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/Revert.sol)
2+
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/5f09d7eb47b707c65cea167574b26d208e366094/contracts/Revert.sol)
33

44
Struct containing revert context passed to onRevert.
55

v2/docs/src/contracts/Revert.sol/struct.RevertOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# RevertOptions
2-
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/Revert.sol)
2+
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/5f09d7eb47b707c65cea167574b26d208e366094/contracts/Revert.sol)
33

44
Struct containing revert options
55

v2/docs/src/contracts/evm/ERC20Custody.sol/contract.ERC20Custody.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ERC20Custody
2-
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/ERC20Custody.sol)
2+
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/5f09d7eb47b707c65cea167574b26d208e366094/contracts/evm/ERC20Custody.sol)
33

44
**Inherits:**
55
[IERC20Custody](/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20Custody.md), ReentrancyGuard, AccessControl, Pausable
@@ -103,6 +103,21 @@ Unpause contract.
103103
function unpause() external onlyRole(PAUSER_ROLE);
104104
```
105105

106+
### updateTSSAddress
107+
108+
Update tss address
109+
110+
111+
```solidity
112+
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE);
113+
```
114+
**Parameters**
115+
116+
|Name|Type|Description|
117+
|----|----|-----------|
118+
|`newTSSAddress`|`address`|new tss address|
119+
120+
106121
### setSupportsLegacy
107122

108123
Unpause contract.

0 commit comments

Comments
 (0)