dsa-connectors/test/arbitrum/arb-claim/test.ts

80 lines
2.7 KiB
TypeScript
Raw Normal View History

2023-04-19 21:18:08 +00:00
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
2023-04-20 11:56:45 +00:00
import { ethers } from "hardhat";
2023-04-19 21:18:08 +00:00
import { ConnectV2ArbitrumAirdrop, ConnectV2ArbitrumAirdrop__factory } from "../../../typechain";
2023-04-20 11:56:45 +00:00
import hre from "hardhat";
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import { encodeSpells } from "../../../scripts/tests/encodeSpells";
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { addresses } from "../../../scripts/tests/arbitrum/addresses";
import { abis } from "../../../scripts/constant/abis";
2023-04-19 21:18:08 +00:00
describe("Arbitrum Airdrop Claim Test", () => {
let signer: SignerWithAddress;
let signer_user: any;
const user = "0x30c3D961a21c2352A6FfAfFd4e8cB8730Bf82757";
2023-04-20 11:56:45 +00:00
const connectorName = "arbitrum-airdrop";
let dsaWallet0: any;
before(async () => {
[signer] = await ethers.getSigners();
});
2023-04-19 21:18:08 +00:00
describe("Arbitrum Airdrop Functions", () => {
let contract: ConnectV2ArbitrumAirdrop;
before(async () => {
await hre.network.provider.request({
method: "hardhat_reset",
params: [
{
forking: {
//@ts-ignore
jsonRpcUrl: hre.config.networks.hardhat.forking.url,
2023-04-20 11:56:45 +00:00
blockNumber: 70606643,
},
},
],
2023-04-19 21:18:08 +00:00
});
const deployer = new ConnectV2ArbitrumAirdrop__factory(signer);
contract = await deployer.deploy();
await contract.deployed();
console.log("Contract deployed at: ", contract.address);
2023-04-20 11:56:45 +00:00
await deployAndEnableConnector({
connectorName,
contractArtifact: ConnectV2ArbitrumAirdrop__factory,
signer: signer,
connectors: await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2),
});
2023-04-19 21:18:08 +00:00
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [user],
});
signer_user = await ethers.getSigner(user);
2023-04-20 11:56:45 +00:00
dsaWallet0 = await buildDSAv2(user);
2023-04-19 21:18:08 +00:00
});
2023-04-20 11:56:45 +00:00
it("Claims Arbitrum Airdrop and checks claimable tokens", async () => {
const claimableBefore = await contract.claimableArbTokens(user);
console.log("Claimable tokens before: ", claimableBefore.toString());
const spells = [
{
connector: connectorName,
method: "claimAirdrop",
args: ["0"],
},
];
const tx = await dsaWallet0.connect(signer_user).cast(...encodeSpells(spells), user);
await tx.wait();
const claimableAfter = await contract.claimableArbTokens(user);
console.log("Claimable tokens after: ", claimableAfter.toString());
});
2023-04-19 21:18:08 +00:00
});
});