Skip to content

Commit 39d1eb2

Browse files
author
Karl Ranna
committed
fix(raiden): add getRoutes and getHeight compatibility
In this commit we're modifying `RaidenClient.getRoutes` and `getHeight` to be compatibile with the current `Swaps` implementation.
1 parent c48594b commit 39d1eb2

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lib/BaseClient.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Logger from './Logger';
22
import { EventEmitter } from 'events';
3-
import { SwapDeal } from './swaps/types';
4-
import { Route } from './proto/lndrpc_pb';
3+
import { SwapDeal, Route } from './swaps/types';
54
import { SwapClient } from './constants/enums';
65

76
enum ClientStatus {

lib/lndclient/LndClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class LndClient extends BaseClient {
223223

224224
if (deal.makerToTakerRoutes && deal.role === SwapRole.Maker) {
225225
const request = new lndrpc.SendToRouteRequest();
226-
request.setRoutesList(deal.makerToTakerRoutes);
226+
request.setRoutesList(deal.makerToTakerRoutes as lndrpc.Route[]);
227227
request.setPaymentHashString(deal.rHash);
228228

229229
try {

lib/raidenclient/RaidenClient.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,14 @@ class RaidenClient extends BaseClient {
136136
}
137137

138138
public getRoutes = async (_amount: number, _destination: string) => {
139-
return []; // stub placeholder, query routes not currently implemented in raiden
139+
// stub placeholder, query routes not currently implemented in raiden
140+
return [{
141+
getTotalTimeLock: () => 1,
142+
}];
140143
}
141144

142145
public getHeight = async () => {
143-
return 0; // raiden's API does not tell us the height
146+
return 1; // raiden's API does not tell us the height
144147
}
145148

146149
public getRaidenInfo = async (): Promise<RaidenInfo> => {

lib/swaps/types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { SwapRole, SwapPhase, SwapState, SwapFailureReason } from '../constants/enums';
2-
import { Route } from '../proto/lndrpc_pb';
32

43
export type SwapDeal = {
54
/** Our role in the swap. */
@@ -76,3 +75,7 @@ export type SwapFailure = Pick<SwapDeal, 'orderId' | 'pairId' | 'quantity' | 'pe
7675
quantity: number;
7776
failureReason: SwapFailureReason;
7877
};
78+
79+
export type Route = {
80+
getTotalTimeLock: Function,
81+
};

0 commit comments

Comments
 (0)