Merge pull request #306 from status-im/feat/add-events-on-new-offers
feat: watch new offers created
This commit is contained in:
commit
09f8dc0885
|
@ -22,6 +22,7 @@ import {
|
|||
WATCH_ESCROW, ESCROW_EVENT_RECEIVED, WATCH_ESCROW_CREATIONS, ESCROW_CREATED_EVENT_RECEIVED, GET_LAST_ACTIVITY, GET_LAST_ACTIVITY_SUCCEEDED, GET_LAST_ACTIVITY_FAILED
|
||||
} from './constants';
|
||||
import {eventTypes} from './helpers';
|
||||
import {ADD_OFFER_SUCCEEDED} from "../metadata/constants";
|
||||
|
||||
export function *createEscrow({user, escrow}) {
|
||||
const toSend = Escrow.methods.create(
|
||||
|
@ -301,8 +302,21 @@ export function *onWatchEscrowCreations() {
|
|||
yield takeEvery(WATCH_ESCROW_CREATIONS, watchEscrowCreations);
|
||||
}
|
||||
|
||||
export function *watchNewOffer({offer, receipt}) {
|
||||
try {
|
||||
const newOffer = Object.assign({}, offer, {id: receipt.events.OfferAdded.returnValues.offerId});
|
||||
yield put({type: WATCH_ESCROW_CREATIONS, offers: [newOffer]});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
export function *onWatchAddOfferSuccess() {
|
||||
yield takeEvery(ADD_OFFER_SUCCEEDED, watchNewOffer);
|
||||
}
|
||||
|
||||
export default [
|
||||
fork(onCreateEscrow), fork(onLoadEscrows), fork(onGetEscrow), fork(onReleaseEscrow), fork(onCancelEscrow), fork(onUserRating), fork(onAddUserRating),
|
||||
fork(onRateTx), fork(onPayEscrow), fork(onPayEscrowSignature), fork(onOpenCase), fork(onOpenCaseSignature), fork(onOpenCaseSuccess),
|
||||
fork(onGetFee), fork(onFundEscrow), fork(onWatchEscrow), fork(onWatchEscrowCreations), fork(onGetEscrowAfterEvent), fork(onGetLastActivity)
|
||||
fork(onGetFee), fork(onFundEscrow), fork(onWatchEscrow), fork(onWatchEscrowCreations), fork(onGetEscrowAfterEvent), fork(onGetLastActivity), fork(onWatchAddOfferSuccess)
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue