0

This is the code is in my /app/lib/litProtocolFunctions.ts file which is where I reference LitJsSdk:

//@ts-ignore
import LitJsSdk from 'lit-js-sdk';
import { baseUrlConf } from '@/lib/config';

export function disconnectLit() {
    LitJsSdk.disconnectWeb3();
    return 'lit-auth';
}

export async function connectLit(uuidSpec: string) {

    const resourceId = {
        baseUrl: "http://" + baseUrlConf + ":3000",
        path: '/protected',
        orgId: "",
        role: "",
        extraData: uuidSpec
    }

    const chain = 'mumbai'
    const accessControlConditions = [
        {
            contractAddress: '<MY CONTRACT'S ADDRESS>',
            standardContractType: 'ERC721',
            chain: chain,
            method: 'balanceOf',
            parameters: [
                ':userAddress'
            ],
            returnValueTest: {
                comparator: '>',
                value: '0'
            }
        },
    ]

    const client = new LitJsSdk.LitNodeClient({ alertWhenUnauthorized: false });
    //@ts-ignore
    await client.connect();
    const authSig = await LitJsSdk.checkAndSignAuthMessage({ chain });

    //@ts-ignore
    await client.saveSigningCondition({ accessControlConditions, chain, authSig, resourceId })
    try {
        //@ts-ignore
        const litjwt = await client.getSignedToken({
            accessControlConditions, chain, authSig, resourceId: resourceId
        });
        return litjwt;
    } catch (err) {
        console.log('error: ', err);
        return 'no-token';
    }
}

When I run the app in next.js 13 with webpack it works perfectly. When I run it in next.js 13 with turbopack it fails with a non-helpful error that looks like this:
enter image description here

Also, it says this in my terminal (the one I used to launch the app): Error during SSR Rendering TypeError: Class extends value #<Object> is not a constructor or null.

And it says this in the browser console Uncaught ReferenceError: $RefreshSig$ is not defined.

I believe I've traced the error to it's point of failure.
This is where the error starts:
enter image description here

And this is the line 1:332 in node_module/lit-js-sdk/build/index.js:
enter image description here

So is it an issue with h=require ("@walletconnect/ethereum-provider")?

ChristianOConnor
  • 820
  • 7
  • 29

0 Answers0