Skip to content

Commit

Permalink
Updates the Paymaster tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesduncombe committed Oct 31, 2023
1 parent d0936a0 commit 48c0275
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions tasks/paymaster.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { task } from "hardhat/config";
import { task, types } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { parseEther } from "ethers/lib/utils";
import { deploymentSalt } from "../src/utils";
import { Paymaster } from "../typechain/hardhat-diamond-abi/HardhatDiamondABI.sol";
import { RelayHub } from "@opengsn/contracts";
import { BigNumber } from "ethers";

// Tasks.

Expand Down Expand Up @@ -33,27 +34,31 @@ task("paymaster-update-facets", "Updates facets of our Paymaster")
});


interface PaymasterFundParams { }
interface PaymasterFundParams {
readonly amount: BigNumber;
}

task("paymaster-fund", "Funds the Paymaster")
.setAction(async (_params: PaymasterFundParams, hre) => {
const { deployments, getNamedAccounts } = hre;
// Who will juice it?
.addParam("amount", "The amount of ETH to fund the Paymaster with", undefined, types.int)
.setAction(async (params: PaymasterFundParams, hre) => {
const { ethers, getNamedAccounts } = hre;
const { issuerMember } = await getNamedAccounts();
const issuerMemberSigner = await ethers.getSigner(issuerMember);

// yeeettttttt this out...
const relayHubAddress = "0x3232f21A6E08312654270c78A773f00dd61d60f5";
const { address: paymasterAddress } = await deployments.get("Paymaster");
// Get a handle to the paymaster contract.
const paymaster = await ethers.getContract<Paymaster>("Paymaster");
const issuerPaymaster = paymaster.connect(issuerMemberSigner);

const RelayHub = await hre.ethers.getContractFactory("RelayHub");
const relayHub = await RelayHub.attach(relayHubAddress);
// Get the relay hub address using the address stored in the paymaster.
const relayHubAddress = await paymaster.getRelayHub();
const relayHub = await ethers.getContractAt<RelayHub>("RelayHub", relayHubAddress);

// params...
const tx = await relayHub.depositFor(paymasterAddress, { value: parseEther("0.1") });
// Fund the paymaster.
const tx = await issuerPaymaster.deposit({ value: params.amount });
await tx.wait();

console.log('Paymaster balance:', await relayHub.balanceOf(paymasterAddress));
// console.log('Admin wallet balance', await provider.getBalance(admin.address));
console.log('Paymaster balance with relay hub:', await relayHub.balanceOf(paymaster.address));
console.log('Admin wallet balance', (await issuerMemberSigner.getBalance()).toString());
});

// Reusable functions and constants.
Expand Down

0 comments on commit 48c0275

Please sign in to comment.