Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Athens 3 support #9

Merged
merged 38 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
33acd7f
feat: import toolkit
fadeev Jun 5, 2023
6d377ec
fix: compile and test
fadeev Jun 7, 2023
d7e8909
typechain imports
fadeev Jun 7, 2023
c1cfc1a
prepareData
fadeev Jun 7, 2023
e977f4f
WIP CCM tests
fadeev Jun 7, 2023
e0be0e3
warriors test
fadeev Jun 7, 2023
e52c269
chore: merge main
fadeev Jun 15, 2023
2e827b4
update message and value
fadeev Jun 15, 2023
a3fbe1a
wip
fadeev Jun 15, 2023
10f2c45
value tests
fadeev Jun 15, 2023
17c99ca
value tests
fadeev Jun 15, 2023
4f60459
yarn add --dev @zetachain/networks@athens3 @zetachain/faucet-cli --no…
fadeev Jun 16, 2023
717d337
yarn add --dev @zetachain/networks@athens3
fadeev Jun 18, 2023
14f6b3e
fix: update omnichain deploy tasks
fadeev Jun 18, 2023
2a522cb
fix: swap test
fadeev Jun 19, 2023
ff461a6
fix: value test
fadeev Jun 19, 2023
d96ba57
fix: counter
fadeev Jun 22, 2023
560397e
fix: counter type warning
fadeev Jun 22, 2023
b4a560b
fix: withdraw
fadeev Jun 22, 2023
0eafbb6
fix: swap
fadeev Jun 22, 2023
814809a
refactor: task descriptions
fadeev Jun 22, 2023
ff21289
fix: use the correct pools (v3 and v2)
fadeev Jun 23, 2023
ea43736
refactor: remove console log
fadeev Jun 23, 2023
ad0c5b7
fix: ccm contracts gas
fadeev Jun 25, 2023
8563224
fix: swap
fadeev Jun 25, 2023
f3228d1
refactor: withdraw to use prepareData
fadeev Jun 25, 2023
fdd200d
refactor: use getAddress in swpa
fadeev Jun 25, 2023
3e79d00
fix: update to @zetachain/protocol-contracts@athens3 @zetachain/netwo…
fadeev Jun 27, 2023
e1e1eb3
formatting
fadeev Jun 28, 2023
3818e45
ZetaMultiOutput
fadeev Jun 30, 2023
cc33fc5
Athens 3 explorer URL
fadeev Jun 30, 2023
d370ff3
improve value tutorial
fadeev Jun 30, 2023
961b530
zeta_testnet in the hello example
fadeev Jul 4, 2023
489fec2
withdraw: main
fadeev Jul 4, 2023
cd95cec
Please use the zeta_testnet network to deploy to ZetaChain.
fadeev Jul 11, 2023
f2a5e67
list all available networks
fadeev Jul 11, 2023
541d336
yarn add --dev @zetachain/networks@athens3
fadeev Jul 11, 2023
d00e157
minter example
fadeev Jul 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion messaging/counter/contracts/CrossChainCounter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract CrossChainCounter is
if (!_isValidChainId(destinationChainId))
revert InvalidDestinationChainId();

uint256 crossChainGas = 18 * (10 ** 18);
uint256 crossChainGas = 2 * (10 ** 18);
uint256 zetaValueAndGas = _zetaConsumer.getZetaFromEth{
value: msg.value
}(address(this), crossChainGas);
Expand Down
1 change: 0 additions & 1 deletion messaging/counter/contracts/readme.md

This file was deleted.

14 changes: 3 additions & 11 deletions messaging/counter/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import "@nomicfoundation/hardhat-toolbox";
import "./tasks/account";
import "./tasks/faucet";
import "./tasks/balances";
import "./tasks/verify";
import "./tasks/deploy";
import "./tasks/counter_increment";
import "./tasks/counter_show";

import { getHardhatConfigNetworks } from "@zetachain/addresses-tools/dist/networks";
import * as dotenv from "dotenv";
import { getHardhatConfigNetworks } from "@zetachain/networks";
import { HardhatUserConfig } from "hardhat/config";

dotenv.config();
const PRIVATE_KEYS =
process.env.PRIVATE_KEY !== undefined ? [`0x${process.env.PRIVATE_KEY}`] : [];
import "@zetachain/toolkit/tasks";

const config: HardhatUserConfig = {
networks: {
...getHardhatConfigNetworks(PRIVATE_KEYS),
...getHardhatConfigNetworks(),
},
solidity: "0.8.7",
};
Expand Down
8 changes: 5 additions & 3 deletions messaging/counter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/addresses": "^0.0.9",
"@zetachain/addresses-tools": "^0.0.7",
"@zetachain/faucet-cli": "1.3.5",
"@zetachain/faucet-cli": "^2.0.1",
"@zetachain/interfaces": "^0.0.1",
"@zetachain/protocol-contracts": "^0.0.7",
"@zetachain/networks": "^2.3.0-athens3",
"@zetachain/protocol-contracts": "^1.0.0-athens3",
"@zetachain/toolkit": "^1.0.2-athens3",
"axios": "^1.3.6",
"chai": "^4.2.0",
"dotenv": "^16.0.3",
Expand All @@ -54,4 +56,4 @@
"typechain": "^8.1.0",
"typescript": ">=4.5.0"
}
}
}
28 changes: 0 additions & 28 deletions messaging/counter/tasks/account.ts

