Skip to content

Commit

Permalink
feat: generate omnichain contracts with new OnlySystem by default
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed May 13, 2024
1 parent b62f6fc commit c313ef3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 3 additions & 1 deletion contracts/OnlySystem.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol";

contract OnlySystem {
error OnlySystemContract(string);

modifier onlySystem(address systemContract) {
modifier onlySystem(SystemContract systemContract) {
if (msg.sender != address(systemContract)) {
revert OnlySystemContract(
"Only system contract can call this function"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,21 @@ pragma solidity 0.8.7;

import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol";
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/zContract.sol";
import "@zetachain/toolkit/contracts/OnlySystem.sol";

contract {{contractName}} is zContract {
contract {{contractName}} is zContract, OnlySystem {
SystemContract public systemContract;

constructor(address systemContractAddress) {
systemContract = SystemContract(systemContractAddress);
}

modifier onlySystem() {
require(
msg.sender == address(systemContract),
"Only system contract can call this function"
);
_;
}

function onCrossChainCall(
zContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
) external virtual override onlySystem {
) external virtual override onlySystem(systemContract) {
{{#if arguments.pairsWithDataLocation}}
({{#each arguments.pairsWithDataLocation}}{{#if @index}}, {{/if}}{{this.[1]}} {{this.[0]}}{{/each}}) = abi.decode(
message,
Expand Down

0 comments on commit c313ef3

Please sign in to comment.