Skip to content

Commit

Permalink
updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Sep 13, 2024
1 parent a5b5002 commit f74fa2e
Show file tree
Hide file tree
Showing 10 changed files with 1,157 additions and 2,275 deletions.
22 changes: 11 additions & 11 deletions examples/hello/contracts/Hello.sol
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

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

import {RevertContext, RevertOptions} from "@zetachain/protocol-contracts/contracts/Revert.sol";
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/UniversalContract.sol";
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IGatewayZEVM.sol";
import "@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol";

contract Hello is UniversalContract {
GatewayZEVM public gateway;

event HelloEvent(string, string);
event ContextDataRevert(RevertContext);
event RevertEvent(string, RevertContext);

address constant gatewayAddress =
0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0;
constructor(address payable gatewayAddress) {
gateway = GatewayZEVM(gatewayAddress);
}

function onCrossChainCall(
zContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
) external override {
string memory decodedMessage;
if (message.length > 0) {
decodedMessage = abi.decode(message, (string));
}
emit HelloEvent("Hello from a universal app", decodedMessage);
string memory name = abi.decode(message, (string));
emit HelloEvent("Hello on ZetaChain", name);
}

function onRevert(RevertContext calldata revertContext) external override {
emit ContextDataRevert(revertContext);
emit RevertEvent("Revert on ZetaChain", revertContext);
}
}
24 changes: 0 additions & 24 deletions examples/hello/contracts/ReceiverContract.sol

This file was deleted.

1 change: 1 addition & 0 deletions examples/hello/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./tasks/deploy";
import "./tasks/deployRevert";
import "./tasks/solana/interact";
import "@zetachain/localnet/tasks";
import "@nomicfoundation/hardhat-toolbox";
Expand Down
6 changes: 3 additions & 3 deletions examples/hello/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"lint:fix": "npx eslint . --ext .js,.ts --fix",
"lint": "npx eslint . --ext .js,.ts",
"deploy": "npx hardhat compile --force && npx hardhat deploy --network localhost --name Hello && npx hardhat deploy --network localhost --name ReceiverContract"
"deploy": "npx hardhat compile --force && npx hardhat deploy --network localhost && npx hardhat deploy-revert --network localhost"
},
"keywords": [],
"author": "",
Expand All @@ -28,7 +28,7 @@
"@types/node": ">=12.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/localnet": "3.0.2",
"@zetachain/localnet": "3.0.3",
"@zetachain/toolkit": "13.0.0-rc2",
"axios": "^1.3.6",
"chai": "^4.2.0",
Expand Down Expand Up @@ -59,4 +59,4 @@
"@solana/web3.js": "^1.95.2",
"@zetachain/protocol-contracts": "10.0.0-rc10"
}
}
}
15 changes: 10 additions & 5 deletions examples/hello/tasks/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { task } from "hardhat/config";
import { task, types } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const network = hre.network.name as ParamChainName;
const network = hre.network.name;

const [signer] = await hre.ethers.getSigners();
if (signer === undefined) {
Expand All @@ -12,20 +12,25 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
}

const factory = await hre.ethers.getContractFactory(args.name);
const contract = await factory.deploy();
const contract = await (factory as any).deploy(args.gatewayZetaChain);
await contract.deployed();

if (args.json) {
console.log(JSON.stringify(contract));
} else {
console.log(`🔑 Using account: ${signer.address}
🚀 Successfully deployed contract on ${network}.
🚀 Successfully deployed "${args.name}" contract on ${network}.
📜 Contract address: ${contract.address}
`);
}
};

task("deploy", "Deploy the contract", main)
.addFlag("json", "Output in JSON")
.addOptionalParam("name", "Contract to deploy", "Hello");
.addOptionalParam("name", "Contract to deploy", "Hello")
.addOptionalParam(
"gatewayZetaChain",
"Gateway address",
"0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0"
);
8 changes: 4 additions & 4 deletions examples/hello/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2407,10 +2407,10 @@
typescript "5.5.4"
zod "3.22.4"

