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

Raffle Client - Error || Undefined - getting getEntranceFee on the client side #29

Open
dibakarsutradhar opened this issue Jun 16, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dibakarsutradhar
Copy link
Owner

dibakarsutradhar commented Jun 16, 2022

There's no specific error code to this problem other than just simple undefined. The problem could be generated from the Hardhat Local Node and Raffle Contract's ABI.

  1. Hardhat Local Node's accounts are not precisely synchronised with the Metamask wallet in my browser the way I'd have wanted them to be. This is something I should get fixed asap, as it's sort of creating a backlog.

  2. Current deploy scripts for generating abi.json from the Raffle.sol contract is sort of working and again not working as the generated abi format is slightly different.

02-updateUI.ts -

import * as fs from 'fs';
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { stringify } from 'querystring';
import {
  FRONT_END_ABI_FILE,
  FRONT_END_ADDRESSES_FILE,
} from '../helper-hardhat-config';

const updateUI: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers } = hre;
  const chainId: string = '31337';

  if (process.env.UPDATE_FRONT_END) {
    console.log('Updating Front End...');
    const raffle = await ethers.getContract('Raffle');
    const contractAddresses = JSON.parse(
      fs.readFileSync(FRONT_END_ADDRESSES_FILE, 'utf8')
    );
    if (chainId in contractAddresses) {
      if (!contractAddresses[chainId].includes(raffle.address)) {
        contractAddresses[chainId].push(raffle.address);
      }
    } else {
      contractAddresses[chainId] = [raffle.address];
    }

    fs.writeFileSync(
      FRONT_END_ABI_FILE,
      JSON.stringify(raffle.interface)
      // raffle.interface.format(ethers.utils.FormatTypes.json)
    );

    fs.writeFileSync(
      FRONT_END_ADDRESSES_FILE,
      JSON.stringify(contractAddresses)
    );
  }
};

export default updateUI;
updateUI.tags = ['all', 'frontend'];
@dibakarsutradhar dibakarsutradhar added the bug Something isn't working label Jun 16, 2022
@dibakarsutradhar dibakarsutradhar self-assigned this Jun 16, 2022
@dibakarsutradhar
Copy link
Owner Author

Will come back to the client issue after a while. Currently halting the client dev for couple of days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

1 participant