Skip to content

Commit

Permalink
2086 debug multiformats 3 (passportxyz#2112)
Browse files Browse the repository at this point in the history
* fix[app]: adressing issue where the  is not available any more + also adding some more logs in Home.tsx

* feat[app]: swicthin from DIDSession.authorize -> DIDSession.get

* Revert "fix: upgrade yarn version, drop unused dependencies (passportxyz#2108)"

This reverts commit 99f13de.
  • Loading branch information
nutrina authored Jan 31, 2024
1 parent 99f13de commit f29d5fa
Show file tree
Hide file tree
Showing 11 changed files with 26,563 additions and 29,747 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ jobs:
node-version: 20.8.1
cache: "yarn"
- name: Install Packages
run: |
yarn set version 4.1.0
yarn install
run: yarn install
- name: Run Tests
run: yarn test
- name: Run Linter
Expand Down
3 changes: 0 additions & 3 deletions .yarnrc.yml

This file was deleted.

6 changes: 4 additions & 2 deletions app/context/datastoreConnectionContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,18 @@ export const useDatastoreConnection = () => {
}

if (
true || // Hotfix: Hardcoding this here, as we always want a session created by DIDSession.get ... (at least for now)
!session ||
session.isExpired ||
session.expireInSecs < 3600 ||
!session.hasSession ||
Date.now() - new Date(session?.cacao?.p?.iat).getTime() >
MAX_VALID_DID_SESSION_AGE - BUFFER_TIME_BEFORE_EXPIRATION
) {
session = await DIDSession.authorize(authMethod, { resources: ["ceramic://*"] });
// session = await DIDSession.authorize(authMethod, { resources: ["ceramic://*"] });
session = await DIDSession.get(accountId, authMethod, { resources: ["ceramic://*"] });
// Store the session in localstorage
window.localStorage.setItem(sessionKey, session.serialize());
// window.localStorage.setItem(sessionKey, session.serialize());
}
if (session) {
await loadDbAccessToken(address, session.did);
Expand Down
15 changes: 14 additions & 1 deletion app/context/walletStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,23 @@ const walletStore = create<{
},
}
: undefined;
const wallet = (await onboard.connectWallet(connectOptions))[0];
let wallet = (await onboard.connectWallet(connectOptions))[0];

if (!wallet) {
// This error can be caused if the user changed the wallet he is using in the mean time,
// for example he switched from MM -> Rabby
// So let's try first without the previouslyUsedWalletLabel
console.debug(
"No wallet selected when trying to connect with `previouslyUsedWalletLabel`. Retrying without it."
);

wallet = (await onboard.connectWallet())[0];
}

if (!wallet) {
throw new Error("No wallet selected");
}

window.localStorage.setItem("previouslyUsedWalletLabel", wallet.label);

const walletData = parseWeb3OnboardWallet(wallet);
Expand Down
2 changes: 2 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@headlessui/tailwindcss": "^0.1.3",
"@heroicons/react": "^2.0.17",
"@popperjs/core": "^2.11.7",
"@self.id/framework": "^0.4.0",
"@web3-onboard/core": "2.21.2",
"@web3-onboard/injected-wallets": "2.10.7",
"@web3-onboard/react": "2.8.13",
Expand Down Expand Up @@ -92,6 +93,7 @@
},
"resolutions": {
"csstype": "3.0.10",
"**/@types/react": "18.2.34",
"leveldown": "6.1.1"
},
"optionalDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions app/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default function Home() {