"@zetachain/[email protected].2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.0.2.tgz#4b9af86f8b0810a9a528073611c0e3a5ac49c28a"
integrity sha512-nNBAOWWUuebUSuRMTwVnsF9V3W5HcWZ+vTiLSINMXBagbKyOJ4wQAK7nFBBB1UZBTnAcGPyMQVP+ymoEvEpn6g==
"@zetachain/[email protected].3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.0.3.tgz#2d822791c1814690971c35efc43be6b3743045e7"
integrity sha512-s/DGVFzGwURwqw6krkU9jlMCUBYbwgOEQPpYbGwVqBHrMR4YB/EFur8FHz1Sc5VPMDV1VarbSsC253oI99Tulw==
dependencies:
"@inquirer/prompts" "^5.5.0"
"@uniswap/v2-core" "^1.0.1"
Expand Down
16 changes: 9 additions & 7 deletions examples/swap/contracts/Swap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {RevertContext, RevertOptions} from "@zetachain/protocol-contracts/contracts/Revert.sol";
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/UniversalContract.sol";
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IGatewayZEVM.sol";
import {GatewayZEVM} from "@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol";

contract Swap is UniversalContract {
SystemContract public systemContract;
GatewayZEVM public gateway;
uint256 constant BITCOIN = 18332;
address constant gatewayAddress =
0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0;

constructor(address systemContractAddress) {
constructor(address systemContractAddress, address payable gatewayAddress) {
systemContract = SystemContract(systemContractAddress);
gateway = GatewayZEVM(gatewayAddress);
}

struct Params {
Expand Down Expand Up @@ -75,12 +76,13 @@ contract Swap is UniversalContract {
);

if (gasZRC20 == params.target) {
IZRC20(gasZRC20).approve(gatewayAddress, outputAmount + gasFee);
IZRC20(gasZRC20).approve(address(gateway), outputAmount + gasFee);
} else {
IZRC20(gasZRC20).approve(gatewayAddress, gasFee);
IZRC20(params.target).approve(gatewayAddress, outputAmount);
IZRC20(gasZRC20).approve(address(gateway), gasFee);
IZRC20(params.target).approve(address(gateway), outputAmount);
}
IGatewayZEVM(gatewayAddress).withdraw(

gateway.withdraw(
params.to,
outputAmount,
params.target,
Expand Down
5 changes: 2 additions & 3 deletions examples/swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/localnet": "3.0.2",
"@zetachain/toolkit": "13.0.0-rc3",
"axios": "^1.3.6",
"chai": "^4.2.0",
"dotenv": "^16.0.3",
Expand All @@ -54,10 +53,10 @@
"packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72",
"dependencies": {
"@coral-xyz/anchor": "0.30.0",
"@openzeppelin/contracts": "^4.9.6",
"@solana-developers/helpers": "^2.4.0",
"@solana/spl-memo": "^0.2.5",
"@solana/web3.js": "^1.95.2",
"@zetachain/protocol-contracts": "10.0.0-rc10"
"@zetachain/protocol-contracts": "10.0.0-rc10",
"@zetachain/toolkit": "13.0.0-rc4"
}
}
10 changes: 9 additions & 1 deletion examples/swap/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
}

const factory = await hre.ethers.getContractFactory(args.name);
const contract = await factory.deploy(args.systemContract);
const contract = await (factory as any).deploy(
args.systemContract,
args.gatewayZetaChain
);
await contract.deployed();

if (args.json) {
Expand All @@ -33,4 +36,9 @@ task("deploy", "Deploy the contract", main)
"systemContract",
"System contract",
"0x610178dA211FEF7D417bC0e6FeD39F05609AD788"
)
.addOptionalParam(
"gatewayZetaChain",
"Gateway address",
"0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0"
);
Loading

0 comments on commit f74fa2e

Please sign in to comment.