Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Jan 10, 2024
2 parents df10b8e + d65814d commit 6cfc35d
Show file tree
Hide file tree
Showing 217 changed files with 29,850 additions and 1,696 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ artifacts
cache
dist
node_modules
pkg
typechain-types
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @andresaiello @brewmaster012 @lumtis @charliemc0 @fadeev
42 changes: 42 additions & 0 deletions .github/workflows/generated-files.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Generated Files are Updated
on:
pull_request:
branches:
- "*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: "14"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq unzip
yarn install
- name: Install specific version of aibgen
run: |
wget https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.11.5-a38f4108.tar.gz
tar -zxvf geth-alltools-linux-amd64-1.11.5-a38f4108.tar.gz
sudo mv geth-alltools-linux-amd64-1.11.5-a38f4108/abigen /usr/local/bin/
- name: Generate Go packages and typechain-types
run: |
yarn generate
- name: Check for changes
run: |
if git diff --exit-code --ignore-space-change --ignore-all-space --ignore-cr-at-eol -- pkg typechain-types; then
echo "Generated Go files are up-to-date."
else
echo "::error::Generated files are not up-to-date. Please run 'yarn generate' locally and commit any changes."
exit 1
fi
26 changes: 26 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint TS/JS

on:
pull_request:
branches:
- "*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"

- name: Install Dependencies
run: yarn install

- name: Lint
run: yarn lint
40 changes: 40 additions & 0 deletions .github/workflows/publish-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish to NPM

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"

- name: Install Dependencies
run: yarn install

