aptos-wallet-adapter icon indicating copy to clipboard operation
aptos-wallet-adapter copied to clipboard

Module not found: Can't resolve 'aptos_dynamic_transaction_composer_bg.wasm'

Open JatSh1804 opened this issue 1 year ago • 4 comments

Have been trying to use the @aptos-wallet-adapter for the last two days, and couldn't get any success. Error:

``Module not found: Can't resolve 'aptos_dynamic_transaction_composer_bg.wasm'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module: ./node_modules/@aptos-labs/ts-sdk/dist/esm/chunk-4PBXTMN3.mjs ./node_modules/@aptos-labs/ts-sdk/dist/esm/index.mjs ./node_modules/@aptos-labs/wallet-adapter-react/node_modules/@aptos-labs/wallet-adapter-core/dist/index.mjs ./node_modules/@aptos-labs/wallet-adapter-react/dist/index.mjs ./app/profile/page.tsx``

Have tried to setup new repo with the latest nextjs version, but still the same error. /app/profile/layout.tsx

'use client'

import { PropsWithChildren } from 'react'
import { PetraWallet } from 'petra-plugin-wallet-adapter'
import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react'
import { WalletSelector } from '@aptos-labs/wallet-adapter-ant-design'
import React from 'react'
import {
  // Aptos,
  // AptosConfig,
  Network,
  // APTOS_COIN,
  // AccountAddressInput,
} from '@aptos-labs/ts-sdk'

const wallets = [new PetraWallet()]
export default function RootLayout({ children }: PropsWithChildren) {
  return (
    <body className="grow">
      <AptosWalletAdapterProvider
        plugins={wallets}
        autoConnect={true}
        dappConfig={{
          network: Network.TESTNET,
          aptosConnectDappId: 'dapp-id',
        }}
      >
        <WalletSelector />
        <div className="mt-16">{children}</div>
      </AptosWalletAdapterProvider>
    </body>
  )
}

/app/profile/page.tsx

import { useWallet, WalletName } from "@aptos-labs/wallet-adapter-react"

const { connect, disconnect, account, connected } = useWallet();
 const handleConnect = async () => {
        try {
            // Change below to the desired wallet name instead of "Petra"
            await connect("Petra" as WalletName<"Petra">);
            console.log('Connected to wallet:', account);
        } catch (error) {
            console.error('Failed to connect to wallet:', error);
        }
    };
    const handleDisconnect = async () => {
        try {
            await disconnect();
            console.log('Disconnected from wallet');
        } catch (error) {
            console.error('Failed to disconnect from wallet:', error);
        }
    };

Have also tried updating the next.config.mjs to allow loading the .wasm file on client side but it's just compiling the route, nothing else. Stack: NextJs 14 (app router)

JatSh1804 avatar Nov 10 '24 09:11 JatSh1804

I have the same issue for the past few days ..

criox4 avatar Nov 10 '24 10:11 criox4

I have the same issue for the past few days ..

It's so frustrating i've even initialized new repos but nothing seems to be working on my system. Even the cloned repo seems to be having this error, Have you tried it?? Btw, are you developing this for the dAppathon by any chance??

JatSh1804 avatar Nov 10 '24 10:11 JatSh1804

I have the same issue for the past few days ..

It's so frustrating i've even initialized new repos but nothing seems to be working on my system. Even the cloned repo seems to be having this error, Have you tried it?? Btw, are you developing this for the dAppathon by any chance??

Even my previous commits are failing to build. I have scoured the net but to no avail. Let's wait for the devs to reply on this.

No no.. Its not for a hackathon. We are creating a web3 application that facilitates transactions, swaps, trades, and bridges, supporting all blockchains.

criox4 avatar Nov 10 '24 10:11 criox4

Hi, thanks for reporting this! The issue was related to a bug in the new Aptos ts-sdk version released a few days ago. We've now released an updated version with a fix (1.32.1), which should resolve the issue.

See related https://github.com/aptos-labs/aptos-ts-sdk/issues/573

0xmaayan avatar Nov 12 '24 03:11 0xmaayan