Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 7 additions & 3 deletions src-ts/cli/distributeRewards.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dotenv from "dotenv";
import yargs from "yargs";
import { JsonRpcProvider } from "@ethersproject/providers";
import { Wallet } from "ethers";
import { ethers, Wallet } from "ethers";
import { distributeRewards } from "../lib";
dotenv.config();

Expand All @@ -13,14 +13,18 @@ const options = yargs(process.argv.slice(2))
.options({
rpcURL: { type: "string", demandOption: true },
rewardDistAddr: { type: "string", demandOption: true },
minBalanceEther: { type: "number", demandOption: false, default: 0 },
minBalance: { type: "string", demandOption: false, default: "10000 wei" },
})
.parseSync();

(async () => {
const wei = ethers.utils.parseUnits(
options.minBalance.split(" ")[0],
options.minBalance.split(" ")[1]
);
await distributeRewards(
new Wallet(CHILD_CHAIN_PK, new JsonRpcProvider(options.rpcURL)),
options.rewardDistAddr,
options.minBalanceEther
wei
);
})();
6 changes: 2 additions & 4 deletions src-ts/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ export const getRecipientsAndWeights = async (
export const distributeRewards = async (
connectedSigner: Wallet,
distributorAddr: string,
_minBalanceEther?: number
_minBalanceWei?: BigNumber
) => {
const chainId = await connectedSigner.getChainId();
const minBalanceWei = _minBalanceEther
? utils.parseEther(_minBalanceEther.toString())
: BigNumber.from(0);
const minBalanceWei = _minBalanceWei || BigNumber.from(0);
const distributor = RewardDistributor__factory.connect(
distributorAddr,
connectedSigner
Expand Down
Loading