“ESM integration proposal for Wasm” is not supported currently in Vite ReactJS and Typescript

  Kiến thức lập trình

I am using ReactJS, and Typescript with Vite and want to get the address from mnemonic I create a function for this generateAddressFromMnomic which takes a mnemonic string as a parameter but when I pass ecc which is imported from tiny-secp256k1 and applies in BIP32Factory I got the vite error “ESM integration proposal for Wasm” is not supported currently in vite react and typescript which is showing in below image. I also solved it with install wasm and config with vite plugin but got the same error. How can this issue be addressed using bitcoinjs-lib, bip32, and bip39?

import * as bip39 from 'bip39';
import * as bitcoin from 'bitcoinjs-lib';
import { BIP32Factory } from 'bip32';
import * as ecc from 'tiny-secp256k1';

const bip32 = BIP32Factory(ecc);

export const generateAddressFromMnemonic = async (mnemonic: string) => {
    const seed = bip39.mnemonicToSeedSync(mnemonic);
    const root = bip32.fromSeed(seed);
    const { address } = bitcoin.payments.p2pkh({ pubkey: root.derivePath("m/44'/1'/0'/0/0").publicKey });
    return address;
};

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT