Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: add a bunch of logging etc
  • Loading branch information
Jwhiles committed Jan 7, 2025
commit 7989bb3b2f824db79306359d5d10464aa1d65dff
24 changes: 21 additions & 3 deletions src/components/AuthLogin/AuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,40 @@ const AuthModal = ({
const { pathname } = location;

const login = async () => {
console.log('in login')
setStep(AUTH_LOGIN_STEP.CONNECTING);
try {
if (!sdk.isExtensionActive()) {
setOpen(false);
}
// This will cause problems on mobile
// if (!sdk.isExtensionActive()) {
// setOpen(false);
// }

// Try to connect wallet first
const accounts = await sdk.connect();
console.log({ accounts })

console.log('before accounts if')
if (accounts && accounts.length > 0) {
setMetaMaskAccount(accounts[0]);
fetchLineaEns(accounts[0]);
const provider = sdk.getProvider();
setMetaMaskProvider(provider);
}

console.log('before get customProvider')
const customProvider = sdk.getProvider()
console.log('customProvider', customProvider)
// Call Profile SDK API to retrieve Hydra Access Token & Wallet userProfile
// Hydra Access Token will be used to fetch Infura API
console.log('before authenticateAndAuthorize')
const { accessToken, userProfile } = await authenticateAndAuthorize(
VERCEL_ENV as string,
customProvider,
);
console.log('accessToken', accessToken)
console.log('userProfile', userProfile)

console.log("before loginResponse")

const loginResponse = await (
await fetch(
Expand All @@ -201,6 +212,8 @@ const AuthModal = ({
)
).json();

console.log('loginResponse', loginResponse)

if (!loginResponse) throw new Error("Something went wrong");

const { data, session, token } = loginResponse;
Expand Down Expand Up @@ -310,7 +323,12 @@ const AuthModal = ({
}
};

console.log('just before use effect')

useEffect(() => {
console.log('in use effect')
console.log('open', open)
console.log('step', step)
if (open && step == AUTH_LOGIN_STEP.CONNECTING) {
(async () => {
try {
Expand Down
10 changes: 7 additions & 3 deletions src/components/Faucet/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export default function Hero({
walletAuthUrl,
} = useContext(MetamaskProviderContext);

const isMobile = sdk.platformManager.isMobile()

// const isMobile = sdk.platformManager.isMobile;
const isMobile = true
console.log(sdk.platformManager)
const isExtensionActive = sdk.isExtensionActive();

const showInstallButton = !isExtensionActive && !isMobile;
Expand All @@ -54,6 +57,7 @@ export default function Hero({
responseMsg: null,
timestamp: Date.now(),
});
console.log("gon trigg");
metaMaskWalletIdConnectHandler();
};

Expand Down Expand Up @@ -97,7 +101,7 @@ export default function Hero({
styles.hero,
network === "linea" && styles.linea,
network === "sepolia" && styles.sepolia,
className,
className
)}
>
{!(!showInstallButton && metaMaskAccount) && <EthIcon />}
Expand Down Expand Up @@ -141,7 +145,7 @@ export default function Hero({
)}
<div
className={clsx(
!!Object.keys(projects).length && styles.alignedButtons,
!!Object.keys(projects).length && styles.alignedButtons
)}
>
{showInstallButton ? (
Expand Down
4 changes: 4 additions & 0 deletions src/lib/siwsrp/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ export const authenticateAndAuthorize = async (env: string, customProvider: SDKP
let accessToken: string, userProfile: SDK.UserProfile;
try {
const authInstance = auth(env);
console.log("authInstance", authInstance);
console.log("customProvider", customProvider);
authInstance.setCustomProvider(customProvider);
console.log('about to connectSnap')
await authInstance.connectSnap();
console.log('after connectSnap')
accessToken = await authInstance.getAccessToken();
userProfile = await authInstance.getUserProfile();
} catch (e: any) {
Expand Down
25 changes: 13 additions & 12 deletions src/theme/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,28 @@ interface IMetamaskProviderContext {
export const MetamaskProviderContext = createContext<IMetamaskProviderContext>({
token: undefined,
projects: {},
setProjects: () => {},
metaMaskDisconnect: () => new Promise(() => {}),
metaMaskWalletIdConnectHandler: () => new Promise(() => {}),
setProjects: () => { },
metaMaskDisconnect: () => new Promise(() => { }),
metaMaskWalletIdConnectHandler: () => new Promise(() => { }),
userId: undefined,
metaMaskAccount: undefined,
metaMaskAccountEns: undefined,
setMetaMaskAccount: () => {},
setMetaMaskAccount: () => { },
uksTier: undefined,
metaMaskProvider: undefined,
setMetaMaskProvider: () => {},
setMetaMaskProvider: () => { },
sdk: undefined,
setNeedsMfa: () => {},
setNeedsMfa: () => { },
needsMfa: false,
setWalletLinked: () => {},
setWalletLinked: () => { },
walletLinked: undefined,
setWalletAuthUrl: () => {},
setWalletAuthUrl: () => { },
walletAuthUrl: "",
userAPIKey: "",
setUserAPIKey: () => {},
fetchLineaEns: () => new Promise(() => {}),
setUserAPIKey: () => { },
fetchLineaEns: () => new Promise(() => { }),
userEncPublicKey: undefined,
setUserEncPublicKey: () => {},
setUserEncPublicKey: () => { },
});

const sdk = new MetaMaskSDK({
Expand Down Expand Up @@ -173,10 +173,11 @@ export const LoginProvider = ({ children }) => {
const provider = sdk.getProvider();
setMetaMaskProvider(provider);
}
} catch (e) {}
} catch (e) { }
};

const metaMaskWalletIdConnectHandler = useCallback(async () => {
console.log("in metaMaskWalletIdConnectHandler");
try {
setOpenAuthModal(true);
} catch (err) {
Expand Down
Loading