import React from 'react'; import { useChain } from '@cosmos-kit/react'; import Button from '@mui/material/Button'; import Box from '@mui/material/Box'; import { Alert, AlertTitle, LinearProgress } from '@mui/material'; import { getDoc } from './data'; export const CosmosKitSign = () => { const { address, getOfflineSignerAmino } = useChain('nyx'); const [signResponse, setSignResponse] = React.useState(); const [busy, setBusy] = React.useState(); const sign = async () => { setBusy(true); const doc = getDoc(address); const tx = await getOfflineSignerAmino().signAmino(address, doc); setBusy(false); return tx; }; const handleSign = async () => { setSignResponse(await sign()); }; if (busy) { return ( Please approve in your wallet Review the message to sign ); } return ( <> {!signResponse && ( Click the button below to sign a fake request with your wallet )} {signResponse && ( Signature:
{JSON.stringify(signResponse?.signature, null, 2)}
)} ); };