mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-13 00:28:15 -05:00
* 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>
27 lines
735 B
TypeScript
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;
|
|
}
|