Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .custom-gcl.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
version: v2.7.2

name: dv-golangci-lint

destination: .bin/

plugins:
- module: 'github.com/dv-net/dv-merchant/pkg/linters/dbtxcheck'
path: ./pkg/linters/dbtxcheck
Expand Down
58 changes: 14 additions & 44 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,62 +25,32 @@ jobs:
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ${{ github.go.gopath }}/pkg/mod
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Update Git to latest version
run: |
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
git --version

- name: Create .bin directory
run: mkdir -p .bin

- name: Create frontend dist directory
run: |
mkdir -p frontend/dist
echo "/* Empty file for CI build */" > frontend/dist/dummy.txt

- name: Cache custom linter binary
uses: actions/cache@v4
with:
path: .bin/dv-golangci-lint
key: ${{ runner.os }}-custom-linter-${{ hashFiles('.custom-gcl.yml', 'pkg/linters/**/*.go') }}
restore-keys: |
${{ runner.os }}-custom-linter-

- name: Download dependencies
run: go mod download

# - name: Build custom linter plugins
# env:
# GIT: /usr/bin/git
# run: |
# echo "Building custom golangci-lint plugins..."
# which git
# git --version
# echo "Using GIT=$GIT"
# make build_plugins

# - name: Verify custom linter
# run: |
# if [ -f ".bin/dv-golangci-lint" ]; then
# echo "✅ Custom linter built successfully"
# ./.bin/dv-golangci-lint --version || echo "Custom linter version check failed"
# else
# echo "❌ Custom linter binary not found"
# ls -la .bin/ || echo ".bin directory not found"
# exit 1
# fi
#
# - name: Run custom linters
# run: |
# echo "Running custom linters with plugins..."
# make lint
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.7.2
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH

- name: Build custom linter
run: |
mkdir -p .bin
GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null \
golangci-lint custom -v

- name: Run linters
run: ./.bin/dv-golangci-lint run --timeout=5m --show-stats --config .golangci.yml

- name: Run tests
run: make test
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ run:
modules-download-mode: readonly
allow-parallel-runners: true
linters:
default: none
enable:
- asciicheck
- bodyclose
Expand All @@ -28,7 +27,7 @@ linters:
- goheader
- gomodguard
- goprintffuncname
- gosec
# - gosec
- govet
- grouper
- ineffassign
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

- feat: added exrate debug logging [DV-4033]
- feat: added clickjacking protection middleware [DV-3955]
- Currency reference data about it being native, and contract address for external routes [DV-3761]
- fix: duplicates withdrawal from processing on 'in_progress' transfer stage [DV-3933]
Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ endif
build:
go build $(GO_OPT_BASE) -o $(OUT_BIN) ./cmd/app

build_plugins:
go tool golangci-lint custom -v
build_custom_linter:
@echo "Building custom golangci-lint..."
@mkdir -p .bin
@if [ ! -f "$(CUSTOM_CI_LINTER)" ]; then \
GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null \
golangci-lint custom -v; \
fi

run: build
$(OUT_BIN) $(filter-out $@,$(MAKECMDGOALS))
Expand All @@ -53,12 +58,12 @@ test:
version: ## Version of the project to built
echo $(VERSION)

version-number: ## Version number of the project to be built
version-number:
echo $(VERSION_NUMBER)

## Lint:
lint: build_plugins
$(CUSTOM_CI_LINTER) run --show-stats
lint: build_custom_linter
$(CUSTOM_CI_LINTER) run --timeout=10m --show-stats --config .golangci.yml

fmt:
go tool gofumpt -l -w .
Expand Down Expand Up @@ -102,4 +107,4 @@ update-frontend:

# Empty goals trap
%:
@:
@:
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ go test ./...

<div align="center">

