Skip to content

Commit

Permalink
fix[app,schemas]: loding & logging stamps from compose-db when connec… (
Browse files Browse the repository at this point in the history
passportxyz#2066)

* fix[app,schemas]: loding & logging stamps from compose-db when connected. Also added command for starting graphql server in schemas module

* fix[app]: fix failing unittest

* fix[app]: fix linter errors
  • Loading branch information
nutrina authored Jan 24, 2024
1 parent a005726 commit 13f1974
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/__tests__/context/ceramicContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jest.mock("../../context/walletStore", () => ({
useWalletStore: (callback: (state: any) => any) => callback(mockWalletState),
}));

export const dbGetPassportMock = jest.fn().mockImplementation(() => {
export const dbGetPassportMock = jest.fn().mockImplementation(async () => {
return {
passport: {
stamps: [],
Expand Down Expand Up @@ -80,7 +80,7 @@ const passportDbMocks = {

const ceramicDbMocks = {
createPassport: dbCreatePassportMock,
getPassport: jest.fn(),
getPassport: dbGetPassportMock,
addStamp: dbAddStampMock,
addStamps: dbAddStampsMock,
deleteStamp: dbDeleteStampMock,
Expand Down
15 changes: 15 additions & 0 deletions app/context/ceramicContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,21 @@ export const CeramicContextProvider = ({ children }: { children: any }) => {
}
}, [database]);

useEffect(() => {
if (ceramicClient) {
ceramicClient
.getPassport()
.then((passportResponse) => {
console.log("loaded passport from compose-db", passportResponse);
datadogLogs.logger.info("loaded passport from compose-db", { passportResponse });
})
.catch((e) => {
console.log("failed to load passport from compose-db", e);
datadogLogs.logger.error("failed to load passport from compose-db", { error: e });
});
}
}, [ceramicClient]);

const passportLoadSuccess = (
database: ComposeDatabase | PassportDatabase,
passport?: Passport,
Expand Down
3 changes: 2 additions & 1 deletion schemas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"graphql:server": "composedb graphql:server --ceramic-url=${CERAMIC_URL} --graphiql definitions/gitcoin-passport-stamps.json --did-private-key=${PRIVATE_KEY} --port=5005",
"models:create-composite": "composedb composite:create models/passportStamps.graphql --output=composites/gitcoin-passport-stamps-composite.json --did-private-key=${PRIVATE_KEY}",
"models:deploy-composite": "composedb composite:deploy composites/gitcoin-passport-stamps-composite.json --ceramic-url=${CERAMIC_URL} --did-private-key=${PRIVATE_KEY}",
"models:compile-composite": "composedb composite:compile composites/gitcoin-passport-stamps-composite.json src/definitions/ts/gitcoin-passport-stamps.ts --ceramic-url=${CERAMIC_URL} && composedb composite:compile composites/gitcoin-passport-stamps-composite.json src/definitions/json/gitcoin-passport-stamps.json --ceramic-url=${CERAMIC_URL}"
"models:compile-composite": "composedb composite:compile composites/gitcoin-passport-stamps-composite.json src/definitions/ts/gitcoin-passport-stamps.ts --ceramic-url=${CERAMIC_URL} && composedb composite:compile composites/gitcoin-passport-stamps-composite.json src/definitions/json/gitcoin-passport-stamps.json --ceramic-url=${CERAMIC_URL}",
"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": {
"@ceramicnetwork/http-client": "^2.2.1",
Expand Down

0 comments on commit 13f1974

Please sign in to comment.