metaplex-foundation / js-examples

Examples and Starter Kits using the new JS SDK
MIT License
79 stars 92 forks source link

Error when signing with Phantom wallet: Caused By: Error: signature must be base58 encoded: [object Object] #39

Closed yukosgiti closed 1 year ago

yukosgiti commented 1 year ago
image

Hello, I am trying to make a simple UI for me to create collections and so far I have these:

// inside jsx component
const connection = new Connection("https://api.devnet.solana.com/");
const metaplex = new Metaplex(connection, { cluster: "devnet" }).use(
  walletAdapterIdentity(wallet)
)
const handleClick = async (e: any) => {
    if (!metaplex || !wallet.publicKey) return;

    const { nft: collectionNft } = await metaplex.nfts().create({
      name: "Test,
      uri: "<pinata json url>",
      sellerFeeBasisPoints: 0,
      isCollection: true,
    });
    console.log({ collectionNft });
  };
);

When I press a button the above function is called. It correctly opens up Phantom wallet for approval however when I approve I get the above error.

I am using Phantom Wallet using solana/web3 and useWallet from @solana/wallet-adapter-reactlike so:

import {
  ConnectionProvider,
  WalletProvider,
} from "@solana/wallet-adapter-react";
import {
  PhantomWalletAdapter,
} from "@solana/wallet-adapter-wallets";

const WalletProvider = () => {
 const endpoint = useMemo(() => clusterApiUrl(network), [network]);
  const wallets = useMemo(
    () => [
      new PhantomWalletAdapter(),
    ],
    [network]
  );
return (
    <ConnectionProvider endpoint={endpoint}>
      <WalletProvider wallets={wallets} autoConnect>
        {children}
      </WalletProvider>
    </ConnectionProvider>
  );
}

Here is phantom wallet UI

image

My version is: "@metaplex-foundation/js": "^0.18.3" Is this an issue with Metaplex of Phantom Wallet? Any idea how can I fix it?

yukosgiti commented 1 year ago

Apparently, it actually minted the nfts? I have like 10 of these!

yukosgiti commented 1 year ago

I was using an older version of solana wallet related libraries. When I updated them to be the latest it fixed all the problems

"@solana/wallet-adapter-base"
"@solana/wallet-adapter-react"
"@solana/wallet-adapter-react-ui"
"@solana/wallet-adapter-wallets"
"@solana/web3.js"
"@project-serum/anchor"