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: update toolkit version #74

Merged
merged 32 commits into from
Oct 10, 2023
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
staking integration
fadeev committed Oct 8, 2023
commit dc11443cb42e6528f8b7a63b0d9d8c6d5c759f41
14 changes: 9 additions & 5 deletions omnichain/staking/tasks/beneficiary.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import { prepareData, trackCCTX } from "@zetachain/toolkit/helpers";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
console.log(`🔑 Using account: ${signer.address}\n`);

const data = prepareData(
args.contract,
@@ -17,11 +16,15 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const value = parseEther("0");

const tx = await signer.sendTransaction({ data, to, value });
console.log(`
🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
if (args.json) {
console.log(JSON.stringify(tx, null, 2));
} else {
console.log(`🔑 Using account: ${signer.address}\n`);

console.log(`🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
📝 Transaction hash: ${tx.hash}
`);
await trackCCTX(tx.hash);
}
};

task(
@@ -30,4 +33,5 @@ task(
main
)
.addParam("contract", "The address of the contract on ZetaChain")
.addPositionalParam("beneficiary", "The address of the beneficiary");
.addPositionalParam("beneficiary", "The address of the beneficiary")
.addFlag("json", "Output in JSON");
7 changes: 3 additions & 4 deletions omnichain/staking/tasks/deploy.ts
Original file line number Diff line number Diff line change
@@ -54,7 +54,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
}
};

task("deploy", "Deploy the contract", main).addParam(
"chain",
"Chain ID (use btc_testnet for Bitcoin Testnet)"
);
task("deploy", "Deploy the contract", main)
.addParam("chain", "Chain ID (use btc_testnet for Bitcoin Testnet)")
.addFlag("json", "Output in JSON");
14 changes: 9 additions & 5 deletions omnichain/staking/tasks/stake.ts
Original file line number Diff line number Diff line change
@@ -6,20 +6,24 @@ import { prepareData, trackCCTX } from "@zetachain/toolkit/helpers";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
console.log(`🔑 Using account: ${signer.address}\n`);

const data = prepareData(args.contract, ["uint8"], ["1"]);
const to = getAddress("tss", hre.network.name);
const value = parseEther(args.amount);

const tx = await signer.sendTransaction({ data, to, value });
console.log(`
🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
if (args.json) {
console.log(JSON.stringify(tx, null, 2));
} else {
console.log(`🔑 Using account: ${signer.address}\n`);

console.log(`🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
📝 Transaction hash: ${tx.hash}
`);
await trackCCTX(tx.hash);
}
};

task("stake", "Deposit tokens to ZetaChain and stake them", main)
.addParam("contract", "The address of the contract on ZetaChain")
.addParam("amount", "Amount of tokens to send");
.addParam("amount", "Amount of tokens to send")
.addFlag("json", "Output in JSON");
18 changes: 10 additions & 8 deletions omnichain/staking/tasks/unstake.ts
Original file line number Diff line number Diff line change
@@ -6,21 +6,23 @@ import { prepareData, trackCCTX } from "@zetachain/toolkit/helpers";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
console.log(`🔑 Using account: ${signer.address}\n`);

const data = prepareData(args.contract, ["uint8"], ["2"]);
const to = getAddress("tss", hre.network.name);
const value = parseEther("0");

const tx = await signer.sendTransaction({ data, to, value });
console.log(`
🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
if (args.json) {
console.log(JSON.stringify(tx, null, 2));
} else {
console.log(`🔑 Using account: ${signer.address}\n`);

console.log(`🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
📝 Transaction hash: ${tx.hash}
`);
await trackCCTX(tx.hash);
}
};

task("unstake", "Unstake tokens", main).addParam(
"contract",
"The address of the contract on ZetaChain"
);
task("unstake", "Unstake tokens", main)
.addParam("contract", "The address of the contract on ZetaChain")
.addFlag("json", "Output in JSON");
15 changes: 10 additions & 5 deletions omnichain/staking/tasks/withdraw.ts
Original file line number Diff line number Diff line change
@@ -6,22 +6,27 @@ import { prepareData, trackCCTX } from "@zetachain/toolkit/helpers";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
console.log(`🔑 Using account: ${signer.address}\n`);

const data = prepareData(args.contract, ["uint8"], ["4"]);
const to = getAddress("tss", hre.network.name);
const value = parseEther("0");

const tx = await signer.sendTransaction({ data, to, value });
console.log(`
🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
if (args.json) {
console.log(JSON.stringify(tx, null, 2));
} else {
console.log(`🔑 Using account: ${signer.address}\n`);

console.log(`🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
📝 Transaction hash: ${tx.hash}
`);
await trackCCTX(tx.hash);
}
};

task(
"set-withdraw",
"Set the address on a connected chain to which unstaked tokens will be withdrawn",
main
).addParam("contract", "The address of the contract on ZetaChain");
)
.addParam("contract", "The address of the contract on ZetaChain")
.addFlag("json", "Output in JSON");
52 changes: 44 additions & 8 deletions scripts/integration.sh
Original file line number Diff line number Diff line change
@@ -2,24 +2,60 @@

