Skip to content

Commit

Permalink
Merge branch 'main' into docs/v2-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Jul 17, 2024
2 parents edb30c8 + 2bbd352 commit e7a458f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const config: HardhatUserConfig = {
},
networks: {
...getHardhatConfigNetworks(),
hardhat: {},
},
solidity: {
compilers: [
Expand Down
1 change: 1 addition & 0 deletions scripts/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
To start localnet execute:

```
yarn compile
yarn localnet
```

Expand Down
19 changes: 9 additions & 10 deletions tasks/localnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ declare const hre: any;
// Otherwise, provide custom addresses as parameters.

task("zevm-call", "calls evm contract from zevm account")
.addOptionalParam("gatewayZEVM", "contract address of gateway on ZEVM", "0x413b1AfCa96a3df5A686d8BFBF93d30688a7f7D9")
.addOptionalParam("receiverEVM", "contract address of receiver on EVM", "0x821f3361D454cc98b7555221A06Be563a7E2E0A6")
.addOptionalParam("gatewayZEVM", "contract address of gateway on ZEVM", "0x0165878A594ca255338adfa4d48449f69242Eb8F")
.addOptionalParam("receiverEVM", "contract address of receiver on EVM", "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6")
.setAction(async (taskArgs) => {
const gatewayZEVM = await hre.ethers.getContractAt("GatewayZEVM", taskArgs.gatewayZEVM);
const receiverEVM = await hre.ethers.getContractAt("ReceiverEVM", taskArgs.receiverEVM);
Expand All @@ -22,15 +22,14 @@ task("zevm-call", "calls evm contract from zevm account")
try {
const callTx = await gatewayZEVM.call(receiverEVM.address, message);
await callTx.wait();
console.log("ReceiverEVM called from ZEVM");
} catch (e) {
console.error("Error calling ReceiverEVM:", e);
}
});

task("zevm-withdraw-and-call", "withdraws zrc20 and calls evm contract from zevm account")
.addOptionalParam("gatewayZEVM", "contract address of gateway on ZEVM", "0x413b1AfCa96a3df5A686d8BFBF93d30688a7f7D9")
.addOptionalParam("receiverEVM", "contract address of receiver on EVM", "0x821f3361D454cc98b7555221A06Be563a7E2E0A6")
.addOptionalParam("gatewayZEVM", "contract address of gateway on ZEVM", "0x0165878A594ca255338adfa4d48449f69242Eb8F")
.addOptionalParam("receiverEVM", "contract address of receiver on EVM", "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6")
.addOptionalParam("zrc20", "contract address of zrc20", "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c")
.addOptionalParam("amount", "amount to withdraw", "1")
.setAction(async (taskArgs) => {
Expand Down Expand Up @@ -58,8 +57,8 @@ task("zevm-withdraw-and-call", "withdraws zrc20 and calls evm contract from zevm
});

task("evm-call", "calls zevm zcontract from evm account")
.addOptionalParam("gatewayEVM", "contract address of gateway on EVM", "0xB06c856C8eaBd1d8321b687E188204C1018BC4E5")
.addOptionalParam("zContract", "contract address of zContract on ZEVM", "0x71089Ba41e478702e1904692385Be3972B2cBf9e")
.addOptionalParam("gatewayEVM", "contract address of gateway on EVM", "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512")
.addOptionalParam("zContract", "contract address of zContract on ZEVM", "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e")
.setAction(async (taskArgs) => {
const gatewayEVM = await hre.ethers.getContractAt("GatewayEVM", taskArgs.gatewayEVM);
const zContract = await hre.ethers.getContractAt("TestZContract", taskArgs.zContract);
Expand All @@ -76,9 +75,9 @@ task("evm-call", "calls zevm zcontract from evm account")
});

task("evm-deposit-and-call", "deposits erc20 and calls zevm zcontract from evm account")
.addOptionalParam("gatewayEVM", "contract address of gateway on EVM", "0xB06c856C8eaBd1d8321b687E188204C1018BC4E5")
.addOptionalParam("zContract", "contract address of zContract on ZEVM", "0x71089Ba41e478702e1904692385Be3972B2cBf9e")
.addOptionalParam("erc20", "contract address of erc20", "0x02df3a3F960393F5B349E40A599FEda91a7cc1A7")
.addOptionalParam("gatewayEVM", "contract address of gateway on EVM", "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512")
.addOptionalParam("zContract", "contract address of zContract on ZEVM", "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e")
.addOptionalParam("erc20", "contract address of erc20", "0xa513e6e4b8f2a923d98304ec87f64353c4d5c853")
.addOptionalParam("amount", "amount to deposit", "1")
.setAction(async (taskArgs) => {
const gatewayEVM = await hre.ethers.getContractAt("GatewayEVM", taskArgs.gatewayEVM);
Expand Down
8 changes: 7 additions & 1 deletion test/ZetaTokenConsumer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import chai, { expect } from "chai";
import { BigNumber } from "ethers";
import { ethers } from "hardhat";
import { getNonZetaAddress } from "lib";
const { reset } = require("@nomicfoundation/hardhat-network-helpers");

import { getTestAddress } from "../lib/address.helpers";
import {
deployZetaNonEth,
getZetaTokenConsumerUniV2Strategy,
getZetaTokenConsumerUniV3Strategy,
} from "../lib/contracts.helpers";
import { parseZetaConsumerLog } from "./test.helpers";
import { MAINNET_FORK_BLOCK, MAINNET_FORK_URL, parseZetaConsumerLog } from "./test.helpers";

chai.should();

Expand Down Expand Up @@ -55,6 +56,7 @@ describe("ZetaTokenConsumer tests", () => {
};

beforeEach(async () => {
await reset(MAINNET_FORK_URL, MAINNET_FORK_BLOCK);
accounts = await ethers.getSigners();
[tssUpdater, tssSigner, randomSigner] = accounts;

Expand Down Expand Up @@ -94,6 +96,10 @@ describe("ZetaTokenConsumer tests", () => {
});
});

afterEach(async () => {
await reset();
});

describe("getZetaFromEth", () => {
const shouldGetZetaFromETH = async (zetaTokenConsumer: ZetaTokenConsumer) => {
const initialZetaBalance = await zetaTokenNonEth.balanceOf(randomSigner.address);
Expand Down
8 changes: 7 additions & 1 deletion test/ZetaTokenConsumerZEVM.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import {
import chai, { expect } from "chai";
import { BigNumber, providers } from "ethers";
import { ethers } from "hardhat";
const { reset } = require("@nomicfoundation/hardhat-network-helpers");

import { WETH9__factory } from "../typechain-types/factories/contracts/zevm/WZETA.sol/WETH9__factory";
import { parseZetaConsumerLog } from "./test.helpers";
import { MAINNET_FORK_BLOCK, MAINNET_FORK_URL, parseZetaConsumerLog } from "./test.helpers";

chai.should();

Expand Down Expand Up @@ -46,6 +47,7 @@ describe("ZetaTokenConsumerZEVM tests", () => {
};

beforeEach(async () => {
await reset(MAINNET_FORK_URL, MAINNET_FORK_BLOCK);
accounts = await ethers.getSigners();
[deployer, randomSigner] = accounts;

Expand All @@ -55,6 +57,10 @@ describe("ZetaTokenConsumerZEVM tests", () => {
zetaTokenConsumerZEVM = await zetaTokenConsumerZEVMFactory.deploy(WETH_ADDRESS, UNI_V2_ROUTER_ADDRESS);
});

afterEach(async () => {
await reset();
});

describe("getZetaFromEth", () => {
it("Should get zeta from eth", async () => {
const initialZetaBalance = await zetaToken.balanceOf(randomSigner.address);
Expand Down
3 changes: 3 additions & 0 deletions test/test.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { BigNumber, ContractReceipt } from "ethers";

export const FUNGIBLE_MODULE_ADDRESS = "0x735b14BB79463307AAcBED86DAf3322B1e6226aB";

export const MAINNET_FORK_URL = "https://rpc.ankr.com/eth";
export const MAINNET_FORK_BLOCK = 14672712;

export const parseZetaConsumerLog = (logs: ContractReceipt["logs"]) => {
const iface = ZetaTokenConsumer__factory.createInterface();

Expand Down

0 comments on commit e7a458f

Please sign in to comment.