Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/contracts/abstractions/Arbitrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class Arbitrator extends AbstractContract {
)

// FIXME do we want to store session?
// this._StoreProvider.updateUserProfile(account, {
// session: currentSession
// })
this._StoreProvider.updateUserSession(account, currentSession)
}

return this.getDisputesForUserFromStore(account)
Expand Down
23 changes: 23 additions & 0 deletions src/utils/StoreProviderWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,29 @@ class StoreProviderWrapper {
)
}

/**
* Update users last processed session.
* @param {string} userAddress - User's address.
* @param {string} session - The current session that the user has processed
* @returns {object} - HTTP response.
*/
updateUserSession = async (userAddress, session) => {
const getBodyFn = () =>
new Promise(resolve =>
resolve(
JSON.stringify({
session
})
)
)

return this.queueWriteRequest(
getBodyFn,
'POST',
`${this._storeUri}/${userAddress}/session`
)
}

/**
* Update the stored data on a contract for a user. Note that you cannot overwrite contract data.
* @param {string} userAddress - The user's address.
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/contracts/abstractions/Arbitrator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe('Arbitrator', () => {
const mockSetUpUserProfile = jest.fn()
const mockGetDisputesForJuror = jest.fn()
const mockUpdateDisputeProfile = jest.fn()
const mockUpdateSession = jest.fn()
const mockDispute = {
arbitratorAddress: arbitratorAddress,
disputeId: '1',
Expand All @@ -131,7 +132,8 @@ describe('Arbitrator', () => {
session: 1
})
),
updateDisputeProfile: mockUpdateDisputeProfile
updateDisputeProfile: mockUpdateDisputeProfile,
updateUserSession: mockUpdateSession
}

arbitratorInstance.setStoreProviderInstance(mockStoreProvider)
Expand Down Expand Up @@ -170,6 +172,7 @@ describe('Arbitrator', () => {
appealDraws: mockDispute.appealDraws,
blockNumber: 1
})
expect(mockUpdateSession.mock.calls.length).toBe(1)
})
})
})