set -e

pushd "./omnichain/swap"
SENDER=0x2cD3D070aE1BD365909dD859d29F387AA96911e1

# pushd "./omnichain/swap"

# yarn

# npx hardhat compile --force

# echo "Testing omnichain Swap"

# OMNI_SWAP_CONTRACT=$(npx hardhat deploy --network zeta_testnet --json | jq -r '.address')
# echo $OMNI_SWAP_CONTRACT

# OMNI_SWAP_TX=$(npx hardhat interact --contract $OMNI_SWAP_CONTRACT --network goerli_testnet --amount 0.01 --recipient $SENDER --destination mumbai_testnet --json | jq -r '.hash')
# echo $OMNI_SWAP_TX
# OMNI_SWAP_CCTX=$(npx hardhat cctx $OMNI_SWAP_TX --json)
# echo $OMNI_SWAP_CCTX

# popd

pushd "./omnichain/staking"

yarn

npx hardhat compile --force

echo "Testing omnichain Swap"
echo "Testing omnichain Staking"

OMNICHAIN_SWAP_CONTRACT=$(npx hardhat deploy --network zeta_testnet --json | jq -r '.address')
OMNI_STAKING_CONTRACT=$(npx hardhat deploy --network zeta_testnet --chain goerli_testnet --json | jq -r '.address')

echo $OMNICHAIN_SWAP_CONTRACT
echo $OMNI_STAKING_CONTRACT

OMNICHAIN_SWAP_TX_SHOULD_SUCCEED=$(npx hardhat interact --contract $OMNICHAIN_SWAP_CONTRACT --network goerli_testnet --amount 0.01 --recipient 0x2cD3D070aE1BD365909dD859d29F387AA96911e1 --destination mumbai_testnet --json | jq -r '.hash')
echo "Setting beneficiary"
OMNI_STAKING_BENEFICIARY_TX=$(npx hardhat set-beneficiary $SENDER --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash')
echo $OMNI_STAKING_BENEFICIARY_TX
OMNI_STAKING_BENEFICIARY_CCTX=$(npx hardhat cctx $OMNI_STAKING_BENEFICIARY_TX --json)
echo $OMNI_STAKING_BENEFICIARY_CCTX

echo $OMNICHAIN_SWAP_TX_SHOULD_SUCCEED
echo "Setting withdraw"
OMNI_STAKING_WITHDRAW_TX=$(npx hardhat set-withdraw --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash')
echo $OMNI_STAKING_WITHDRAW_TX
OMNI_STAKING_WITHDRAW_CCTX=$(npx hardhat cctx $OMNI_STAKING_WITHDRAW_TX --json)
echo $OMNI_STAKING_WITHDRAW_CCTX

OMNICHAIN_SWAP_CCTX_SHOULD_SUCCEED=$(npx hardhat cctx $OMNICHAIN_SWAP_TX_SHOULD_SUCCEED --json)
echo "Stake"
OMNI_STAKING_STAKE_TX=$(npx hardhat stake --amount 0.01 --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash')
echo $OMNI_STAKING_STAKE_TX
OMNI_STAKING_STAKE_CCTX=$(npx hardhat cctx $OMNI_STAKING_STAKE_TX --json)
echo $OMNI_STAKING_STAKE_CCTX

echo $OMNICHAIN_SWAP_CCTX_SHOULD_SUCCEED
echo "Unstake"
OMNI_STAKING_UNSTAKE_TX=$(npx hardhat unstake --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash')
echo $OMNI_STAKING_UNSTAKE_TX
OMNI_STAKING_UNSTAKE_CCTX=$(npx hardhat cctx $OMNI_STAKING_UNSTAKE_TX --json)
echo $OMNI_STAKING_UNSTAKE_CCTX

popd