Skip to content

Commit

Permalink
Hotfix 20250217 (#3281)
Browse files Browse the repository at this point in the history
* chore: disable all linters

* feat(nonce): add more logs for nonce error

* feat(weights): add more logs for weights error

* feat(useLoginFlow): add more detail logs

* feat(workflow): undo bad rebase change

* feat(workflow): add linter bacl

* feat(workflow): add linter back

* feat(lint): fix linter error

---------

Co-authored-by: Lucian Hymer <[email protected]>
  • Loading branch information
larisa17 and lucianHymer authored Feb 18, 2025
1 parent 8d24561 commit 2fec2ff
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_and_deploy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
run: yarn install --frozen-lockfile
- name: Run Tests
run: yarn test
# - name: Run Linter
# run: yarn lint
- name: Run Linter
run: yarn lint
- name: Workarround for build error
run: rm -rf node_modules/@tendermint
- name: Run Build (ensure that build succeeds)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
run: yarn install --frozen-lockfile
- name: Run Tests
run: yarn test
# - name: Run Linter
# run: yarn lint
- name: Run Linter
run: yarn lint
- name: Workarround for build error
run: rm -rf node_modules/@tendermint
- name: Run Build (ensure that build succeeds)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy_ui_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
run: yarn install --frozen-lockfile
- name: Run Tests
run: yarn test
# - name: Run Linter
# run: yarn lint
- name: Run Linter
run: yarn lint
- name: Workarround for build error
run: rm -rf node_modules/@tendermint
- name: Run Build (ensure that build succeeds)
Expand Down
5 changes: 3 additions & 2 deletions app/context/datastoreConnectionContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ export const useDatastoreConnection = () => {

const getPassportDatabaseAccessToken = async (did: DID, address: string): Promise<string> => {
let nonce = null;
console.error("Getting nonce for did:", did);
try {
// Get nonce from server
const nonceResponse = await axios.get(`${process.env.NEXT_PUBLIC_SCORER_ENDPOINT}/account/nonce`);
nonce = nonceResponse.data.nonce;
} catch (error) {
const msg = `Failed to get nonce from server for user with did: ${did.parent}`;
const msg = `Failed to get nonce from server for user with did: ${did.parent}. Error: ${error}`;
datadogRum.addError(msg);
throw new Error(msg);
}
Expand All @@ -82,7 +83,7 @@ export const useDatastoreConnection = () => {
setConnectedAddress(address);
return accessToken;
} catch (error) {
const msg = `Failed to authenticate user with did: ${did.parent}`;
const msg = `Failed to authenticate user with did: ${did.parent}. Error: ${error}`;
datadogRum.addError(msg);
throw new Error(msg);
}
Expand Down
1 change: 1 addition & 0 deletions app/context/scorerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export const ScorerContextProvider = ({ children }: { children: any }) => {
}
} catch (error) {
setPassportSubmissionState("APP_REQUEST_ERROR");
console.error("Error fetching stamp weights", error);
}
};

Expand Down
34 changes: 29 additions & 5 deletions app/hooks/useLoginFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useLoginFlow = ({
isLoggingIn: boolean;
signIn: () => void;
} => {
const { address, isConnected } = useAccount();
const { address, isConnected, connector } = useAccount();
const { data: walletClient } = useWalletClient();
const { open: web3ModalIsOpen } = useAppKitState();
const { disconnect } = useDisconnect();
Expand All @@ -47,10 +47,13 @@ export const useLoginFlow = ({
}, []);

useEffect(() => {
console.error("Debug Login Flow loginStep: ", loginStep);
console.error("Debug Login Flow web3modalEvent: ", web3modalEvent);
console.error("Debug Login Flow resetLogin: ", resetLogin);
if (web3modalEvent.data.event === "MODAL_CLOSE" && web3modalEvent.data.properties.connected === false) {
resetLogin();
}
}, [web3modalEvent, resetLogin]);
}, [web3modalEvent, resetLogin, loginStep]);

const showConnectionError = useCallback(
(e: any) => {
Expand All @@ -63,19 +66,26 @@ export const useLoginFlow = ({
);

useEffect(() => {
console.error("Debug Login Flow enabled: ", enabled);
console.error("Debug Login Flow isConnected: ", isConnected);
console.error("Debug Login Flow dbAccessTokenStatus: ", dbAccessTokenStatus);

const newLoginStep = (() => {
if (!enabled) return "NOT_STARTED";
else if (!isConnected) return "PENDING_WALLET_CONNECTION";
else if (dbAccessTokenStatus !== "connected") return "PENDING_DATABASE_CONNECTION";
else return "DONE";
})();
console.error("Debug Login Flow newLoginStep: ", newLoginStep);
setLoginStep(newLoginStep);
}, [enabled, isConnected, dbAccessTokenStatus]);

// Workaround for bug where if you disconnect from the modal on
// the dashboard, the web3ModalIsOpen state is incorrect
// until we call disconnect
useEffect(() => {
console.error("Debug Login Flow web3ModalIsOpen: ", web3ModalIsOpen);
console.error("Debug Login Flow loginStep: ", loginStep);
(async () => {
if (web3ModalIsOpen && loginStep === "NOT_STARTED") {
try {
Expand All @@ -85,9 +95,11 @@ export const useLoginFlow = ({
}
}
})();
}, [web3ModalIsOpen, loginStep]);
}, [web3ModalIsOpen, loginStep, disconnect]);

useEffect(() => {
console.error("Debug Login Flow loginStep: ", loginStep);
console.error("Debug Login Flow navigateToPage: ", navigateToPage);
if (loginStep === "DONE") {
if (onLoggedIn) {
onLoggedIn();
Expand All @@ -99,9 +111,16 @@ export const useLoginFlow = ({
}
}
}
}, [loginStep, navigateToPage]);
}, [loginStep, navigateToPage, onLoggedIn]);

useEffect(() => {
console.error("Debug Login Flow loginStep: ", loginStep);
console.error("Debug Login Flow address: ", address);
console.error("Debug Login Flow connector: ", connector?.name);
console.error("Debug Login Flow walletClient: ", walletClient);
console.error("Debug Login Flow connectDatastore: ", connectDatastore);
console.error("Debug Login Flow showConnectionError: ", showConnectionError);
console.error("Debug Login Flow resetLogin: ", resetLogin);
(async () => {
if (
!isConnectingToDatabaseRef.current &&
Expand All @@ -126,6 +145,11 @@ export const useLoginFlow = ({
const isLoggingIn = loginStep !== "DONE" && loginStep !== "NOT_STARTED";

const signIn = useCallback(async () => {
console.error("Debug Login Flow initiateLogin: ", initiateLogin);
console.error("Debug Login Flow isConnected: ", isConnected);
console.error("Debug Login Flow openWeb3Modal: ", openWeb3Modal);
console.error("Debug Login Flow showConnectionError: ", showConnectionError);
console.error("Debug Login Flow resetLogin: ", resetLogin);
try {
initiateLogin();
if (!isConnected) {
Expand All @@ -136,7 +160,7 @@ export const useLoginFlow = ({
showConnectionError(e);
resetLogin();
}
}, [openWeb3Modal, isConnected, showConnectionError]);
}, [initiateLogin, isConnected, openWeb3Modal, showConnectionError, resetLogin]);

return useMemo(() => ({ loginStep, isLoggingIn, signIn }), [loginStep, isLoggingIn, signIn]);
};

0 comments on commit 2fec2ff

Please sign in to comment.