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

get_starknet_core_1.getStarknet is not a function #245

Closed
iddriss opened this issue May 25, 2023 · 7 comments
Closed

get_starknet_core_1.getStarknet is not a function #245

iddriss opened this issue May 25, 2023 · 7 comments

Comments

@iddriss
Copy link
Contributor

iddriss commented May 25, 2023

While using the useConnectors() hook, the following error occurred when accessing connector methods after upgrading to version v0.17.1 from v0.14.6

Screenshot 2023-05-25 at 11 51 37 AM

It appears the error only occurs for methods that use ensureWallet(). The error indicates that .getStarknet is not a function, however tracing back to the line show .getStarknet is in fact a function.

Screenshot 2023-05-25 at 11 57 08 AM
@fracek
Copy link
Contributor

fracek commented May 25, 2023

It looks like something strange with get-starknet or get-starknet-core. Requires further investigation.

@fracek
Copy link
Contributor

fracek commented May 25, 2023

I tried to reproduce the issue with the following steps:

  • create a new project with npx create-starknet, selecting the next.js template
  • update the @starknet-react/core version to '^0.17.2'
  • run npm update
  • check that the lock file contains the updated version of starknet react
  • load the main page npm run dev and connect the wallet. The WalletBar component uses useConnectors so it should trigger this issue.

Unfortunately I did not get any error. Can you try to run the same steps as me and see if there is any issue?

@iddriss
Copy link
Contributor Author

iddriss commented May 26, 2023

Alright, I'll try that

@fracek
Copy link
Contributor

fracek commented May 27, 2023

Are you using create-react-app by any chance? In that case, it could be this issue facebook/create-react-app#12021

If you attach a debugger in the browser, you should see something like this (notice the .cjs extension)
2023-05-27-113234_649x347_scrot

@fracek
Copy link
Contributor

fracek commented May 27, 2023

I was able to fix the issue my monkey patching the webpack config used by cra. Here is the commit that shows exactly how to do it

@iddriss
Copy link
Contributor Author

iddriss commented May 31, 2023

I was able to fix the issue my monkey patching the webpack config used by cra. Here is the commit that shows exactly how to do it

This fixed my issue. Thanks for helping with the problem.

@iddriss iddriss closed this as completed May 31, 2023
@iddriss
Copy link
Contributor Author

iddriss commented Jun 8, 2023

Ended up using this

facebook/create-react-app#12700 (comment)

somehow the cjs file was still processed as a static file after building . Works perfectly on while using running the start script.

export default {
  webpack: {
    configure: config => ({
      ...config,
      module: {
        ...config.module,
        rules: config.module.rules.map(rule => {
          if (rule.oneOf instanceof Array) {
            // eslint-disable-next-line no-param-reassign
            rule.oneOf[rule.oneOf.length - 1].exclude = [
              /\.(js|mjs|jsx|cjs|ts|tsx)$/,
              /\.html$/,
              /\.json$/,
            ];
          }
          return rule;
        }),
      },
    }),
  },
};

@fracek fracek changed the title error in InjectedConnector.ensureWallet() after upgrading to 0.17.1 get_starknet_core_1.getStarknet is not a function Jun 23, 2023
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

2 participants