Files
TheGame/packages/web/lib/hooks/useW3.ts
Sero 38c3dc059e Sero/wc v2 (#1735)
* wc/wagmi/viem

* replace

* profile

* replace context (,:

* testing, clean up

* wallet connect deploy

* connect

* remove type slive

* podcast

* podcast

* heck yeah

* feat: connect button

* chore

* trying siwe, network switch

* redirect

* prettying, cleaning up SIWE endpoints, & passing linting 🕊

* switching minting to Optimism & converting `ethers` to `wagmi` for contract access 🥧

* simplified onboarding & successfully minted 

* typo

* api key

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: dysbulic <dys@dhappy.org>
2024-03-21 06:09:12 -04:00

27 lines
735 B
TypeScript

import { Client } from '@web3-storage/w3up-client';
import { CONFIG } from 'config';
import { delegate } from 'pages/api/w3up-client';
import { useEffect, useState } from 'react';
export function useW3upClient() {
const [w3upClient, setW3upClient] = useState<Client | null>(null);
const { web3StorageDID } = CONFIG;
useEffect(() => {
if (!web3StorageDID) return;
async function fetchW3upClient() {
try {
const result = await delegate(web3StorageDID);
if (result) {
setW3upClient(result[1] as Client);
}
} catch (error) {
console.error('Error occurred during delegation:', error);
}
}
fetchW3upClient();
}, [web3StorageDID]);
return w3upClient;
}