Skip to content

Commit

Permalink
Merge pull request #176 from lightninglabs/pool-user-agent
Browse files Browse the repository at this point in the history
Add Pool user agent
  • Loading branch information
guggero authored Jan 29, 2021
2 parents 93523cd + 955920a commit ad5e49b
Show file tree
Hide file tree
Showing 32 changed files with 423 additions and 337 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN apk add --no-cache --update alpine-sdk \

# The first stage is already done and all static assets should now be generated
# in the app/build sub directory.
FROM golang:1.15.5-alpine as golangbuilder
FROM golang:1.15.7-alpine as golangbuilder

# Instead of checking out from git again, we just copy the whole working
# directory of the previous stage that includes the generated static assets.
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PKG := github.com/lightninglabs/lightning-terminal
ESCPKG := github.com\/lightninglabs\/lightning-terminal
LND_PKG := github.com/lightningnetwork/lnd
LOOP_PKG := github.com/lightninglabs/loop
POOL_PKG := github.com/lightninglabs/pool

LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
GOVERALLS_PKG := github.com/mattn/goveralls
Expand All @@ -23,6 +24,12 @@ LOOP_COMMIT := $(shell cat go.mod | \
awk -F " " '{ print $$2 }' | \
awk -F "/" '{ print $$1 }')

POOL_COMMIT := $(shell cat go.mod | \
grep $(POOL_PKG) | \
head -n1 | \
awk -F " " '{ print $$2 }' | \
awk -F "/" '{ print $$1 }')

LINT_COMMIT := v1.18.0
GOACC_COMMIT := ddc355013f90fea78d83d3a6c71f1d37ac07ecd5

Expand Down Expand Up @@ -52,7 +59,8 @@ make_ldflags = $(2) -X $(LND_PKG)/build.Commit=lightning-terminal-$(COMMIT) \
-X $(LND_PKG)/build.CommitHash=$(COMMIT_HASH) \
-X $(LND_PKG)/build.GoVersion=$(GOVERSION) \
-X $(LND_PKG)/build.RawTags=$(shell echo $(1) | sed -e 's/ /,/g') \
-X $(LOOP_PKG).Commit=$(LOOP_COMMIT)
-X $(LOOP_PKG).Commit=$(LOOP_COMMIT) \
-X $(POOL_PKG).Commit=$(POOL_COMMIT)

LDFLAGS := $(call make_ldflags, $(LND_RELEASE_TAGS))

Expand Down Expand Up @@ -119,7 +127,7 @@ go-install-cli:
$(GOINSTALL) -trimpath -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" github.com/lightningnetwork/lnd/cmd/lncli
$(GOINSTALL) -trimpath -ldflags "$(LDFLAGS)" github.com/lightninglabs/loop/cmd/loop
$(GOINSTALL) -trimpath github.com/lightninglabs/faraday/cmd/frcli
$(GOINSTALL) -trimpath github.com/lightninglabs/pool/cmd/pool
$(GOINSTALL) -trimpath -ldflags "$(LDFLAGS)" github.com/lightninglabs/pool/cmd/pool

app-build: yarn-install
@$(call print, "Building production app.")
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Lightning Terminal is backwards compatible with `lnd` back to version v0.11.1-be

| LiT | LND |
| ---------------- | ------------ |
| **v0.4.0-alpha** | v0.11.1-beta |
| **v0.3.4-alpha** | v0.11.1-beta |
| **v0.3.3-alpha** | v0.11.1-beta |
| **v0.3.2-alpha** | v0.11.1-beta |
Expand All @@ -77,6 +78,7 @@ Lightning Terminal is backwards compatible with `lnd` back to version v0.11.1-be

