Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] - Snap debugging branch #1799

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
Jwhiles committed Jan 7, 2025

Verified

This commit was signed with the committer’s verified signature.
veritem Verité Mugabo
commit 7989bb3b2f824db79306359d5d10464aa1d65dff
24 changes: 21 additions & 3 deletions src/components/AuthLogin/AuthModal.tsx
Original file line number Diff line number Diff line change
@@ -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(
@@ -201,6 +212,8 @@ const AuthModal = ({
)
).json();

console.log('loginResponse', loginResponse)

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

const { data, session, token } = loginResponse;
@@ -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 {
10 changes: 7 additions & 3 deletions src/components/Faucet/Hero.tsx
Original file line number Diff line number Diff line change
@@ -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;
@@ -54,6 +57,7 @@ export default function Hero({
responseMsg: null,
timestamp: Date.now(),
});
console.log("gon trigg");
metaMaskWalletIdConnectHandler();
};

@@ -97,7 +101,7 @@ export default function Hero({
styles.hero,
network === "linea" && styles.linea,
network === "sepolia" && styles.sepolia,
className,
className
)}
>
{!(!showInstallButton && metaMaskAccount) && <EthIcon />}
@@ -141,7 +145,7 @@ export default function Hero({
)}
<div
className={clsx(
!!Object.keys(projects).length && styles.alignedButtons,
!!Object.keys(projects).length && styles.alignedButtons
)}
>
{showInstallButton ? (
4 changes: 4 additions & 0 deletions src/lib/siwsrp/auth.ts
Original file line number Diff line number Diff line change
@@ -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) {
25 changes: 13 additions & 12 deletions src/theme/Root.tsx
Original file line number Diff line number Diff line change
@@ -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({
@@ -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) {
Loading