**Telegram:** [@dv_net_support_bot](https://t.me/dv_net_support_bot) • **Email:** [support@dv.net](mailto:support@dv.net)
**Telegram:** [@dv_net_support_bot](https://t.me/dv_net_support_bot) • **Telegram Chat:** [@dv_net_support_chat](https://t.me/dv_net_support_chat) • **Discord:** [discord.gg/Szy2XGsr](https://discord.gg/Szy2XGsr)

**Website:** [dv.net](https://dv.net) • **Docs:** [docs.dv.net](https://docs.dv.net)
**Email:** [support@dv.net](https://dv.net/#support) • **Website:** [dv.net](https://dv.net) • **Documentation:** [docs.dv.net](https://docs.dv.net)

</div>

Expand Down
4 changes: 2 additions & 2 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ go test ./...

<div align="center">

**Telegram:** [@dv_net_support_bot](https://t.me/dv_net_support_bot) • **Email:** [support@dv.net](mailto:support@dv.net)
**Telegram:** [@dv_net_support_bot](https://t.me/dv_net_support_bot) • **Чат в Telegram:** [@dv_net_support_chat](https://t.me/dv_net_support_chat) • **Discord:** [discord.gg/Szy2XGsr](https://discord.gg/Szy2XGsr)

**Сайт:** [dv.net](https://dv.net) • **Документация:** [docs.dv.net](https://docs.dv.net)
**Email:** [support@dv.net](https://dv.net/#support) • **Сайт:** [dv.net](https://dv.net) • **Документация:** [docs.dv.net](https://docs.dv.net)

</div>

Expand Down
4 changes: 2 additions & 2 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ go test ./...

<div align="center">

**Telegram:** [@dv_net_support_bot](https://t.me/dv_net_support_bot) • **Email:** [support@dv.net](mailto:support@dv.net)
**Telegram:** [@dv_net_support_bot](https://t.me/dv_net_support_bot) • **Telegram 群组:** [@dv_net_support_chat](https://t.me/dv_net_support_chat) • **Discord:** [discord.gg/Szy2XGsr](https://discord.gg/Szy2XGsr)

**官网:** [dv.net](https://dv.net) • **文档:** [docs.dv.net](https://docs.dv.net)
**邮箱:** [support@dv.net](https://dv.net/#support) • **网站:** [dv.net](https://dv.net) • **文档:** [docs.dv.net](https://docs.dv.net)

</div>

Expand Down
5 changes: 5 additions & 0 deletions configs/config.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ redis:
db_index: 0
exrate:
fetch_interval: 1m0s
timeout: 10s
proxies:
- http://user:pass@proxy1.example.com:8080
- https://user:pass@proxy2.example.com:443
- socks5://user:pass@proxy3.example.com:9050
admin:
base_url: https://api.dv.net/
ping_version_interval: 1h0m0s
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type (

ExrateConfig struct {
FetchInterval time.Duration `yaml:"fetch_interval" env:"FETCH_INTERVAL" default:"1m"`
Proxies []string `yaml:"proxies" example:"http://user:pass@proxy1.example.com:8080"`
Timeout time.Duration `yaml:"timeout" default:"10s"`
}

AdminConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/delivery/middleware/clickjacking.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ func ClickjackingMiddleware() fiber.Handler {
c.Set("Content-Security-Policy", "frame-ancestors 'self'")
return c.Next()
}
}
}
6 changes: 3 additions & 3 deletions internal/service/exchange/bitget/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (o *Service) GetDepositAddresses(ctx context.Context, currency, _ string) (
}

func (o *Service) CreateWithdrawalOrder(ctx context.Context, args *models.CreateWithdrawalOrderParams) (*models.ExchangeWithdrawalDTO, error) {
args.NativeAmount = args.NativeAmount.RoundDown(int32(args.WithdrawalPrecision))
args.NativeAmount = args.NativeAmount.RoundDown(int32(args.WithdrawalPrecision)) //nolint:gosec

internalCurrency, err := o.storage.ExchangeChains().GetTickerByCurrencyID(ctx, repo_exchange_chains.GetTickerByCurrencyIDParams{
CurrencyID: args.Currency,
Expand Down Expand Up @@ -387,9 +387,9 @@ func (o *Service) CreateSpotOrder(ctx context.Context, from string, to string, s

switch spotOrderRequest.Side {
case bitgetmodels.OrderSideSell:
spotOrderRequest.Size = maxAmount.RoundDown(int32(rule.AmountPrecision)).String()
spotOrderRequest.Size = maxAmount.RoundDown(int32(rule.AmountPrecision)).String() //nolint:gosec
case bitgetmodels.OrderSideBuy:
spotOrderRequest.Size = maxAmount.RoundDown(int32(rule.ValuePrecision)).String()
spotOrderRequest.Size = maxAmount.RoundDown(int32(rule.ValuePrecision)).String() //nolint:gosec
}

placedOrder, err := o.exClient.Spot().Trade().PlaceOrder(ctx, spotOrderRequest)
Expand Down
3 changes: 1 addition & 2 deletions internal/service/exchange/bybit/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func (o *Service) GetOrderRule(ctx context.Context, ticker string) (*models.Orde

// Calculate minimum amount based on minimum notional value and current price
// minOrderValue is in quote currency, divide by price to get base currency amount
calculatedMinAmount := minOrderValue.Div(currentPrice).RoundUp(int32(basePrecision.IntPart()))
calculatedMinAmount := minOrderValue.Div(currentPrice).RoundUp(int32(basePrecision.IntPart())) //nolint:gosec

// Use the larger of the calculated minimum or the exchange's minimum quantity
if calculatedMinAmount.GreaterThan(minOrderAmount) {
Expand Down Expand Up @@ -1011,7 +1011,6 @@ func (o *Service) CreateWithdrawalOrder(ctx context.Context, args *models.Create
FromAccountType: bybitmodels.AccountTypeUnified,
ToAccountType: bybitmodels.AccountTypeFund,
})

if err != nil {
return nil, err
}
Expand Down
Loading
Loading