diff --git a/packages/frontend/src/features/core/services/RelayApiService/RelayApiService.ts b/packages/frontend/src/features/core/services/RelayApiService/RelayApiService.ts index ff441ece9..70b9812de 100644 --- a/packages/frontend/src/features/core/services/RelayApiService/RelayApiService.ts +++ b/packages/frontend/src/features/core/services/RelayApiService/RelayApiService.ts @@ -42,13 +42,23 @@ export class RelayApiService { client.interceptors.request.use( async (config) => { + const data = await userState.getData() + + const reputation = data[0] - data[1] + const { publicSignals, proof } = - await userState.genProveReputationProof({ - minRep: 0, - }) + reputation < 0 + ? await userState.genProveReputationProof({ + maxRep: 1, + }) + : await userState.genProveReputationProof({ + minRep: 0, + }) + const token = btoa( JSON.stringify(stringifyBigInts({ publicSignals, proof })), ) + config.headers.set('authentication', token) return config diff --git a/packages/frontend/src/features/post/hooks/useCreateComment/useCreateComment.test.ts b/packages/frontend/src/features/post/hooks/useCreateComment/useCreateComment.test.ts index fa1535152..2b11a256c 100644 --- a/packages/frontend/src/features/post/hooks/useCreateComment/useCreateComment.test.ts +++ b/packages/frontend/src/features/post/hooks/useCreateComment/useCreateComment.test.ts @@ -31,6 +31,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ }, }, getGuaranteedUserState: () => ({ + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], waitForSync: jest.fn(), latestTransitionedEpoch: jest.fn().mockResolvedValue(1), genEpochKeyProof: jest.fn().mockResolvedValue({ diff --git a/packages/frontend/src/features/post/hooks/useCreatePost/useCreatePost.test.ts b/packages/frontend/src/features/post/hooks/useCreatePost/useCreatePost.test.ts index b5466dd78..1454c375e 100644 --- a/packages/frontend/src/features/post/hooks/useCreatePost/useCreatePost.test.ts +++ b/packages/frontend/src/features/post/hooks/useCreatePost/useCreatePost.test.ts @@ -41,6 +41,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ }, }, getGuaranteedUserState: () => ({ + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], waitForSync: jest.fn(), latestTransitionedEpoch: jest.fn().mockResolvedValue(1), genEpochKeyProof: jest.fn().mockResolvedValue({ diff --git a/packages/frontend/src/features/post/hooks/useReportComment/useReportComment.test.ts b/packages/frontend/src/features/post/hooks/useReportComment/useReportComment.test.ts index 53f43006f..4b2167656 100644 --- a/packages/frontend/src/features/post/hooks/useReportComment/useReportComment.test.ts +++ b/packages/frontend/src/features/post/hooks/useReportComment/useReportComment.test.ts @@ -31,6 +31,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ }, }, getGuaranteedUserState: () => ({ + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], waitForSync: jest.fn(), latestTransitionedEpoch: jest.fn().mockResolvedValue(1), genEpochKeyProof: jest.fn().mockResolvedValue({ diff --git a/packages/frontend/src/features/post/hooks/useReportPost/useReportPost.test.ts b/packages/frontend/src/features/post/hooks/useReportPost/useReportPost.test.ts index 7e24bc124..7989b87fc 100644 --- a/packages/frontend/src/features/post/hooks/useReportPost/useReportPost.test.ts +++ b/packages/frontend/src/features/post/hooks/useReportPost/useReportPost.test.ts @@ -31,6 +31,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ }, }, getGuaranteedUserState: () => ({ + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], waitForSync: jest.fn(), latestTransitionedEpoch: jest.fn().mockResolvedValue(1), genEpochKeyProof: jest.fn().mockResolvedValue({ diff --git a/packages/frontend/src/features/post/hooks/useVotes/useVotes.test.ts b/packages/frontend/src/features/post/hooks/useVotes/useVotes.test.ts index 4d9e069eb..fb6aaef21 100644 --- a/packages/frontend/src/features/post/hooks/useVotes/useVotes.test.ts +++ b/packages/frontend/src/features/post/hooks/useVotes/useVotes.test.ts @@ -18,6 +18,7 @@ jest.mock('@/features/core/hooks/useRelayConfig/useRelayConfig', () => ({ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ useUserState: () => ({ userState: { + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], getEpochKeys: jest .fn() .mockReturnValue(['epochKey-1', 'epochKey-2'].join(',')), @@ -27,6 +28,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ }, }, getGuaranteedUserState: () => ({ + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], getEpochKeys: jest .fn() .mockReturnValue(['epochKey-1', 'epochKey-2'].join(',')), diff --git a/packages/frontend/src/features/reporting/components/AdjudicateNotification/AdjudicateNotification.test.tsx b/packages/frontend/src/features/reporting/components/AdjudicateNotification/AdjudicateNotification.test.tsx index fddb485ce..4d13c758f 100644 --- a/packages/frontend/src/features/reporting/components/AdjudicateNotification/AdjudicateNotification.test.tsx +++ b/packages/frontend/src/features/reporting/components/AdjudicateNotification/AdjudicateNotification.test.tsx @@ -11,6 +11,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ id: { secret: '0x123', }, + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], genProveReputationProof: jest.fn().mockResolvedValue({ publicSignals: 'mocked_signals', proof: 'mocked_proof', diff --git a/packages/frontend/src/features/reporting/hooks/useAdjudicate/useAdjudicate.test.ts b/packages/frontend/src/features/reporting/hooks/useAdjudicate/useAdjudicate.test.ts index b64739f71..c12b509ec 100644 --- a/packages/frontend/src/features/reporting/hooks/useAdjudicate/useAdjudicate.test.ts +++ b/packages/frontend/src/features/reporting/hooks/useAdjudicate/useAdjudicate.test.ts @@ -24,6 +24,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ id: { secret: '0x123', }, + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], latestTransitionedEpoch: jest.fn().mockResolvedValue(2), genProveReputationProof: jest.fn().mockResolvedValue({ publicSignals: 'mocked_signals', @@ -39,6 +40,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ id: { secret: '0x123', }, + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], latestTransitionedEpoch: jest.fn().mockResolvedValue(2), genProveReputationProof: jest.fn().mockResolvedValue({ publicSignals: 'mocked_signals', diff --git a/packages/frontend/src/features/reporting/hooks/useGetWaitForTransactReport/useWaitForTransactionReport.test.ts b/packages/frontend/src/features/reporting/hooks/useGetWaitForTransactReport/useWaitForTransactionReport.test.ts index 8e6b09154..d20fce447 100644 --- a/packages/frontend/src/features/reporting/hooks/useGetWaitForTransactReport/useWaitForTransactionReport.test.ts +++ b/packages/frontend/src/features/reporting/hooks/useGetWaitForTransactReport/useWaitForTransactionReport.test.ts @@ -10,6 +10,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ id: { secret: '0x123', }, + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], genProveReputationProof: jest.fn().mockResolvedValue({ publicSignals: 'mocked_signals', proof: 'mocked_proof', diff --git a/packages/frontend/src/features/reporting/hooks/usePendingReports/usePendingReports.test.ts b/packages/frontend/src/features/reporting/hooks/usePendingReports/usePendingReports.test.ts index 36f2071ae..cd6cc05bc 100644 --- a/packages/frontend/src/features/reporting/hooks/usePendingReports/usePendingReports.test.ts +++ b/packages/frontend/src/features/reporting/hooks/usePendingReports/usePendingReports.test.ts @@ -10,6 +10,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({ id: { secret: '0x123', }, + getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)], genProveReputationProof: jest.fn().mockResolvedValue({ publicSignals: 'mocked_signals', proof: 'mocked_proof',