aptos-labs / aptos-wallet-adapter

A monorepo modular wallet adapter for Aptos applications
https://aptos-labs.github.io/aptos-wallet-adapter/
Apache License 2.0
92 stars 100 forks source link

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

Open JatSh1804 opened 1 week ago

JatSh1804 commented 1 week ago

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)

criox4 commented 1 week ago

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

JatSh1804 commented 1 week ago

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??

criox4 commented 1 week ago

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.

0xmaayan commented 1 week ago

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