useEffect(() => {
if (connectError) {
console.log("displaying Connection Error", connectError);
console.log("displaying Connection Error", (connectError as Error).message);
toast({
duration: 6000,
isClosable: true,
Expand Down
38 changes: 20 additions & 18 deletions app/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { OnChainContextProvider } from "../context/onChainContext";
import ManageAccountCenter from "../components/ManageAccountCenter";

// --- Ceramic Tools
// import { Provider as SelfIdProvider } from "@self.id/framework";
import { Provider as SelfIdProvider } from "@self.id/framework";

// --- GTM Module
import TagManager from "react-gtm-module";
Expand Down Expand Up @@ -143,23 +143,25 @@ function App({ Component, pageProps }: AppProps) {
<title>Gitcoin Passport</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
</Head>
<DatastoreConnectionContextProvider>
<OnChainContextProvider>
<ScorerContextProvider>
<CeramicContextProvider>
<StampClaimingContextProvider>
<ManageAccountCenter>
<RenderOnlyOnClient>
<ThemeWrapper initChakra={true} defaultTheme={themes.LUNARPUNK_DARK_MODE}>
<Component {...pageProps} />
</ThemeWrapper>
</RenderOnlyOnClient>
</ManageAccountCenter>
</StampClaimingContextProvider>
</CeramicContextProvider>
</ScorerContextProvider>
</OnChainContextProvider>
</DatastoreConnectionContextProvider>
<SelfIdProvider client={{ ceramic: `${process.env.NEXT_PUBLIC_CERAMIC_CLIENT_URL || "testnet-clay"}` }}>
<DatastoreConnectionContextProvider>
<OnChainContextProvider>
<ScorerContextProvider>
<CeramicContextProvider>
<StampClaimingContextProvider>
<ManageAccountCenter>
<RenderOnlyOnClient>
<ThemeWrapper initChakra={true} defaultTheme={themes.LUNARPUNK_DARK_MODE}>
<Component {...pageProps} />
</ThemeWrapper>
</RenderOnlyOnClient>
</ManageAccountCenter>
</StampClaimingContextProvider>
</CeramicContextProvider>
</ScorerContextProvider>
</OnChainContextProvider>
</DatastoreConnectionContextProvider>
</SelfIdProvider>
</>
);
}
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"husky": "^7.0.0",
"lerna": "^4.0.0",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"typescript": "^5.3.3"
"rimraf": "^3.0.2"
},
"workspaces": [
"app",
Expand Down Expand Up @@ -64,8 +63,8 @@
},
"resolutions": {
"csstype": "3.0.10",
"**/@types/react": "17.0.2",
"leveldown": "6.1.1",
"node-gyp": "^9.0.0"
},
"packageManager": "[email protected]"
}
}
4 changes: 2 additions & 2 deletions platforms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
"typescript": "^5.3.3"
},
"devDependencies": {
"eslint-plugin-prettier": "^5.1.3",
"jest": "^27.5.1",
"jest-mock-extended": "^3.0.4",
"ts-jest": "^27.1.4",
"ts-node": "^10.8.0"
"ts-node": "^10.8.0",
"eslint-plugin-prettier": "^5.1.3"
},
"scripts": {
"clean": "rimraf dist node_modules",
Expand Down
13 changes: 9 additions & 4 deletions schemas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@
"graphql-server": "composedb graphql:server --ceramic-url=${CERAMIC_URL} --graphiql ./src/definitions/json/gitcoin-passport-stamps.json --did-private-key=${PRIVATE_KEY} --port=5005"
},
"dependencies": {
"@composedb/types": "^0.6.0"
"@ceramicnetwork/http-client": "^2.2.1",
"@composedb/types": "^0.6.0",
"dids": "^5.0.2",
"dotenv": "^16.0.0",
"key-did-provider-ed25519": "^2.0.0",
"key-did-resolver": "^4.0.0",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
"@ceramicnetwork/cli": "^3.2.0",
"@ceramicnetwork/cli": "^2.3.1",
"@composedb/cli": "^0.6.1",
"@glazed/devtools": "^0.2.0",
"@types/node": "^16.11.6",
"dotenv": "^16.0.0"
"@types/node": "^16.11.6"
},
"resolutions": {
"leveldown": "6.1.1"
Expand Down
Loading

0 comments on commit f29d5fa

Please sign in to comment.