Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

use arbitrum for submissions on ethereum vaults #659

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions packages/web/src/contracts/write/LogClaim.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { HATSVaultV1_abi, HATSVaultsRegistry_abi } from "@hats.finance/shared";
import { IVault } from "types";
import { IS_PROD } from "settings";
import * as wagmiChains from "@wagmi/chains";

import { switchNetworkAndValidate } from "utils/switchNetwork.utils";
import { useContractWrite, useNetwork } from "wagmi";

Expand All @@ -14,8 +17,10 @@ export class LogClaimContract {
* @param vault - The selected vault to send the claim
*/
static hook = (vault?: IVault) => {
const DEFAULT_NETWORK_TO_USE = IS_PROD ? wagmiChains.arbitrum.id as number : wagmiChains.sepolia.id as number;
let useChaniId = DEFAULT_NETWORK_TO_USE;
vault!.chainId != wagmiChains.mainnet.id ? useChaniId = vault!.chainId:null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for determining the default network to use (DEFAULT_NETWORK_TO_USE) and the assignment of useChaniId based on the vault's chain ID is implemented. However, there's a typo in the variable name useChaniId which should likely be useChainId. This typo could lead to confusion and potential bugs in the future.

- let useChaniId = DEFAULT_NETWORK_TO_USE;
+ let useChainId = DEFAULT_NETWORK_TO_USE;

Additionally, the ternary operation for setting useChainId based on the vault's chain ID is a bit unconventional. Consider simplifying this logic for clarity and maintainability.

- vault!.chainId != wagmiChains.mainnet.id ? useChaniId = vault!.chainId:null;
+ if (vault?.chainId && vault.chainId !== wagmiChains.mainnet.id) {
+     useChainId = vault.chainId;
+ }

const { chain } = useNetwork();

const contractAddress = vault?.master.address ?? "";
const registryAbi = vault?.version === "v1" ? HATSVaultV1_abi : HATSVaultsRegistry_abi;
const method = vault?.version === "v1" ? "claim" : "logClaim";
Expand All @@ -32,7 +37,7 @@ export class LogClaimContract {
...claim,
send: async (data: string) => {
if (!vault) return;
await switchNetworkAndValidate(chain!.id, vault!.chainId as number);
await switchNetworkAndValidate(chain!.id, useChaniId);

return claim.write!({ recklesslySetUnpreparedArgs: [data] });
},
Expand Down
Loading