Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Aug 14, 2023
2 parents bf7ac04 + 038b28c commit 40a3ae5
Show file tree
Hide file tree
Showing 31 changed files with 185 additions and 653 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/generated-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ jobs:
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
- name: Generate Go packages and typechain-types
run: |
yarn generate:go
- name: Compile contracts
run: |
yarn compile
yarn generate
- name: Check for changes
run: |
git diff --exit-code --ignore-space-change --ignore-all-space --ignore-cr-at-eol -- pkg typechain-types
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
18 changes: 0 additions & 18 deletions contracts/zevm/Interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ interface IZRC20 {
event UpdatedProtocolFlatFee(uint256 protocolFlatFee);
}

abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}

function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}

interface IZRC20Metadata is IZRC20 {
function name() external view returns (string memory);

Expand All @@ -70,11 +60,3 @@ enum CoinType {
Gas,
ERC20
}

/**
* @dev Any ZetaChain Contract must implement this interface to allow SystemContract to interact with.
* This is only required if the contract wants to interact with other chains.
*/
interface zContract {
function onCrossChainCall(address zrc20, uint256 amount, bytes calldata message) external;
}
13 changes: 9 additions & 4 deletions contracts/zevm/SystemContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,26 @@ contract SystemContract is SystemContractErrors {
emit SystemContractDeployed();
}

//

/**
* @dev Deposit foreign coins into ZRC20 and call user specified contract on zEVM.
* @param context, context data for deposit.
* @param zrc20, zrc20 address for deposit.
* @param amount, amount to deposit.
* @param target, contract address to make a call after deposit.
* @param message, calldata for a call.
*/
function depositAndCall(address zrc20, uint256 amount, address target, bytes calldata message) external {
function depositAndCall(
zContext calldata context,
address zrc20,
uint256 amount,
address target,
bytes calldata message
) external {
if (msg.sender != FUNGIBLE_MODULE_ADDRESS) revert CallerIsNotFungibleModule();
if (target == FUNGIBLE_MODULE_ADDRESS || target == address(this)) revert InvalidTarget();

IZRC20(zrc20).deposit(target, amount);
zContract(target).onCrossChainCall(zrc20, amount, message);
zContract(target).onCrossChainCall(context, zrc20, amount, message);
}

/**
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions contracts/zevm/ZRC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ interface ZRC20Errors {
error ZeroAddress();
}

<<<<<<< HEAD
contract ZRC20 is Context, IZRC20, IZRC20Metadata, ZRC20Errors {
/// @notice The fungible module address, this is maintained at the protocol level and is always constant
=======
contract ZRC20 is IZRC20, IZRC20Metadata, ZRC20Errors {
/// @notice Fungible address is always the same, maintained at the protocol level
>>>>>>> main
address public constant FUNGIBLE_MODULE_ADDRESS = 0x735b14BB79463307AAcBED86DAf3322B1e6226aB;
/// @notice Chain id.abi
uint256 public immutable CHAIN_ID;
Expand Down Expand Up @@ -49,6 +54,14 @@ contract ZRC20 is Context, IZRC20, IZRC20Metadata, ZRC20Errors {
/// @notice Number of decimal places the token can be divided into
uint8 private _decimals;

function _msgSender() internal view virtual returns (address) {
return msg.sender;
}

function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}

/**
* @dev Only fungible module modifier.
*/
Expand Down
13 changes: 12 additions & 1 deletion contracts/zevm/interfaces/zContract.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

struct zContext {
bytes origin;
address sender;
uint256 chainID;
}

interface zContract {
function onCrossChainCall(address zrc20, uint256 amount, bytes calldata message) external;
function onCrossChainCall(
zContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
) external;
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@
"build": "yarn clean && yarn compile && npx del-cli dist abi && tsc || exit 0 && npx del-cli './dist/typechain-types/**/*.js' && npx cpx './data/**/*' dist/data && npx cpx './artifacts/contracts/**/*' ./abi && npx del-cli './abi/**/*.dbg.json'",
"clean": "npx hardhat clean",
"compile": "yarn clean && npx hardhat compile",
"generate:go": "yarn compile && ./scripts/generate_go.sh",
"generate:interfaces": "yarn clean && yarn compile",
"generate": "yarn compile && ./scripts/generate_go.sh",
"lint": "npx eslint . --ext .js,.ts",
"lint:fix": "npx eslint . --ext .js,.ts,.json --fix",
"prepublishOnly": "yarn build",
Expand Down
181 changes: 0 additions & 181 deletions pkg/contracts/zevm/interfaces.sol/context.go

This file was deleted.

Loading

0 comments on commit 40a3ae5

Please sign in to comment.