Skip to content

Commit 8a95c69

Browse files
author
Karl Ranna
authored
feat: upgrade grpc-js to 1.1.7 (#102)
1 parent c66fb7c commit 8a95c69

14 files changed

+307
-192
lines changed

package-lock.json

Lines changed: 287 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"typescript": "3.9.3"
5151
},
5252
"dependencies": {
53-
"@grpc/grpc-js": "1.0.4",
53+
"@grpc/grpc-js": "1.1.7",
5454
"axios": "0.19.2",
5555
"axios-debug-log": "0.7.0",
5656
"bignumber.js": "9.0.0",

src/opendex/swap-success.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Config } from '../config';
44
import { RETRY_INTERVAL } from '../constants';
55
import { XudClient } from '../proto/xudrpc_grpc_pb';
66
import { SwapSuccess } from '../proto/xudrpc_pb';
7-
import { parseGrpcError } from './xud/parse-error';
87
import { SubscribeSwapsParams } from './xud/subscribe-swaps';
98

109
type GetOpenDEXswapSuccessParams = {
@@ -32,7 +31,7 @@ const getOpenDEXswapSuccess$ = ({
3231
] = partition(
3332
getXudClient$(config).pipe(
3433
mergeMap(client => {
35-
return subscribeXudSwaps$({ client, config, parseGrpcError });
34+
return subscribeXudSwaps$({ client, config });
3635
}),
3736
share()
3837
),

src/opendex/xud/balance.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Observable } from 'rxjs';
22
import { XudClient } from '../../proto/xudrpc_grpc_pb';
33
import { GetBalanceRequest, GetBalanceResponse } from '../../proto/xudrpc_pb';
44
import { processResponse } from './process-response';
5-
import { parseGrpcError } from './parse-error';
65

76
const getXudBalance$ = (client: XudClient): Observable<GetBalanceResponse> => {
87
const request = new GetBalanceRequest();
@@ -11,7 +10,6 @@ const getXudBalance$ = (client: XudClient): Observable<GetBalanceResponse> => {
1110
request,
1211
processResponse({
1312
subscriber,
14-
parseGrpcError,
1513
})
1614
);
1715
});

src/opendex/xud/create-order.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { PlaceOrderRequest, PlaceOrderResponse } from '../../proto/xudrpc_pb';
66
import { satsToCoinsStr } from '../../utils';
77
import { OpenDEXorder } from '../orders';
88
import { processResponse } from './process-response';
9-
import { parseGrpcError } from './parse-error';
109

1110
type CreateXudOrderParams = OpenDEXorder & {
1211
logger: Logger;
@@ -52,7 +51,6 @@ const createXudOrder$ = ({
5251
request,
5352
processResponse({
5453
subscriber,
55-
parseGrpcError,
5654
})
5755
);
5856
}).pipe(

src/opendex/xud/list-orders.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { XudClient } from '../../proto/xudrpc_grpc_pb';
33
import { ListOrdersRequest, ListOrdersResponse } from '../../proto/xudrpc_pb';
44
import { processResponse } from './process-response';
55
import { map } from 'rxjs/operators';
6-
import { parseGrpcError } from './parse-error';
76

87
type ListXudOrdersResponse = {
98
client: XudClient;
@@ -19,7 +18,6 @@ const listXudOrders$ = (
1918
request,
2019
processResponse({
2120
subscriber,
22-
parseGrpcError,
2321
})
2422
);
2523
});

src/opendex/xud/parse-error.spec.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/opendex/xud/parse-error.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/opendex/xud/process-response.spec.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ describe('processResponse', () => {
99
test('success', done => {
1010
expect.assertions(1);
1111
const nextValue = 'next';
12-
const parseGrpcError = jest.fn().mockReturnValue('error');
1312
const source$ = new Observable(subscriber => {
1413
processResponse({
1514
subscriber,
16-
parseGrpcError,
1715
})(null, nextValue);
1816
});
1917
source$.subscribe({
@@ -25,23 +23,18 @@ describe('processResponse', () => {
2523
});
2624

2725
test('error', done => {
28-
expect.assertions(3);
26+
expect.assertions(1);
2927
const errorValue = ('errorValue' as unknown) as ServiceError;
30-
const parsedError = 'parsedError';
31-
const parseGrpcError = jest.fn().mockReturnValue(parsedError);
3228
const source$ = new Observable(subscriber => {
3329
processResponse({
34-
parseGrpcError,
3530
subscriber,
3631
})(errorValue, null);
3732
});
3833
source$.subscribe({
3934
error: errorMsg => {
40-
expect(errorMsg).toEqual(parsedError);
35+
expect(errorMsg).toEqual(errorValue);
4136
done();
4237
},
4338
});
44-
expect(parseGrpcError).toHaveBeenCalledWith(errorValue);
45-
expect(parseGrpcError).toHaveBeenCalledTimes(1);
4639
});
4740
});

src/opendex/xud/process-response.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
import { ServiceError } from '@grpc/grpc-js';
22
import { Subscriber } from 'rxjs';
3-
import { ParseGrpcErrorResponse } from './parse-error';
43

54
type ProcessResponseParams = {
65
subscriber: Subscriber<unknown>;
7-
parseGrpcError: (error: ServiceError) => ParseGrpcErrorResponse;
86
};
97

10-
const processResponse = ({
11-
subscriber,
12-
parseGrpcError,
13-
}: ProcessResponseParams) => {
8+
const processResponse = ({ subscriber }: ProcessResponseParams) => {
149
return (error: ServiceError | null, response: any) => {
1510
if (error) {
16-
const parsedError = parseGrpcError(error);
17-
parsedError && subscriber.error(parsedError);
11+
subscriber.error(error);
1812
} else {
1913
subscriber.next(response);
2014
}

0 commit comments

Comments
 (0)