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

Bip39.ValidateMnemonic() always returns false in react #193

Open
onyxaudit opened this issue Mar 3, 2024 · 3 comments
Open

Bip39.ValidateMnemonic() always returns false in react #193

onyxaudit opened this issue Mar 3, 2024 · 3 comments

Comments

@onyxaudit
Copy link

here is the code

const bip39 = require("bip39")

const hey = () =>{
const worddd = 'arrow wear carbon enact shadow expand sword custom tape ice display deliver'
const yrsss = bip39.validateMnemonic(worddd)
if (yrsss) {
console.log(true)
}
}

hey()

@zaidmstrr
Copy link

Its returning 'true' in my case. Check your system and try again.

@GildedPleb
Copy link

Returns false for me as well.
Firefox 123.01
Chrome 122.0.6
MacOS Sonoma 14.3.1

vite react swc

@GildedPleb
Copy link

GildedPleb commented May 1, 2024

In vite, i had to add this to get it to work:

npm i buffer

// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
optimizeDeps: {
include: ["bip39"],
},
resolve: {
alias: {
buffer: "buffer", // Ensures that imports/requires of 'buffer' are aliased to the 'buffer' package
},
},
});

// src/main.tsx
import "./index.css";

// eslint-disable-next-line unicorn/prefer-node-protocol, node/prefer-global/buffer
import { Buffer } from "buffer";
import React from "react";
import ReactDOM from "react-dom/client";

import App from "./app";
window.Buffer = Buffer;

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
ReactDOM.createRoot(document.querySelector("#root")!).render(
<React.StrictMode>

</React.StrictMode>,
);

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

3 participants