Skip to content

Commit

Permalink
Merge pull request #37 from gnosischain/dev
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
giacomognosis authored May 20, 2024
2 parents 54f4d2d + be9f414 commit a0fa79e
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 17 deletions.
6 changes: 2 additions & 4 deletions app/connect/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import Image from "next/image";
import { useAccount, useConnect } from "wagmi";
import Link from "next/link";

const connectorImages = ["coinbaseWallet.png", "walletConnect.png", "metaMask.png"];

export default function Page() {
const account = useAccount();
const { connectors, connect } = useConnect();
Expand All @@ -29,11 +27,11 @@ export default function Page() {
</Link>
</div>
<p className="text-2xl lg:text-3xl text-black font-bold mt-8 w-1/2 text-center">Choose your preferred wallet</p>
<div className="w-full flex flex-col divide-slate-700 divide-y mt-8">
<div className="w-full flex flex-col divide-slate-700 divide-y mt-8 overflow-y-auto">
{connectors.map((connector, index) => {
return (
<div className="flex w-full justify-between items-center text-black hover:bg-[#E8E1CF] py-4 p-2 first:rounded-t-lg last:rounded-b-lg" key={connector.uid} onClick={() => connect({ connector })}>
{connector.name} <Image src={connectorImages[index]} alt={connector.id} width={48} height={24} />
{connector.name} <Image src={"./"+connector.id+".png"} alt={connector.id} width={48} height={24} />
</div>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function Dashboard() {
<div className="flex flex-col gap-y-4 justify-between items-start mt-4 lg:mt-0">
<div>
Balance:
<p className="font-bold text-xl lg:text-3xl">{Math.round(Number(formatEther(balance || BigInt(0))))} GNO</p>
<p className="font-bold text-xl lg:text-3xl">{Number(formatEther(balance || BigInt(0))).toFixed(3)} GNO</p>
</div>
<div>
Network:
Expand Down
2 changes: 1 addition & 1 deletion components/validator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function Validator() {
) : step === "validated" ? (
<div className="w-full flex flex-col items-center">
{statuses && statuses.length > 0 ? (
<div>
<div className="overflow-y-auto">
{statuses.map((status, index) => (
<div key={index}>
<h2>
Expand Down
2 changes: 1 addition & 1 deletion components/withdrawal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function Withdrawal() {
<div className="w-full flex text-sm items-center justify-between">
<div className="w-full flex gap-x-2">
Claimable balance:
<div className="flex font-bold items-center">{Math.round(Number(formatEther(claimBalance || BigInt(0))))} GNOS</div>
<div className="flex font-bold items-center">{Number(formatEther(claimBalance || BigInt(0))).toFixed(3)} GNOS</div>
<button className="text-[#DD7143] underline hover:text-[#E07F55]" onClick={onClaim}>
Manual claim
</button>
Expand Down
14 changes: 7 additions & 7 deletions hooks/use-deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function useDeposit() {
async (deposits: DepositDataJson[], balance: bigint) => {
let newDeposits = [];
let hasDuplicates = false;
let _isBatch = false;
if (contractConfig) {
const checkJsonStructure = (depositDataJson: DepositDataJson) => {
return depositDataJson.pubkey && depositDataJson.withdrawal_credentials && depositDataJson.amount && depositDataJson.signature && depositDataJson.deposit_message_root && depositDataJson.deposit_data_root && depositDataJson.fork_version;
Expand Down Expand Up @@ -87,9 +88,9 @@ function useDeposit() {
const wc = newDeposits[0].withdrawal_credentials;

// batch processing necessary for both single deposit and batch deposit for same withdrawal_credentials
const isBatch = newDeposits.every((d) => d.withdrawal_credentials === wc);
_isBatch = newDeposits.every((d) => d.withdrawal_credentials === wc);

if (isBatch && newDeposits.length > 128) {
if (_isBatch && newDeposits.length > 128) {
throw Error("Number of validators exceeds the maximum batch size of 128. Please upload a file with 128 or fewer validators.");
}

Expand All @@ -115,7 +116,7 @@ function useDeposit() {
}
}

return { deposits: newDeposits, hasDuplicates, isBatch };
return { deposits: newDeposits, hasDuplicates, _isBatch };
},
[account, contractConfig, balance]
);
Expand All @@ -130,10 +131,11 @@ function useDeposit() {
} catch (error) {
throw Error("Oops, something went wrong while parsing your json file. Please check the file and try again.");
}
const { deposits, hasDuplicates, isBatch } = await validate(data, balance || BigInt(0));
const { deposits, hasDuplicates, _isBatch } = await validate(data, balance || BigInt(0));
console.log(_isBatch);
setDeposits(deposits);
setHasDuplicates(hasDuplicates);
setIsBatch(isBatch);
setIsBatch(_isBatch);
} else {
setDeposits([]);
setHasDuplicates(false);
Expand Down Expand Up @@ -171,8 +173,6 @@ function useDeposit() {
data += deposit.signature;
data += deposit.deposit_data_root;

console.log(data);

try {
writeContract({ address: contractConfig.addresses.token, abi: ERC677ABI, functionName: "transferAndCall", args: [contractConfig.addresses.deposit, depositAmountBN, `0x${data}`] });
} catch (error) {
Expand Down
File renamed without changes
File renamed without changes
Binary file added public/io.rabby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion utils/fetchEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GetPublicClientReturnType } from "wagmi/actions";
import claimRegistryABI from "./abis/claimRegistry";
import depositABI from "./abis/deposit";

const BLOCK_RANGE_SIZE = 1000000;
const BLOCK_RANGE_SIZE = 100000;

export async function fetchRegister(claimRegistryAddress: Address, userAddress: Address, fromBlock: bigint, client: GetPublicClientReturnType) {
if (!client) return [];
Expand Down
3 changes: 1 addition & 2 deletions wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { coinbaseWallet, metaMask, walletConnect } from "wagmi/connectors";

export const config = createConfig({
chains: [gnosis, gnosisChiado],
multiInjectedProviderDiscovery: false,
connectors: [coinbaseWallet({ appName: "Gnosis Deposit" }), walletConnect({ projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID || "" }), metaMask({dappMetadata: {name: "Gnosis Deposit"}})],
connectors: [coinbaseWallet({ appName: "Gnosis Deposit" }), walletConnect({ projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID || "" })],
ssr: true,
transports: {
[gnosis.id]: http("https://rpc.gnosischain.com/"),
Expand Down

0 comments on commit a0fa79e

Please sign in to comment.