This file was deleted.

96 changes: 0 additions & 96 deletions messaging/counter/tasks/balances.ts

This file was deleted.

15 changes: 5 additions & 10 deletions messaging/counter/tasks/counter_increment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,11 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {

Please, refer to ZetaChain's explorer for updates on the progress of the cross-chain transaction.

🌍 Explorer: https://explorer.zetachain.com/cc/tx/${receipt.transactionHash}
🌍 Explorer: https://athens3.explorer.zetachain.com/cc/tx/${receipt.transactionHash}
`);
};

const descTask = `Sends a message from one chain to another.`;
const descContractFlag = `Contract address`;
const descDestinationFlag = `Destination chain ID (integer)`;
const descAmountFlag = `Token amount to send`;

task("counter:increment", descTask, main)
.addParam("contract", descContractFlag)
.addParam("amount", descAmountFlag)
.addParam("destination", descDestinationFlag);
task("counter:increment", "Sends a message from one chain to another.", main)
.addParam("contract", "Contract address")
.addParam("amount", "Token amount to send")
.addParam("destination", "Destination chain ID (integer)");
12 changes: 6 additions & 6 deletions messaging/counter/tasks/counter_show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {

const counter = await contract.counter(signer.address);

console.log(`
🔢 The counter for ${signer.address} is: ${counter.toString()}
console.log(`🔢 The counter for ${signer.address} is: ${counter.toString()}
`);
};

const descTask = `Sends a message from one chain to another.`;
const descContractFlag = `Contract address`;

task("counter:show", descTask, main).addParam("contract", descContractFlag);
task(
"counter:show",
"Sends a message from one chain to another.",
main
).addParam("contract", "Contract address");
58 changes: 25 additions & 33 deletions messaging/counter/tasks/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getAddress, getChainId } from "@zetachain/addresses";
import { getAddress } from "@zetachain/protocol-contracts";
import { ethers } from "ethers";
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getSupportedNetworks } from "@zetachain/networks";

const contractName = "CrossChainCounter";

Expand All @@ -23,7 +24,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
// Initialize a wallet using a network configuration and a private key from
// environment variables.
const initWallet = (hre: HardhatRuntimeEnvironment, networkName: string) => {
const { url } = hre.config.networks[networkName];
const { url } = hre.config.networks[networkName] as any;
const provider = new ethers.providers.JsonRpcProvider(url);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY as string, provider);

Expand All @@ -38,41 +39,30 @@ const deployContract = async (
networkName: string
) => {
const wallet = initWallet(hre, networkName);
const zetaNetwork = "athens";
const connectorAddress = getAddress({
address: "connector",
networkName,
zetaNetwork,
});
const zetaTokenAddress = getAddress({
address: "zetaToken",
networkName,
zetaNetwork,
});
const zetaTokenConsumerV2 = getAddress({
address: "zetaTokenConsumerUniV2",
networkName,
zetaNetwork,
});
const zetaTokenConsumerV3 = getAddress({
address: "zetaTokenConsumerUniV3",
networkName,
zetaNetwork,
});

const connector = getAddress("connector", networkName as any);
const zetaToken = getAddress("zetaToken", networkName as any);
const zetaTokenConsumerUniV2 = getAddress(
"zetaTokenConsumerUniV2",
networkName as any
);
const zetaTokenConsumerUniV3 = getAddress(
"zetaTokenConsumerUniV3",
networkName as any
);

const { abi, bytecode } = await hre.artifacts.readArtifact(contractName);
const factory = new ethers.ContractFactory(abi, bytecode, wallet);
const contract = await factory.deploy(
connectorAddress,
zetaTokenAddress,
zetaTokenConsumerV2 || zetaTokenConsumerV3
connector,
zetaToken,
zetaTokenConsumerUniV2 || zetaTokenConsumerUniV3
);

await contract.deployed();
console.log(`
🚀 Successfully deployed contract on ${networkName}.
📜 Contract address: ${contract.address}
`);
📜 Contract address: ${contract.address}`);
return contract.address;
};

Expand Down Expand Up @@ -102,7 +92,7 @@ const setInteractors = async (
["address"],
[contracts[counterparty]]
);
const chainId = getChainId(counterparty as any);
const chainId = hre.config.networks[counterparty].chainId;
await (
await contract.setInteractorByChainId(chainId, counterpartyContract)
).wait();
Expand All @@ -112,7 +102,9 @@ const setInteractors = async (
}
};

const descTask = `Deploy the contract`;
const descNetworksFlag = `Comma separated list of networks to deploy to`;

task("deploy", descTask).addParam("networks", descNetworksFlag).setAction(main);
task("deploy", "Deploy the contract", main).addParam(
"networks",
`Comma separated list of networks to deploy to (e.g. ${getSupportedNetworks(
"ccm"
)})`
);
56 changes: 0 additions & 56 deletions messaging/counter/tasks/faucet.ts

This file was deleted.

Loading
Loading