diff --git a/src/resources/Disputes.js b/src/resources/Disputes.js index 1af7b55..262e1a5 100644 --- a/src/resources/Disputes.js +++ b/src/resources/Disputes.js @@ -127,7 +127,7 @@ class Disputes { const amountShift = event.args._amount.toNumber() // juror won/lost tokens if (address === account) { - const userProfile = await this._StoreProviderInstance.getUserProfile( + const userProfile = await this._StoreProviderInstance.setUpUserProfile( account ) const contractAddress = this._ArbitratorInstance.getContractAddress() diff --git a/src/resources/Notifications.js b/src/resources/Notifications.js index 038d74c..7f8b2d2 100644 --- a/src/resources/Notifications.js +++ b/src/resources/Notifications.js @@ -234,8 +234,7 @@ class Notifications { */ getUnreadStoredNotifications = async account => { this._requireStoreProvider() - - const profile = await this._StoreProviderInstance.getUserProfile(account) + const profile = await this._StoreProviderInstance.setUpUserProfile(account) const currentArbitrator = this._ArbitratorInstance.getContractAddress() // return notifications that are for current arbitrator and are unread return _.filter( @@ -605,7 +604,7 @@ class Notifications { // If we have store provider fetch contracts and disputes from the store. if (this._StoreProviderInstance) { - const userProfile = await this._StoreProviderInstance.getUserProfile( + const userProfile = await this._StoreProviderInstance.setUpUserProfile( account ) diff --git a/src/utils/StoreProviderWrapper.js b/src/utils/StoreProviderWrapper.js index 81a0e59..14cb501 100644 --- a/src/utils/StoreProviderWrapper.js +++ b/src/utils/StoreProviderWrapper.js @@ -172,7 +172,7 @@ class StoreProviderWrapper { * @returns {number} The last block number. */ getLastBlock = async userAddress => { - const userProfile = await this.getUserProfile(userAddress) + const userProfile = await this.setUpUserProfile(userAddress) return userProfile.lastBlock || 0 } @@ -229,10 +229,10 @@ class StoreProviderWrapper { setUpUserProfile = async userAddress => { let userProfile = await this.getUserProfile(userAddress) if (_.isNull(userProfile)) { - this.updateUserProfile(userAddress, {}) - userProfile = await this.queueReadRequest( - `${this._storeUri}/${userAddress}` - ) + const response = await this.updateUserProfile(userAddress, {}) + if (response.status !== 201) + throw new Error(errorConstants.REQUEST_FAILED(response.responseText)) + userProfile = response.body } return userProfile @@ -329,7 +329,7 @@ class StoreProviderWrapper { params ) => { const getBodyFn = async () => { - const userProfile = await this.getUserProfile(userAddress) + const userProfile = await this.setUpUserProfile(userAddress) const currentDisputeProfile = _.filter( @@ -438,7 +438,7 @@ class StoreProviderWrapper { isRead = true ) => { const getBodyFn = async () => { - const userProfile = await this.getUserProfile(userAddress) + const userProfile = await this.setUpUserProfile(userAddress) const notificationIndex = await _.findIndex( userProfile.notifications,