- name: Determine NPM Tag
id: determine-npm-tag
run: |
VERSION_TAG=${GITHUB_REF#refs/tags/v}
if [[ $VERSION_TAG == *"-"* ]]; then
echo ::set-output name=NPM_TAG::${VERSION_TAG#*-}
else
echo ::set-output name=NPM_TAG::latest
fi
env:
GITHUB_REF: ${{ github.ref }}

- name: Publish to NPM
run: yarn publish --new-version ${GITHUB_REF#refs/tags/v} --tag ${{ steps.determine-npm-tag.outputs.NPM_TAG }} --no-git-tag-version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_REF: ${{ github.ref }}
16 changes: 16 additions & 0 deletions .github/workflows/semantic-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Semantic PR"
on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test

on:
pull_request:
branches:
- "*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"

- name: Install Dependencies
run: yarn install

- name: Test
run: yarn test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ tsconfig.tsbuildinfo

# Slither
scripts/slither-results/*
!scripts/slither-results/.gitkeep
!scripts/slither-results/.gitkeep

abi
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Set the base image to ethereum/client-go
FROM ethereum/client-go:alltools-v1.11.5

# Update and install dependencies
RUN apk update && \
apk add jq unzip bash

# Copy the scripts directory into the docker container
COPY . .

# Make the script executable
RUN chmod +x /scripts/generate_go.sh

# Set the working directory
WORKDIR /

# Print the contents of /scripts/pkg after running the script
CMD ["ls", "-la", "pkg"]

# Set the entry point to your script
ENTRYPOINT ["/bin/bash", "/scripts/generate_go.sh"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Meta Protocol, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions arguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = [];
19 changes: 11 additions & 8 deletions contracts/evm/ERC20Custody.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ pragma solidity 0.8.7;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

/// @title ERC20Custody.
/// @notice ERC20Custody for depositing ERC20 assets into ZetaChain and making operations with them.
contract ERC20Custody {
contract ERC20Custody is ReentrancyGuard {
using SafeERC20 for IERC20;

error NotWhitelisted();
Expand Down Expand Up @@ -114,7 +115,7 @@ contract ERC20Custody {
/**
* @dev Pause custody operations.
*/
function pause() external onlyTSSUpdater {
function pause() external onlyTSS {
if (paused) {
revert IsPaused();
}
Expand All @@ -128,7 +129,7 @@ contract ERC20Custody {
/**
* @dev Unpause custody operations.
*/
function unpause() external onlyTSSUpdater {
function unpause() external onlyTSS {
if (!paused) {
revert NotPaused();
}
Expand Down Expand Up @@ -161,7 +162,12 @@ contract ERC20Custody {
* @param amount, asset amount.
* @param message, bytes message or encoded zetechain call.
*/
function deposit(bytes calldata recipient, IERC20 asset, uint256 amount, bytes calldata message) external {
function deposit(
bytes calldata recipient,
IERC20 asset,
uint256 amount,
bytes calldata message
) external nonReentrant {
if (paused) {
revert IsPaused();
}
Expand All @@ -184,10 +190,7 @@ contract ERC20Custody {
* @param asset, ERC20 asset.
* @param amount, asset amount.
*/
function withdraw(address recipient, IERC20 asset, uint256 amount) external onlyTSS {
if (paused) {
revert IsPaused();
}
function withdraw(address recipient, IERC20 asset, uint256 amount) external nonReentrant onlyTSS {
if (!whitelisted[asset]) {
revert NotWhitelisted();
}
Expand Down
10 changes: 10 additions & 0 deletions contracts/evm/Zeta.non-eth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ contract ZetaNonEth is ZetaNonEthInterface, ERC20Burnable, ZetaErrors {

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();

Expand All @@ -37,6 +43,9 @@ contract ZetaNonEth is ZetaNonEthInterface, ERC20Burnable, ZetaErrors {

tssAddress = tssAddress_;
connectorAddress = connectorAddress_;

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

/**
Expand All @@ -47,6 +56,7 @@ contract ZetaNonEth is ZetaNonEthInterface, ERC20Burnable, ZetaErrors {
if (tssAddress == address(0)) revert InvalidAddress();

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

function mint(address mintee, uint256 value, bytes32 internalSendHash) external override {
Expand Down
7 changes: 5 additions & 2 deletions contracts/evm/ZetaConnector.base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ contract ZetaConnectorBase is ConnectorErrors, Pausable {
bytes32 indexed internalSendHash
);

event TSSAddressUpdated(address zetaTxSenderAddress, address newTssAddress);
event TSSAddressUpdated(address callerAddress, address newTssAddress);

event PauserAddressUpdated(address updaterAddress, address newTssAddress);
event TSSAddressUpdaterUpdated(address callerAddress, address newTssUpdaterAddress);

event PauserAddressUpdated(address callerAddress, address newTssAddress);

/**
* @dev Constructor requires initial addresses.
Expand Down Expand Up @@ -139,6 +141,7 @@ contract ZetaConnectorBase is ConnectorErrors, Pausable {
if (tssAddress == address(0)) revert ZetaCommonErrors.InvalidAddress();

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

/**
Expand Down
3 changes: 3 additions & 0 deletions contracts/evm/ZetaConnector.non-eth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import "./interfaces/ZetaNonEthInterface.sol";
contract ZetaConnectorNonEth is ZetaConnectorBase {
uint256 public maxSupply = 2 ** 256 - 1;

event MaxSupplyUpdated(address callerAddress, uint256 newMaxSupply);

constructor(
address zetaTokenAddress_,
address tssAddress_,
Expand All @@ -28,6 +30,7 @@ contract ZetaConnectorNonEth is ZetaConnectorBase {

function setMaxSupply(uint256 maxSupply_) external onlyTssAddress {
maxSupply = maxSupply_;
emit MaxSupplyUpdated(msg.sender, maxSupply_);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions contracts/evm/interfaces/ZetaInterfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ interface ZetaTokenConsumer {
address outputToken,
uint256 zetaTokenAmount
) external returns (uint256);

function hasZetaLiquidity() external view returns (bool);
}

interface ZetaCommonErrors {
Expand Down
Loading

0 comments on commit 6cfc35d

Please sign in to comment.