| LiT | LND | Loop | Faraday | Pool |
| ---------------- | ------------ | ----------- | ------------ |---------------|
| **v0.4.0-alpha** | v0.12.0-beta | v0.11.2-beta | v0.2.3-alpha | v0.4.3-alpha |
| **v0.3.4-alpha** | v0.11.1-beta | v0.11.2-beta | v0.2.2-alpha | v0.3.4-alpha |
| **v0.3.3-alpha** | v0.11.1-beta | v0.11.2-beta | v0.2.2-alpha | v0.3.4-alpha |
| **v0.3.2-alpha** | v0.11.1-beta | v0.11.1-beta | v0.2.2-alpha | v0.3.4-alpha |
Expand Down
10 changes: 6 additions & 4 deletions app/scripts/build-protos.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const util = require('util');
const https = require('https');
const exec = util.promisify(require('child_process').exec);
const { promises: fs } = require('fs');
const { join, sep } = require('path');
const { promises: fs, mkdirSync } = require('fs');
const { join, sep, dirname } = require('path');
const { platform } = require('os');
const appPath = join(__dirname, '..');

Expand Down Expand Up @@ -41,7 +41,7 @@ const protoSources = async () => {
lnd: `lightningnetwork/lnd/${lndVersion[1]}/lnrpc/rpc.proto`,
loop: `lightninglabs/loop/${loopVersion[1]}/looprpc/client.proto`,
trader: `lightninglabs/pool/${poolVersion[1]}/poolrpc/trader.proto`,
auctioneer: `lightninglabs/pool/${poolVersion[1]}/poolrpc/auctioneer.proto`,
'auctioneerrpc/auctioneer': `lightninglabs/pool/${poolVersion[1]}/auctioneerrpc/auctioneer.proto`,
};
};

