Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

After getting approved the position it takes approved address, it works fine on rinkeby but on polygon chain it isnt #1

Open
hamzamughal74 opened this issue Jul 22, 2022 · 1 comment

Comments

@hamzamughal74
Copy link

hamzamughal74 commented Jul 22, 2022

After getting approved the position it takes approved address, it works fine on rinkeby but on polygon chain it isnt getting updated approved address , i check from contract on polygonscan there i'm getting right approved address

https://github.com/vbstreetz/uniswap-v3-staker-frontend/blob/4bd4a74a741b3d363f7e05468dd8139ee2cdf566/src/modals/StakeModal.tsx#L48

@hamzamughal74 hamzamughal74 changed the title After getting approved the position it takes approved address, it works fine on rinkeby After getting approved the position it takes approved address, it works fine on rinkeby but on polygon chain it isnt Jul 22, 2022
@hamzamughal74
Copy link
Author

hamzamughal74 commented Jul 22, 2022

Basically i have changed the flow , i'm now initiating all transaction for staking on one click but one after one
and not getting approved address updated after approved , but if i call stake() function again then it gets right approvedAddress
can you please have a look on this?
(it works fine on rinkeby but not on polygon chain, i'm using right addresses issue is somewhere here in my code)

const stake = useCallback(async () => {
    const load = async () => {
      if (!(stakingRewardsContract && nftManagerPositionsContract)) return;
      
      const [approvedAddress, owner] = await Promise.all([
        nftManagerPositionsContract.getApproved(position.tokenId),
        nftManagerPositionsContract.ownerOf(position.tokenId),
      ]);
      position.owner = owner;
      if (owner === stakingRewardsContract.address) {
       await stakee(() => {});
        // setActiveStep(2);
      } else if (approvedAddress === stakingRewardsContract.address) {
       await transfer(() => {

          load();
        });

        // setActiveStep(1);
      } else {
        await approve(() => {
          
          load();
        });
      }
    };
    load();
    // history.push(`/stake/${position.tokenId}`);
  }, [position.tokenId, history]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant