Skip to content

Commit

Permalink
dapp: adapt dapp to new async udcWithdraw events
Browse files Browse the repository at this point in the history
  • Loading branch information
andrevmatos committed Mar 24, 2021
1 parent f9c13f9 commit 4e81cd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions raiden-dapp/src/services/raiden-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ export default class RaidenService {
value.payload.reward,
value.payload.txHash,
);
} else if (value.type === 'udc/withdrawn') {
} else if (value.type === 'udc/withdraw/success') {
if (!value.payload.confirmed) {
return;
}
await this.notifyWithdrawal(value.meta.amount, value.payload.withdrawal);
} else if (value.type === 'udc/withdraw/failure') {
} else if (value.type === 'udc/withdraw/plan/failure') {
await this.notifyWithdrawalFailure(
value.payload?.code,
value.meta.amount,
Expand Down Expand Up @@ -481,7 +481,7 @@ export default class RaidenService {
}

private async updatePlannedUserDepositWithdrawals(event: ObservedValueOf<Raiden['events$']>) {
if (event.type === 'udc/withdraw/success') {
if (event.type === 'udc/withdraw/plan/success') {
if (event.payload.confirmed === false) {
this.store.commit('userDepositContract/clearPlannedWithdrawal');
} else {
Expand All @@ -493,7 +493,7 @@ export default class RaidenService {
confirmed: event.payload.confirmed,
});
}
} else if (event.type === 'udc/withdrawn' && event.payload.confirmed) {
} else if (event.type === 'udc/withdraw/success' && event.payload.confirmed) {
this.store.commit('userDepositContract/clearPlannedWithdrawal');
}
}
Expand Down
14 changes: 7 additions & 7 deletions raiden-dapp/tests/unit/raiden-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ describe('RaidenService', () => {
await setupSDK();

subject.next({
type: 'udc/withdrawn',
type: 'udc/withdraw/success',
payload: {
withdrawal: utils.parseEther('5'),
confirmed: true,
Expand Down Expand Up @@ -760,7 +760,7 @@ describe('RaidenService', () => {
await setupSDK({ subkey: true });

subject.next({
type: 'udc/withdrawn',
type: 'udc/withdraw/success',
payload: {
withdrawal: utils.parseEther('5'),
confirmed: true,
Expand All @@ -787,7 +787,7 @@ describe('RaidenService', () => {
(raiden as any).events$ = subject;
await setupSDK();
subject.next({
type: 'udc/withdraw/failure',
type: 'udc/withdraw/plan/failure',
payload: {
code: 'UDC_PLAN_WITHDRAW_EXCEEDS_AVAILABLE',
},
Expand All @@ -808,7 +808,7 @@ describe('RaidenService', () => {
(raiden as any).events$ = subject;
await setupSDK();
subject.next({
type: 'udc/withdraw/failure',
type: 'udc/withdraw/plan/failure',
payload: {
code: -3200,
message: 'gas',
Expand Down Expand Up @@ -1060,7 +1060,7 @@ describe('RaidenService', () => {
(raiden as any).events$ = subject;
await setupSDK();
subject.next({
type: 'udc/withdraw/success',
type: 'udc/withdraw/plan/success',
payload: {
block: 5,
txHash: '0xTxHash',
Expand All @@ -1084,7 +1084,7 @@ describe('RaidenService', () => {
(raiden as any).events$ = subject;
await setupSDK();
subject.next({
type: 'udc/withdraw/success',
type: 'udc/withdraw/plan/success',
payload: {
block: 5,
txHash: '0xTxHash',
Expand All @@ -1105,7 +1105,7 @@ describe('RaidenService', () => {
(raiden as any).events$ = subject;
await setupSDK();
subject.next({
type: 'udc/withdrawn',
type: 'udc/withdraw/success',
payload: {
confirmed: true,
withdrawal: constants.One,
Expand Down

0 comments on commit 4e81cd6

Please sign in to comment.