diff --git a/src/adapters/gitcoin/gitcoinAdapter.ts b/src/adapters/gitcoin/gitcoinAdapter.ts index dfdc3c7d5..01eeea732 100644 --- a/src/adapters/gitcoin/gitcoinAdapter.ts +++ b/src/adapters/gitcoin/gitcoinAdapter.ts @@ -96,7 +96,8 @@ export class GitcoinAdapter implements GitcoinAdapterInterface { const result = await axios.post( `${GITCOIN_API_BASE_URL}/registry/submit-passport`, { - variables: params, + address: params.address.toLowerCase(), + scorer_id: this.ScorerID, }, { headers: { diff --git a/src/adapters/gitcoin/gitcoinAdapterInterface.ts b/src/adapters/gitcoin/gitcoinAdapterInterface.ts index e9f6bdfbc..e51d03a16 100644 --- a/src/adapters/gitcoin/gitcoinAdapterInterface.ts +++ b/src/adapters/gitcoin/gitcoinAdapterInterface.ts @@ -5,9 +5,6 @@ export interface SigningMessageAndNonceResponse { export interface SubmitPassportInput { address: string; - scorer: string; - signature: string; - nonce: string; } export interface SubmittedPassportResponse { diff --git a/src/adapters/gitcoin/gitcoinMockAdapter.ts b/src/adapters/gitcoin/gitcoinMockAdapter.ts index 6409c0a06..23f381fe9 100644 --- a/src/adapters/gitcoin/gitcoinMockAdapter.ts +++ b/src/adapters/gitcoin/gitcoinMockAdapter.ts @@ -63,7 +63,7 @@ export class GitcoinMockAdapter implements GitcoinAdapterInterface { } return Promise.resolve({ address: 'string', - score: 'string', + score: '10', status: 'string', last_score_timestamp: 'string', evidence: undefined, diff --git a/src/resolvers/userResolver.test.ts b/src/resolvers/userResolver.test.ts index ca1cdc39f..ba4abc666 100644 --- a/src/resolvers/userResolver.test.ts +++ b/src/resolvers/userResolver.test.ts @@ -45,9 +45,6 @@ function refreshUserScoresTestCases() { const user = await User.create(userData).save(); await getGitcoinAdapter().submitPassport({ address: userData.walletAddress, - scorer: '200', - signature: 'any', - nonce: 'any', }); const result = await axios.post(graphqlUrl, { query: refreshUserScores, @@ -74,9 +71,6 @@ function refreshUserScoresTestCases() { const user = await User.create(userData).save(); await getGitcoinAdapter().submitPassport({ address: userData.walletAddress, - scorer: '200', - signature: 'any', - nonce: 'any', }); const result = await axios.post(graphqlUrl, { query: refreshUserScores, @@ -102,30 +96,6 @@ function refreshUserScoresTestCases() { updatedUser.passportScore, ); }); - it('should not refresh user scores if not registered to gitcoin', async () => { - const userData = { - firstName: 'firstName', - lastName: 'lastName', - email: 'giveth@gievth.com', - avatar: 'pinata address', - url: 'website url', - loginType: 'wallet', - walletAddress: generateRandomEtheriumAddress(), - }; - const user = await User.create(userData).save(); - const result = await axios.post(graphqlUrl, { - query: refreshUserScores, - variables: { - address: userData.walletAddress, - }, - }); - - const updatedUser = result.data.data.refreshUserScores; - assert.equal(updatedUser.walletAddress, user.walletAddress); - // if score remains null the user has not registered - assert.equal(updatedUser.passportScore, 0); - assert.equal(updatedUser.passportStamps, 0); - }); } function userByAddressTestCases() { diff --git a/src/resolvers/userResolver.ts b/src/resolvers/userResolver.ts index 1047cf4e4..a03f3906a 100644 --- a/src/resolvers/userResolver.ts +++ b/src/resolvers/userResolver.ts @@ -61,16 +61,16 @@ export class UserResolver { if (!foundUser) return; try { - const passportScore = await getGitcoinAdapter().getWalletAddressScore( + const passportScore = await getGitcoinAdapter().submitPassport({ address, - ); + }); const passportStamps = await getGitcoinAdapter().getPassportStamps( address, ); - if (passportScore) { + if (passportScore && passportScore?.score) { const score = Number(passportScore.score); - foundUser.passportScore = isNaN(score) ? 0 : score; + foundUser.passportScore = score; } if (passportStamps) foundUser.passportStamps = passportStamps.items.length;