Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonmanRolls committed Jan 24, 2024
1 parent a81f836 commit 3f1d81e
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 387 deletions.
2 changes: 0 additions & 2 deletions cypress/plugins/delegateBySig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ module.exports = (on) => {
accounts: {},
};

console.log("forkId: ", forkId);

const wallet = ethers.Wallet.createRandom();

await fetch(
Expand Down
6 changes: 0 additions & 6 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ module.exports = (on, config) => {
process.env.NETWORK = network;
process.env.PASSWORD = password;

console.log("setMetamaskData: ", {
secretWords,
network,
password,
});

return true;
},
});
Expand Down
6 changes: 0 additions & 6 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ async function handleDelegate(params) {
const tx = await contract.delegateBySig(delegatee, nonce, expiry, v, r, s, {
gasPrice: "0",
});
console.log("tx: ", tx);
return tx.hash;
}

Expand All @@ -118,9 +117,6 @@ async function handleDelegateRequest(req) {
},
};

console.log(contract);
console.log("req: ", req);

if (req.method === "OPTIONS") {
response.headers["Access-Control-Allow-Methods"] = "POST";
response.headers["Access-Control-Allow-Headers"] = "Content-Type";
Expand Down Expand Up @@ -169,8 +165,6 @@ Cypress.Commands.add("interceptDelegateBySig", () => {
const { wallet, forkId } = Cypress.env("DELEGATE_WALLET");
const rpcUrl = `https://rpc.tenderly.co/fork/${forkId}`;

console.log("wallt and rpcUrl", wallet, rpcUrl);

const provider = new ethers.providers.JsonRpcProvider(rpcUrl, CHAIN_ID);
signer = new ethers.Wallet(wallet, provider);
contract = new ethers.Contract(TOKEN_ADDRESS, ABI, signer);
Expand Down
17 changes: 0 additions & 17 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import {
import EnteryourDelegate from "./pages/EnteryourDelegate";
import Home from "./pages/Home";
import { useGetDelegates, useQueryString } from "./utils/hooks";
import { hasClaimed } from "./utils/token";
import { initWeb3Read } from "./web3modal";
import { addressDetails, ep2AddressDetails } from "./apollo";
import { getClaimData } from "./utils/utils";

const PROJECT_ID = "02f438d1701ea8029113972850066224";

Expand Down Expand Up @@ -106,10 +103,6 @@ function PrivateRoute({ component: Component, type = "mainnet", ...rest }) {
history.push("/dashboard");
return;
}
const isClaimed = await hasClaimed(address, type);
if (isClaimed) {
history.push("/dashboard");
}
} catch (error) {
console.error("Private Route error: ", error);
history.push("/dashboard");
Expand Down Expand Up @@ -161,16 +154,6 @@ function App() {
setDelegateChoice(address, delegate);
setDelegateReferral(delegate);
}

// const run = async () => {
// if (address) {
// const claimData = await getClaimData(address);
// addressDetails(claimData);
// const ep2ClaimData = await getClaimData(address, "ep2");
// ep2AddressDetails(ep2ClaimData);
// }
// };
// run();
}, [address]);

useGetDelegates(isConnected);
Expand Down
12 changes: 1 addition & 11 deletions src/pages/DelegateRanking.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,7 @@ const FreeDelegationContentBox = styled(ContentBox)`
justify-content: space-between;
`;

function CurrentDelegation({
account,
tokens,
selection,
delegatedTo,
setRenderKey,
}) {
console.log("delegatedTo: ", delegatedTo);
function CurrentDelegation({ tokens, selection, delegatedTo }) {
let text = (
<>
<span>
Expand Down Expand Up @@ -420,9 +413,6 @@ const ChooseYourDelegate = () => {
chooseData.delegateSigDetails;
const { selectedDelegate } = chooseData;

console.log("chooseData: ", chooseData);
console.log("balanceLoading: ", balanceLoading);

const history = useHistory();
const location = useLocation();

Expand Down
3 changes: 0 additions & 3 deletions src/pages/DelegateTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const delegateToAddress = async (
if (!delegateAddress || delegateAddress === "") {
throw "No chosen delegate";
}
console.log("probe");
const tx =
sigDetails && sigDetails.canSign
? await delegateBySig(
Expand Down Expand Up @@ -94,8 +93,6 @@ const ENSTokenClaim = ({ location }) => {
message: "",
});

console.log("address: ", address);

useEffect(() => {
let timeout;
const run = async () => {
Expand Down
10 changes: 2 additions & 8 deletions src/utils/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export const useGetDelegates = (isConnected) => {

useEffect(() => {
const provider = getEthersProvider(walletProvider);
console.log("walletProvider: ", walletProvider);

const run = async () => {
const delegateDataRaw = await Promise.all([
Expand Down Expand Up @@ -288,7 +287,6 @@ export const useGetTokens = (address) => {
useEffect(() => {
async function run() {
const balance = await ENSTokenContract.balanceOf(address);
console.log("contract balance: ", balance);
setBalance(balance);
setLoading(false);
}
Expand All @@ -313,11 +311,7 @@ export const useGetDelegatedTo = (address) => {

useEffect(() => {
async function run() {
console.log("delegatedToAddressContract: ", ENSTokenContract);
console.log("delegatedToAddressInput: ", address);
console.log("delegatedToAddressWallet: ", walletProvider);
const delegatedToAddress = await ENSTokenContract.delegates(address);
console.log("delegatedToAddress: ", delegatedToAddress);
setDelegatedToAddress(delegatedToAddress);
setLoading(false);
}
Expand Down Expand Up @@ -358,8 +352,8 @@ export const useGetTransactionDone = (txHash) => {
try {
const tx = await provider.getTransaction(txHash);
setTransactionDone(tx?.blockNumber !== null);
} catch {
console.log("caught error");
} catch (e) {
console.error(e);
}
}
if (txHash) {
Expand Down
145 changes: 0 additions & 145 deletions src/utils/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,94 +16,6 @@ import {
} from "./consts";
import { sendToDelegateJsonRpc } from "./utils";

const testingMerkleRoot = {
root: "0xdc11fa9fd3249811b64f70f9e0e8fd906652eece35cc97ea99fec6e5eeb7946c",
shardNybbles: 1,
total: "25000000000000000000000000",
};

export const hasClaimed = async (address, type = "mainnet") => {
// try {
// const response = await fetch(generateMerkleShardUrl(address, type));
// if (!response.ok) {
// throw new Error("error getting shard data");
// }
// const shardJson = await response.json({ encoding: "utf-8" });
// let root, shardNybbles, total;
// if (process.env.REACT_APP_STAGE === "testing" && type === "ep2")
// ({ root, shardNybbles, total } = testingMerkleRoot);
// else if (type === "ep2") ({ root, shardNybbles, total } = ep2MerkleRoot);
// else ({ root, shardNybbles, total } = merkleRoot);
// const shardedMerkleTree = new ShardedMerkleTree(
// () => shardJson,
// shardNybbles,
// root,
// BigNumber.from(total)
// );
// const provider = getEthersProvider();
// const signer = provider.getSigner();
// const airdropContract =
// type === "mainnet"
// ? new Contract(getENSTokenContractAddress(), ENSTokenAbi.abi, signer)
// : new Contract(
// getMerkleAirdropContractAddress(),
// MerkleAirdropAbi.abi,
// signer
// );
// const [entry, proof] = shardedMerkleTree.getProof(address);
// const index = getIndex(address, entry, proof);
// const result = await airdropContract.isClaimed(index);
// return result;
// } catch (error) {
// return false;
// }
};

export const submitClaim = async (
balance,
proof,
address,
setClaimState,
history,
type = "mainnet"
) => {
// try {
// const provider = getEthersProvider();
// const signer = provider.getSigner();
// let airdropContractAddress;
// let abi;
// let claimTokensFunc;
// if (type === "mainnet") {
// airdropContractAddress = getENSTokenContractAddress();
// abi = ENSTokenAbi.abi;
// claimTokensFunc = (claimTokens) =>
// claimTokens(balance, address, proof, { gasLimit: GAS_LIMIT });
// } else {
// airdropContractAddress = getMerkleAirdropContractAddress();
// abi = MerkleAirdropAbi.abi;
// claimTokensFunc = (claimTokens) =>
// claimTokens(address, balance, proof, { gasLimit: GAS_LIMIT });
// }
// const airdropContract = new Contract(airdropContractAddress, abi, signer);
// airdropContract.connect(signer);
// const result = await claimTokensFunc(airdropContract.claimTokens);
// await result.wait(1);
// setClaimState({
// state: "SUCCESS",
// message: "",
// });
// return setTimeout(() => {
// history.push((type === "mainnet" ? "" : "/ep2") + "/success");
// }, 2000);
// } catch (error) {
// console.error(error);
// setClaimState({
// state: "ERROR",
// message: error,
// });
// }
};

export async function delegate(
address,
setClaimState,
Expand Down Expand Up @@ -204,60 +116,3 @@ export async function delegateBySig(
});
}
}

export const handleClaim = async (
address,
setClaimState,
history,
type = "mainnet"
) => {
// try {
// setClaimState({
// state: "LOADING",
// message: "",
// });
// let outputAddress;
// let provider = getEthersProvider();
// let displayName;
// if (type === "mainnet") {
// displayName = getDelegateChoice(address);
// if (!displayName) {
// throw "No chosen delegate";
// }
// } else {
// displayName = address;
// }
// if (displayName.includes(".eth")) {
// outputAddress = await provider.resolveName(displayName);
// } else {
// outputAddress = displayName;
// }
// const response = await fetch(generateMerkleShardUrl(address, type));
// if (!response.ok) {
// throw new Error("error getting shard data");
// }
// const shardJson = await response.json({ encoding: "utf-8" });
// const { root, shardNybbles, total } = merkleRoot;
// const shardedMerkleTree = new ShardedMerkleTree(
// () => shardJson,
// shardNybbles,
// root,
// BigNumber.from(total)
// );
// const [entry, proof] = shardedMerkleTree.getProof(address);
// return await submitClaim(
// entry.balance,
// proof,
// outputAddress,
// setClaimState,
// history,
// type
// );
// } catch (error) {
// console.error(error);
// setClaimState({
// state: "ERROR",
// message: error,
// });
// }
};
Loading

0 comments on commit 3f1d81e

Please sign in to comment.