-
Notifications
You must be signed in to change notification settings - Fork 39
/
SweepSwaps.ts
35 lines (27 loc) · 901 Bytes
/
SweepSwaps.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Arguments } from 'yargs';
import { SweepSwapsRequest } from '../../proto/boltzrpc_pb';
import BuilderComponents from '../BuilderComponents';
import { callback, loadBoltzClient } from '../Command';
export const command = 'sweepswaps [symbol]';
export const describe = 'sweeps all deferred swap claims';
export const builder = {
symbol: BuilderComponents.symbol,
};
export const handler = (argv: Arguments<any>): void => {
const request = new SweepSwapsRequest();
if (argv.symbol !== undefined && argv.symbol !== '') {
request.setSymbol(argv.symbol);
}
loadBoltzClient(argv).sweepSwaps(
request,
callback((res) => {
const sweep: Record<string, string[]> = {};
for (const [, [symbol, swapIds]] of res
.toObject()
.claimedSymbolsMap.entries()) {
sweep[symbol] = swapIds.claimedIdsList;
}
return sweep;
}),
);
};