Expand All @@ -50,7 +50,7 @@ const filePatches = {
lnd: 'lnrpc: {}',
loop: 'looprpc: {}',
trader: 'poolrpc: {}',
auctioneer: 'poolrpc: {}',
'auctioneerrpc/auctioneer': 'poolrpc: {}',
'google/api/annotations': 'google: { api: {} }',
'google/api/http': 'google: { api: {} }',
};
Expand All @@ -63,6 +63,7 @@ const download = async () => {
for ([name, urlPath] of Object.entries(await protoSources())) {
const url = `https://raw.githubusercontent.com/${urlPath}`;
const filePath = join(appPath, '..', 'proto', `${name}.proto`);
mkdirSync(dirname(filePath), {recursive: true});
console.log(`${url}`);
console.log(` -> ${filePath}`);
const content = await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -92,6 +93,7 @@ const generate = async () => {
);
const protocCmd = [
'protoc',
`-I../proto`,
`--plugin=protoc-gen-ts=${protocGen}`,
'--proto_path=../proto',
'--js_out=import_style=commonjs,binary:./src/types/generated',
Expand Down
2 changes: 1 addition & 1 deletion app/src/__tests__/store/batchStore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { keys, runInAction, values } from 'mobx';
import * as AUCT from 'types/generated/auctioneer_pb';
import * as AUCT from 'types/generated/auctioneerrpc/auctioneer_pb';
import { grpc } from '@improbable-eng/grpc-web';
import { waitFor } from '@testing-library/react';
import * as config from 'config';
Expand Down
2 changes: 1 addition & 1 deletion app/src/__tests__/store/orderStore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { values } from 'mobx';
import * as AUCT from 'types/generated/auctioneer_pb';
import * as AUCT from 'types/generated/auctioneerrpc/auctioneer_pb';
import * as POOL from 'types/generated/trader_pb';
import { grpc } from '@improbable-eng/grpc-web';
import { waitFor } from '@testing-library/react';
Expand Down
6 changes: 5 additions & 1 deletion app/src/api/pool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as AUCT from 'types/generated/auctioneer_pb';
import * as AUCT from 'types/generated/auctioneerrpc/auctioneer_pb';
import * as POOL from 'types/generated/trader_pb';
import { Trader } from 'types/generated/trader_pb_service';
import { b64 } from 'util/strings';
Expand All @@ -22,6 +22,8 @@ export const MIN_FEE_RATE_KW = 253;
// see: https://github.com/lightninglabs/pool/blob/master/order/interface.go#L35
export const ORDER_VERSION = 2;

const POOL_INITIATOR = 'lit-ui';

/** the names and argument types for the subscription events */
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface PoolEvents {}
Expand Down Expand Up @@ -63,6 +65,7 @@ class PoolApi extends BaseApi<PoolEvents> {
req.setAccountValue(amount);
req.setRelativeHeight(expiryBlocks);
req.setConfTarget(confTarget);
req.setInitiator(POOL_INITIATOR);
const res = await this._grpc.request(Trader.InitAccount, req, this._meta);
return res.toObject();
}
Expand Down Expand Up @@ -176,6 +179,7 @@ class PoolApi extends BaseApi<PoolEvents> {
}

const req = new POOL.SubmitOrderRequest();
req.setInitiator(POOL_INITIATOR);

const order = new POOL.Order();
order.setTraderKey(b64(traderKey));
Expand Down
2 changes: 1 addition & 1 deletion app/src/store/models/batch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeAutoObservable, observable } from 'mobx';
import * as AUCT from 'types/generated/auctioneer_pb';
import * as AUCT from 'types/generated/auctioneerrpc/auctioneer_pb';
import { LeaseDuration } from 'types/state';
import Big from 'big.js';
import { toPercent } from 'util/bigmath';
Expand Down
2 changes: 1 addition & 1 deletion app/src/store/models/lease.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeAutoObservable } from 'mobx';
import * as AUCT from 'types/generated/auctioneer_pb';
import * as AUCT from 'types/generated/auctioneerrpc/auctioneer_pb';
import * as POOL from 'types/generated/trader_pb';
import Big from 'big.js';
import { CsvColumns } from 'util/csv';
Expand Down
2 changes: 1 addition & 1 deletion app/src/store/models/market.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeAutoObservable, observable, ObservableMap } from 'mobx';
import * as AUCT from 'types/generated/auctioneer_pb';
import * as AUCT from 'types/generated/auctioneerrpc/auctioneer_pb';
import { hex } from 'util/strings';
import { Store } from 'store';
import { Batch } from './';
Expand Down
2 changes: 1 addition & 1 deletion app/src/store/models/order.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeAutoObservable } from 'mobx';
import * as AUCT from 'types/generated/auctioneer_pb';
import * as AUCT from 'types/generated/auctioneerrpc/auctioneer_pb';
import * as POOL from 'types/generated/trader_pb';
import { SortParams } from 'types/state';
import Big from 'big.js';
Expand Down
2 changes: 1 addition & 1 deletion app/src/store/stores/batchStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
values,
when,
} from 'mobx';
import { NodeTier } from 'types/generated/auctioneer_pb';
import { NodeTier } from 'types/generated/auctioneerrpc/auctioneer_pb';
import { LeaseDuration } from 'types/state';
import { IS_DEV, IS_TEST } from 'config';
import debounce from 'lodash/debounce';
Expand Down
2 changes: 1 addition & 1 deletion app/src/store/stores/settingsStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { autorun, makeAutoObservable, toJS } from 'mobx';
import { NodeTier } from 'types/generated/auctioneer_pb';
import { NodeTier } from 'types/generated/auctioneerrpc/auctioneer_pb';
import { SortParams } from 'types/state';
import {
BalanceMode,
Expand Down
5 changes: 4 additions & 1 deletion app/src/store/views/batchesView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { entries, makeAutoObservable } from 'mobx';
import { DurationBucketState, NodeTier } from 'types/generated/auctioneer_pb';
import {
DurationBucketState,
NodeTier,
} from 'types/generated/auctioneerrpc/auctioneer_pb';
import { toPercent } from 'util/bigmath';
import { Store } from 'store';

Expand Down
5 changes: 4 additions & 1 deletion app/src/store/views/orderFormView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { entries, makeAutoObservable, runInAction } from 'mobx';
import { DurationBucketState, NodeTier } from 'types/generated/auctioneer_pb';
import {
DurationBucketState,
NodeTier,
} from 'types/generated/auctioneerrpc/auctioneer_pb';
import { LeaseDuration } from 'types/state';
import { annualPercentRate, toBasisPoints, toPercent } from 'util/bigmath';
import { BLOCKS_PER_DAY } from 'util/constants';
Expand Down
2 changes: 1 addition & 1 deletion app/src/store/views/orderListView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeAutoObservable, observable } from 'mobx';
import { OrderState } from 'types/generated/auctioneer_pb';
import { OrderState } from 'types/generated/auctioneerrpc/auctioneer_pb';
import { Store } from 'store';
import { Channel } from 'store/models';
import { LeaseView } from './';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ad5e49b

Please sign in to comment.