Display account addresses after connecting wallet

This commit is contained in:
IshaVenikar 2024-10-24 19:07:50 +05:30
parent 7383d5c36d
commit 2b7c75f97b
2 changed files with 34 additions and 4 deletions

View File

@ -22,7 +22,7 @@ import { useToast } from 'components/shared/Toast';
import { useGQLClient } from '../../../context/GQLClientContext'; import { useGQLClient } from '../../../context/GQLClientContext';
import EnvironmentVariablesForm from 'pages/org-slug/projects/id/settings/EnvironmentVariablesForm'; import EnvironmentVariablesForm from 'pages/org-slug/projects/id/settings/EnvironmentVariablesForm';
import { EnvironmentVariablesFormValues } from 'types/types'; import { EnvironmentVariablesFormValues } from 'types/types';
import { useWalletConnectClient } from 'context/WalletConnectContext'; import ConnectWallet from './ConnectWallet';
type ConfigureDeploymentFormValues = { type ConfigureDeploymentFormValues = {
option: string; option: string;
@ -35,8 +35,6 @@ type ConfigureFormValues = ConfigureDeploymentFormValues &
EnvironmentVariablesFormValues; EnvironmentVariablesFormValues;
const Configure = () => { const Configure = () => {
const { onConnect } = useWalletConnectClient()
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [deployers, setDeployers] = useState<Deployer[]>([]); const [deployers, setDeployers] = useState<Deployer[]>([]);
@ -352,7 +350,7 @@ const Configure = () => {
</div> </div>
</form> </form>
</FormProvider> </FormProvider>
<Button onClick={onConnect}>Connect Wallet</Button> <ConnectWallet/>
</div> </div>
</div> </div>
); );

View File

@ -0,0 +1,32 @@
import { Button } from '../../shared/Button';
import { useWalletConnectClient } from 'context/WalletConnectContext';
// import { useGQLClient } from '../../../context/GQLClientContext';
import { Select, Option } from '@snowballtools/material-tailwind-react-fork';
const ConnectWallet = () => {
const { onConnect, accounts } = useWalletConnectClient();
// const client = useGQLClient();
const handleConnect = async () => {
await onConnect();
// const snowballaddress = await client.getAddress();
};
return (
<>
{!accounts ? (
<Button onClick={handleConnect}>Connect Wallet</Button>
) : (
<Select label="Select Account">
{accounts.map((account, index) => (
<Option key={index} value={account.address}>
{account.address}
</Option>
))}
</Select>
)}
</>
);
};
export default ConnectWallet;