Skip to content

Commit 5aa0053

Browse files
authored
feat: price service (#360)
Signed-off-by: Norman Meier <norman@berty.tech> Signed-off-by: Norman Meier <norman@berty.tech>
1 parent 30274fd commit 5aa0053

File tree

35 files changed

+3695
-40
lines changed

35 files changed

+3695
-40
lines changed

.env

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ TLD=.tori
1515

1616
TERITORI_NETWORK_ID=teritori-testnet
1717

18-
TERITORI_MINTER_CODE_IDS=27
18+
TERITORI_MINTER_CODE_IDS=27,40,43
1919
TERITORI_NAME_SERVICE_CONTRACT_ADDRESS=tori18etjzrma5604af50jjklk3wlkqcsxdrvmy6jzw5naw2t7kyv4rys3kpwky
2020
TERITORI_NAME_SERVICE_DEFAULT_IMAGE_URL=ipfs://bafkreieqcwmjcb64r42ygs6a4dswz63djzgayjn3rhzjber3e42cknawlm
2121
TERITORI_VAULT_CONTRACT_ADDRESS=tori13d26fzmvuvlvvxwt3ur0vkv8j6f28mf4nqfmxu3xk5r57wzxxglqut8ezk
@@ -29,7 +29,7 @@ TORIPUNKS_COLLECTION_ADDRESS=tori1plr28ztj64a47a32lw7tdae8vluzm2lm7nqk364r4ws50r
2929
TERITORI_CONTRACT_EXPLORER_URL=https://explorer.teritori.com/teritori-testnet/account/$address
3030
TERITORI_ACCOUNT_EXPLORER_URL=https://explorer.teritori.com/teritori-testnet/account/$address
3131
TERITORI_TRANSACTION_EXPLORER_URL=https://explorer.teritori.com/teritori-testnet/tx/$hash
32-
TERITORI_COLLECTION_WHITELIST=tori1zxzv4j9dxarfhxhkxm5cfnv06vy6g4l80adjwaq3dxdzmh5jm8rsrkzz65,tori18etjzrma5604af50jjklk3wlkqcsxdrvmy6jzw5naw2t7kyv4rys3kpwky
32+
TERITORI_COLLECTION_WHITELIST=tori1zxzv4j9dxarfhxhkxm5cfnv06vy6g4l80adjwaq3dxdzmh5jm8rsrkzz65,tori18etjzrma5604af50jjklk3wlkqcsxdrvmy6jzw5naw2t7kyv4rys3kpwky,tori10z8um7u47e24rv68ghd43tspeztmqy3cc283gvc3pj48zxs5ljdqn84deq,tori1f79tgydtrzemkxf50xzvyf0xe9ckynuvgyr2f0580e04fe5nep5skgcdqc
3333

3434
#Just for DB local instance
3535
POSTGRES_USER=postgres
@@ -41,3 +41,9 @@ DB_INDEXER_PORT=5432
4141
# dapp RO DB
4242
DB_DAPP_HOST=127.0.0.1
4343
DB_DAPP_PORT=5432
44+
45+
PRICES_DB_HOST=127.0.0.1
46+
PRICES_DB_PORT=5433
47+
PRICES_DB_NAME=postgres
48+
PRICES_DB_USER=postgres
49+
PRICES_DB_PASSWORD=magic

Makefile

+15
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ CONTRACTS_CLIENTS_DIR=packages/contracts-clients
1818
DOCKER_REGISTRY=rg.nl-ams.scw.cloud/teritori
1919
INDEXER_DOCKER_IMAGE=$(DOCKER_REGISTRY)/teritori-indexer:$(shell git rev-parse --short HEAD)
2020
BACKEND_DOCKER_IMAGE=$(DOCKER_REGISTRY)/teritori-dapp-backend:$(shell git rev-parse --short HEAD)
21+
PRICES_SERVICE_DOCKER_IMAGE=$(DOCKER_REGISTRY)/prices-service:$(shell git rev-parse --short HEAD)
22+
PRICES_OHLC_REFRESH_DOCKER_IMAGE=$(DOCKER_REGISTRY)/prices-ohlc-refresh:$(shell git rev-parse --short HEAD)
2123

2224
node_modules: package.json yarn.lock
2325
yarn
@@ -146,3 +148,16 @@ publish.backend:
146148
publish.indexer:
147149
docker build -f go/cmd/teritori-indexer/Dockerfile . --platform amd64 -t $(INDEXER_DOCKER_IMAGE)
148150
docker push $(INDEXER_DOCKER_IMAGE)
151+
152+
publish.prices-service:
153+
docker build -f go/cmd/prices-service/Dockerfile . --platform amd64 -t $(PRICES_SERVICE_DOCKER_IMAGE)
154+
docker push $(PRICES_SERVICE_DOCKER_IMAGE)
155+
156+
publish.prices-ohlc-refresh:
157+
docker build -f go/cmd/prices-ohlc-refresh/Dockerfile . --platform amd64 -t $(PRICES_OHLC_REFRESH_DOCKER_IMAGE)
158+
docker push $(PRICES_OHLC_REFRESH_DOCKER_IMAGE)
159+
160+
generate.sqlboiler-prices:
161+
go install github.com/volatiletech/sqlboiler/v4@latest
162+
go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest
163+
sqlboiler psql

api/prices/v1/prices.proto

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
syntax = "proto3";
2+
3+
package prices.v1;
4+
option go_package = "./pricespb";
5+
6+
service PricesService {
7+
rpc Prices(PricesRequest) returns (PricesResponse);
8+
}
9+
10+
message PricesRequest {
11+
string id = 1;
12+
string time = 2;
13+
repeated string vs_ids = 3;
14+
}
15+
16+
message Price {
17+
string id = 1;
18+
double value = 2;
19+
}
20+
21+
message PricesResponse {
22+
repeated Price prices = 1;
23+
}

docker-compose.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ services:
1010
- teritori-data:/var/lib/postgresql/data/ # persist data even if container shuts down
1111
ports:
1212
- "5432:5432"
13+
prices-postgres:
14+
image: postgres
15+
environment:
16+
- POSTGRES_USER=${POSTGRES_USER}
17+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
18+
- POSTGRES_DB=${DATABASE_NAME}
19+
volumes:
20+
- prices-data:/var/lib/postgresql/data/ # persist data even if container shuts down
21+
ports:
22+
- "5433:5432"
1323

1424
volumes:
15-
teritori-data: # named volumes can be managed easier using docker-compose
25+
teritori-data: # named volumes can be managed easier using docker-compose
26+
prices-data:

go.mod

+10-8
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ require (
1010
github.com/cosmos/cosmos-sdk v0.45.4
1111
github.com/cosmos/gogoproto v1.4.2
1212
github.com/davecgh/go-spew v1.1.1
13+
github.com/friendsofgo/errors v0.9.2
1314
github.com/gorilla/websocket v1.5.0
1415
github.com/improbable-eng/grpc-web v0.14.1
16+
github.com/jackc/pgx/v5 v5.1.1
1517
github.com/mehanizm/airtable v0.2.6
1618
github.com/peterbourgon/ff/v3 v3.3.0
1719
github.com/pkg/errors v0.9.1
20+
github.com/rubenv/sql-migrate v1.2.0
1821
github.com/tendermint/tendermint v0.34.19
22+
github.com/volatiletech/null/v8 v8.1.2
1923
github.com/volatiletech/sqlboiler/v4 v4.13.0
24+
github.com/volatiletech/strmangle v0.0.4
2025
go.uber.org/zap v1.19.1
2126
golang.org/x/exp v0.0.0-20221108223516-5d533826c662
2227
google.golang.org/grpc v1.49.0
@@ -62,7 +67,7 @@ require (
6267
github.com/klauspost/compress v1.13.6 // indirect
6368
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
6469
github.com/magiconair/properties v1.8.6 // indirect
65-
github.com/mattn/go-sqlite3 v1.14.12 // indirect
70+
github.com/mattn/go-sqlite3 v1.14.14 // indirect
6671
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
6772
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
6873
github.com/mitchellh/mapstructure v1.4.3 // indirect
@@ -87,14 +92,13 @@ require (
8792
github.com/tendermint/tm-db v0.6.7 // indirect
8893
github.com/vektah/gqlparser/v2 v2.4.5 // indirect
8994
go.etcd.io/bbolt v1.3.6 // indirect
90-
go.uber.org/atomic v1.9.0 // indirect
95+
go.uber.org/atomic v1.10.0 // indirect
9196
go.uber.org/multierr v1.7.0 // indirect
92-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
97+
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
9398
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
9499
golang.org/x/sys v0.1.0 // indirect
95-
golang.org/x/text v0.3.7 // indirect
100+
golang.org/x/text v0.3.8 // indirect
96101
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect
97-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
98102
gopkg.in/ini.v1 v1.66.4 // indirect
99103
gopkg.in/yaml.v2 v2.4.0 // indirect
100104
gopkg.in/yaml.v3 v3.0.1 // indirect
@@ -115,7 +119,7 @@ require (
115119
github.com/danieljoos/wincred v1.0.2 // indirect
116120
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
117121
github.com/ericlagergren/decimal v0.0.0-20181231230500-73749d4874d5 // indirect
118-
github.com/friendsofgo/errors v0.9.2 // indirect
122+
github.com/go-gorp/gorp/v3 v3.0.2 // indirect
119123
github.com/go-playground/validator/v10 v10.4.1 // indirect
120124
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
121125
github.com/gofrs/uuid v4.0.0+incompatible // indirect
@@ -144,9 +148,7 @@ require (
144148
github.com/tendermint/btcd v0.1.1 // indirect
145149
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
146150
github.com/volatiletech/inflect v0.0.1 // indirect
147-
github.com/volatiletech/null/v8 v8.1.2 // indirect
148151
github.com/volatiletech/randomize v0.0.1 // indirect
149-
github.com/volatiletech/strmangle v0.0.4 // indirect
150152
github.com/zondax/hid v0.9.0 // indirect
151153
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
152154
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect

0 commit comments

Comments
 (0)