Skip to content

Commit

Permalink
refactor: move v1 contracts still used to v2 directory (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Jan 14, 2025
1 parent 2cfa785 commit 638bf47
Show file tree
Hide file tree
Showing 161 changed files with 43,947 additions and 156 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/lint_v1.yaml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/publish-npm_v1.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions v2/contracts/evm/legacy/ConnectorErrors.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

/**
* @dev Interface with connector custom errors
*/
interface ConnectorErrors {
// @dev Thrown when caller is not the address defined as paused address
error CallerIsNotPauser(address caller);

// @dev Thrown when caller is not the address defined as TSS address
error CallerIsNotTss(address caller);

// @dev Thrown when caller is not the address defined as TSS Updater address
error CallerIsNotTssUpdater(address caller);

// @dev Thrown when caller is not the address defined as TSS or TSS Updater address
error CallerIsNotTssOrUpdater(address caller);

// @dev Thrown when Zeta can't be transferred for some reason
error ZetaTransferError();

// @dev Thrown when maxSupply will be exceed if minting will proceed
error ExceedsMaxSupply(uint256 maxSupply);
}
13 changes: 13 additions & 0 deletions v2/contracts/evm/legacy/Zeta.eth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/**
* @dev ZetaEth is an implementation of OpenZeppelin's ERC20
*/
contract ZetaEth is ERC20("Zeta", "ZETA") {
constructor(address creator, uint256 initialSupply) {
_mint(creator, initialSupply * (10 ** uint256(decimals())));
}
}
83 changes: 83 additions & 0 deletions v2/contracts/evm/legacy/Zeta.non-eth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

import "./ZetaErrors.sol";

import "./ZetaNonEthInterface.sol";

contract ZetaNonEth is ZetaNonEthInterface, ERC20Burnable, ZetaErrors {
address public connectorAddress;

/**
* @dev Collectively held by Zeta blockchain validators
*/
address public tssAddress;

/**
* @dev Initially a multi-sig, eventually held by Zeta blockchain validators (via renounceTssAddressUpdater)
*/
address public tssAddressUpdater;

event Minted(address indexed mintee, uint256 amount, bytes32 indexed internalSendHash);

event Burnt(address indexed burnee, uint256 amount);

event TSSAddressUpdated(address callerAddress, address newTssAddress);

event TSSAddressUpdaterUpdated(address callerAddress, address newTssUpdaterAddress);

event ConnectorAddressUpdated(address callerAddress, address newConnectorAddress);

constructor(address tssAddress_, address tssAddressUpdater_) ERC20("Zeta", "ZETA") {
if (tssAddress_ == address(0) || tssAddressUpdater_ == address(0)) revert InvalidAddress();

tssAddress = tssAddress_;
tssAddressUpdater = tssAddressUpdater_;
}

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

tssAddress = tssAddress_;
connectorAddress = connectorAddress_;

emit TSSAddressUpdated(msg.sender, tssAddress_);
emit ConnectorAddressUpdated(msg.sender, connectorAddress_);
}

/**
* @dev Sets tssAddressUpdater to be tssAddress
*/
function renounceTssAddressUpdater() external {
if (msg.sender != tssAddressUpdater) revert CallerIsNotTssUpdater(msg.sender);
if (tssAddress == address(0)) revert InvalidAddress();

tssAddressUpdater = tssAddress;
emit TSSAddressUpdaterUpdated(msg.sender, tssAddress);
}

function mint(address mintee, uint256 value, bytes32 internalSendHash) external override {
/**
* @dev Only Connector can mint. Minting requires burning the equivalent amount on another chain
*/
if (msg.sender != connectorAddress) revert CallerIsNotConnector(msg.sender);

_mint(mintee, value);

emit Minted(mintee, value, internalSendHash);
}

function burnFrom(address account, uint256 amount) public override(ZetaNonEthInterface, ERC20Burnable) {
/**
* @dev Only Connector can burn.
*/
if (msg.sender != connectorAddress) revert CallerIsNotConnector(msg.sender);

ERC20Burnable.burnFrom(account, amount);

emit Burnt(account, amount);
}
}
Loading

0 comments on commit 638bf47

Please sign in to comment.