Bonfida / sns-sdk

Solana Name Service SDKs monorepo
https://sns.id/
MIT License
34 stars 28 forks source link

Conflict with @solflare-wallet/utl-sdk #74

Closed KoenRijpstra closed 4 months ago

KoenRijpstra commented 4 months ago

Using a clean next project and installing both @solflare-wallet/utl-sdk and @bonfida/spl-name-service results in the following error when using @solflare-wallet/utl-sdk:

TypeError: Cannot read properties of undefined (reading 'prototype')
    at extendBorsh (webpack-internal:///(rsc)/./node_modules/@metaplex-foundation/mpl-core/dist/src/utils/borsh.js:14:26)
    at eval (webpack-internal:///(rsc)/./node_modules/@metaplex-foundation/mpl-core/dist/src/utils/borsh.js:30:25)

After investigating, I found that the issue started with @bonfida/spl-name-service version 2.3.3. It's unclear whether the problem lies with @solflare-wallet/utl-sdk or @bonfida/spl-name-service.

Steps to Reproduce:

  1. Create a new Next.js app with default settings:

    bunx create-next-app
  2. Install the required packages:

    bun install @solflare-wallet/utl-sdk @bonfida/spl-name-service
  3. Replace the content of page.tsx with the following code:

    import { Client, Token } from "@solflare-wallet/utl-sdk";
    import { PublicKey } from "@solana/web3.js";
    
    export default async function Home() {
      const utl = new Client();
      const token: Token = await utl.fetchMint(
        new PublicKey("So11111111111111111111111111111111111111112")
      );
    
      return <>{token.logoURI}</>;
    }
  4. Start the development server:

    bun run dev
dr497 commented 4 months ago

Hi @KoenRijpstra! Thanks for opening the issue, I will investigate and get back to you

dr497 commented 4 months ago

It looks like the issue you're encountering is related to how bun handles package resolutions, specifically with different versions of borsh. When using npm, everything works fine. You can see more details here on this test repo https://github.com/dr497/test-issue/tree/main

Our SDK does not have a dependency on @metaplex-foundation. The error you're seeing (TypeError: Cannot read properties of undefined (reading 'prototype')) seems to be related to how bun resolves borsh dependencies. In version 2.3.3 of @bonfida/spl-name-service, we upgraded to borsh 1.0.0. This change might be causing conflicts with other packages that rely on older versions of borsh.

To resolve this, you might want to try using npm instead of bun, or ensure that all packages in your project are compatible with borsh >= 1.0.0.

KoenRijpstra commented 4 months ago

Thanks, that explains a lot! Will lock it to 2.3.2 for now and maybe I can use overrides to fix the issue.