Skip to content

Commit

Permalink
fix: use static provider for isMultisig
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeday committed Aug 6, 2024
1 parent c484514 commit 665cb59
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 5 additions & 7 deletions features/withdrawals/hooks/useNftDataByTxHash.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useSDK } from '@lido-sdk/react';
import { useLidoSWR } from '@lido-sdk/react';
import { useWithdrawalsContract } from './contract/useWithdrawalsContract';

import { standardFetcher } from 'utils/standardFetcher';
import type { TransactionReceipt } from '@ethersproject/abstract-provider';
import { useCurrentStaticRpcProvider } from 'shared/hooks/use-current-static-rpc-provider';

const EVENT_NAME = 'WithdrawalRequested';

Expand All @@ -15,17 +15,15 @@ type NFTApiData = {

export const useNftDataByTxHash = (txHash: string | null) => {
const { contractRpc, account } = useWithdrawalsContract();
const { providerWeb3 } = useSDK();
const { staticRpcProvider } = useCurrentStaticRpcProvider();

const swrNftApiData = useLidoSWR(
account && txHash && providerWeb3
? ['swr:nft-data-by-tx-hash', txHash, account]
: null,
account && txHash ? ['swr:nft-data-by-tx-hash', txHash, account] : null,
async () => {
if (!txHash || !account || !providerWeb3) return null;
if (!txHash || !account) return null;

const txReciept: TransactionReceipt =
await providerWeb3.getTransactionReceipt(txHash);
await staticRpcProvider.getTransactionReceipt(txHash);

const eventTopic = contractRpc.interface.getEventTopic(EVENT_NAME);
const eventLogs = txReciept.logs.filter(
Expand Down
6 changes: 1 addition & 5 deletions features/wsteth/wrap/hooks/use-wrap-form-processing.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import invariant from 'tiny-invariant';

import { useCallback } from 'react';
import { useSDK } from '@lido-sdk/react';
import { useWeb3 } from 'reef-knot/web3-react';
import { useWrapTxProcessing } from './use-wrap-tx-processing';
import { useTxModalWrap } from './use-tx-modal-stages-wrap';
Expand All @@ -27,7 +26,6 @@ export const useWrapFormProcessor = ({
onRetry,
}: UseWrapFormProcessorArgs) => {
const { account } = useWeb3();
const { providerWeb3 } = useSDK();
const processWrapTx = useWrapTxProcessing();
const { isApprovalNeededBeforeWrap, processApproveTx } = approvalData;
const { txModalStages } = useTxModalWrap();
Expand All @@ -39,8 +37,7 @@ export const useWrapFormProcessor = ({
try {
invariant(amount, 'amount should be presented');
invariant(account, 'address should be presented');
invariant(providerWeb3, 'provider should be presented');
const isMultisig = await isContract(account, providerWeb3);
const isMultisig = await isContract(account, staticRpcProvider);
const willReceive = await wstETHContractRPC.getWstETHByStETH(amount);

if (isApprovalNeededBeforeWrap) {
Expand Down Expand Up @@ -89,7 +86,6 @@ export const useWrapFormProcessor = ({
},
[
account,
providerWeb3,
wstETHContractRPC,
isApprovalNeededBeforeWrap,
txModalStages,
Expand Down
2 changes: 1 addition & 1 deletion shared/hooks/useApprove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const useApprove = (
invariant(account, 'account is required');
await onTxStart?.();
const contractWeb3 = getERC20Contract(token, providerWeb3.getSigner());
const isMultisig = await isContract(account, providerWeb3);
const isMultisig = await isContract(account, staticRpcProvider);

const processApproveTx = async () => {
const tx = await contractWeb3.populateTransaction.approve(
Expand Down

0 comments on commit 665cb59

Please sign in to comment.