Skip to content

Commit

Permalink
fixup! feat(connext): reconcile deposit when channel balance changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl Ranna committed Dec 9, 2020
1 parent 8696518 commit 124bb22
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/connextclient/ConnextClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,16 @@ class ConnextClient extends SwapClient {
}
const ethBalance$ = interval(30000).pipe(
mergeMap(() => from(this.getBalanceForAddress(this.channelAddress!))),
// only emit new ETH balance events when the balance changes
distinctUntilChanged(),
);
this._reconcileDepositSubscriber = ethBalance$
// when ETH balance changes
.pipe(
mergeMap(() => {
if (this.status === ClientStatus.ConnectionVerified) {
return defer(() => {
// create new commitment transaction
return from(
this.sendRequest('/deposit', 'POST', {
channelAddress: this.channelAddress,
Expand Down

0 comments on commit 124bb22

Please sign in to comment.