Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported method: personal_sign #2645

Closed
emmajane1313 opened this issue Jan 10, 2023 · 3 comments
Closed

Unsupported method: personal_sign #2645

emmajane1313 opened this issue Jan 10, 2023 · 3 comments

Comments

@emmajane1313
Copy link

I'm building a nextjs app that uses wagmi hooks for most of the web3 front end calls. When setting up the ceramic account auth and trying to call

await DIDSession.authorize(authProv, {
        resources: [`ceramic://*`],
        
      })

I keep getting the following error from alchemy upon request:

bad response (status=400, headers={"content-length":"173","content-type":"application/json"}, body="{\"jsonrpc\":\"2.0\",\"id\":42,\"error\":{\"code\":-32600,\"message\":\"Unsupported method: personal_sign. See available methods at https://docs.alchemy.com/alchemy/documentation/apis\"}}

Is there a way to switch from personal_sign to ethers_sign ?

I am getting my signer and provider from wagmi and was previously receiving another bad request error when calling await threeIDConnect.connect(auth) but was able to solve this by using Eip1193Bridge on the wagmi provider response so it could be correctly read by threeId

const ethersSigner = useSigner().data as Signer;
  const wagmiProvider = useProvider({
    chainId: 8001,
  });
  const provider = new Eip1193Bridge(ethersSigner, wagmiProvider);
 const auth = new EthereumAuthProvider(provider, address as string);
 const threeIDConnect = new ThreeIdConnect();
 await threeIDConnect.connect(auth)

I'm not sure if the above is related to the error I'm currently experiencing but any help on how I can get the personal_signer or circumnavigated is much appreciated :)

Here is the code the full code that's being run:

const { address } = useAccount();
 const ethersSigner = useSigner().data as Signer;
 const wagmiProvider = useProvider({
   chainId: 8001,
 });
 const provider = new Eip1193Bridge(ethersSigner, wagmiProvider);
 console.log(ethersSigner)
 useEffect(() => {
   if (lensProfile && !client) {
     createAuthProvider();
   }
 }, [lensProfile]);

 const createAuthProvider = async () => {
   try {
     const auth = new EthereumAuthProvider(provider, address as string);
     const threeIDConnect = new ThreeIdConnect();
     await threeIDConnect.connect(auth)
     const accountId = await getAccountId(provider, address as string);
     const authProv = await EthereumWebAuth.getAuthMethod(provider, accountId);
     const session = await loadSession(authProv);
     const ceramic = new CeramicClient();
     ceramic.did = session.did;
   } catch (err: any) {
     console.error(err.message);
   }
 };

 const loadSession = async (authProv: AuthMethod): Promise<DIDSession> => {
   const sessionStr = getCeramicSession();
   let session: any;

   if (sessionStr) {
     session = await DIDSession.fromSession(sessionStr);
   }

   if (!session || (session.hasSession && session.isExpired)) {
     session = await DIDSession.authorize(authProv, {
       resources: [`ceramic://*`],
       
     });
     setCeramicSession(session);
   }

   return session;
 };
@zachferland
Copy link
Contributor

Hi! would you mind opening the same issues in this repo instead - https://github.com/ceramicnetwork/js-did, related libraries are there and would allow us to track it better

First there is no need to use 3idconnect AND didsession, they offer the same thing, an authenticated did to use with ceramic. We recommend using did-session (alone).

@emmajane1313
Copy link
Author

just moved the issue over

@zachferland
Copy link
Contributor

Thanks! closing here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants