Skip to content

Commit

Permalink
update global-wallet-sdk and add typings to WalletContext
Browse files Browse the repository at this point in the history
  • Loading branch information
lwin-kyaw committed Sep 9, 2024
1 parent f0aeac0 commit 3246984
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export default function Home() {
setIsLoading(true);
setDisplayErrorPopup(false);
try {
const response = await walletProvider?.request({
method: "eth_requestAccounts",
params: loginParams || [],
});
const response = await walletProvider?.connect(loginParams);
const loggedInAddress = (response as string[])[0];
setAddress(loggedInAddress);
setLoggedIn(walletProvider?.connected || false);
Expand Down
19 changes: 16 additions & 3 deletions src/context/walletContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@ import { WalletProvider } from "@web3auth/global-accounts-sdk";
import { useRouter } from "next/navigation";
import React, { createContext, useContext, useEffect, useState } from "react";

const WalletContext = createContext({
interface IWalletContext {
address: string;
setAddress: (val: string) => void;
selectedEnv: SelectedEnv;
setSelectedEnv: (val: SelectedEnv) => void;
walletProvider: WalletProvider | null;
setWalletProvider: (val: WalletProvider) => void;
loggedIn: boolean;
setLoggedIn: (val: boolean) => void;
showNextLoginModal: boolean;
setShowNextLoginModal: (val: boolean) => void;
}

const WalletContext = createContext<IWalletContext>({
address: "",
selectedEnv: "production" as SelectedEnv,
setSelectedEnv: (selectedEnv: SelectedEnv) => {},
setAddress: (address: string) => {},
walletProvider: null as any,
setWalletProvider: (provider: any) => {},
walletProvider: null,
setWalletProvider: (provider: WalletProvider) => {},
loggedIn: false,
setLoggedIn: (loggedIn: boolean) => {},
showNextLoginModal: false,
Expand Down
Binary file modified web3auth-global-accounts-sdk-0.1.1-0.tgz
Binary file not shown.
Binary file removed web3auth-global-accounts-sdk-0.1.1-2.tgz
Binary file not shown.

0 comments on commit 3246984

Please sign in to comment.