Skip to content
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "CI"

on:
push:
branches:
- main
pull_request:

env:
GO_VERSION: 1.24.0

jobs:
test-go:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Check go mod
run: |
go mod tidy
git diff --exit-code go.mod

- name: Build examples
run: go install ./...

- name: Lint
uses: golangci/golangci-lint-action@v7.0.0
with:
version: latest
skip-build-cache: true
skip-pkg-cache: true
158 changes: 158 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
version: "2"
run:
issues-exit-code: 1
tests: true
output:
formats:
text:
path: stdout
print-linter-name: true
print-issued-lines: true
linters:
enable:
- bidichk
- bodyclose
- copyloopvar
- dogsled
- durationcheck
- err113
- gocritic
- godot
- goprintffuncname
- importas
- makezero
- misspell
- nakedret
- nilerr
- noctx
- revive
- unconvert
- usetesting
- wastedassign
disable:
- asciicheck
- containedctx
- contextcheck
- cyclop
- decorder
- depguard
- dupl
- errchkjson
- errname
- exhaustive
- forbidigo
- funlen
- gocognit
- goconst
- gocyclo
- godox
- goheader
- gomoddirectives
- gomodguard
- gosec
- grouper
- ireturn
- lll
- maintidx
- nlreturn
- nolintlint
- paralleltest
- predeclared
- promlinter
- rowserrcheck
- sqlclosecheck
- staticcheck
- tagliatelle
- testpackage
- thelper
- tparallel
- unused
- varnamelen
- wrapcheck
- wsl
settings:
dogsled:
max-blank-identifiers: 3
dupl:
threshold: 150
errcheck:
check-type-assertions: false
check-blank: false
goconst:
min-len: 3
min-occurrences: 3
gocritic:
disabled-checks:
- ifElseChain
gocyclo:
min-complexity: 10
lll:
line-length: 140
tab-width: 1
misspell:
ignore-rules:
- sucess
nakedret:
max-func-lines: 30
prealloc:
simple: true
range-loops: true
for-loops: false
exclusions:
generated: lax
rules:
- linters:
- err113
text: do not define dynamic errors
- linters:
- revive
text: if-return
- linters:
- revive
text: var-naming
- linters:
- revive
text: error-return
- linters:
- revive
text: package-comments
- linters:
- revive
text: superfluous-else
- linters:
- revive
text: indent-error-flow
- linters:
- revive
text: unused-parameter
- linters:
- revive
text: empty-block
- linters:
- revive
text: redefines-builtin-id
paths:
- .*\.pb\.go$
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
new: false
formatters:
enable:
- gofmt
settings:
gofmt:
simplify: true
goimports:
local-prefixes:
- github.com/BoostyLabs/hotpot-sdk-go
exclusions:
generated: lax
paths:
- .*\.pb\.go$
- third_party$
- builtin$
- examples$
2 changes: 2 additions & 0 deletions client/intents.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type CreateIntentResponse struct {
types.ApprovalToSign
}

// UnmarshalJSON implements json.Unmarshaler interface.
func (resp *CreateIntentResponse) UnmarshalJSON(data []byte) error {
type createIntentResponseCodec struct {
ID uuid.UUID `json:"intent_id"`
Expand Down Expand Up @@ -63,6 +64,7 @@ func (resp *CreateIntentResponse) UnmarshalJSON(data []byte) error {
}
}

// CreateIntent creates a new intent using the provided request data and returns the created intent details or an error.
func (c *Client) CreateIntent(ctx context.Context, req CreateIntentRequest) (CreateIntentResponse, error) {
var resp = CreateIntentResponse{}
var endpoint = c.buildURL("intents")
Expand Down
1 change: 1 addition & 0 deletions client/quotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type GetTheBestQuoteRequest struct {
AffiliateFees map[string]RequestedFee `json:"affiliate_fees"`
}

// RequestedFee represents the fee requested for the swap.
type RequestedFee struct {
FeeBps *types.Int `json:"fee_bps"`
NetworkID uint64 `json:"network_id"`
Expand Down
2 changes: 1 addition & 1 deletion crypto/evm/permit2.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func GetPermit2Signature(digest []byte, sign func([]byte) ([]byte, error)) (sig
}

// Normalize to 27/28 for EVM contracts if needed
sig[64] = sig[64] + 27
sig[64] += 27

return sig, nil
}
1 change: 1 addition & 0 deletions types/approvals.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func NewCosignIntentApproval(transaction string, userAddress string) IntentAppro
}
}

// MarshalJSON implements json.Marshaler interface.
func (a *IntentApproval) MarshalJSON() ([]byte, error) {
var v = addIntentApprovalRequestCodec{Type: string(a.approvalMechanism)}
switch {
Expand Down
2 changes: 2 additions & 0 deletions types/bigint.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewIntFromPercent(percent float64) (*Int, error) {
return NewInt(int64(math.Round(percent * PercentToBps))), nil
}

// MarshalJSON implements the json.Marshaler interface.
func (i *Int) MarshalJSON() ([]byte, error) {
buf := new(bytes.Buffer)
buf.WriteByte('"')
Expand All @@ -38,6 +39,7 @@ func (i *Int) MarshalJSON() ([]byte, error) {
return buf.Bytes(), nil
}

// UnmarshalJSON implements the json.Unmarshaler interface.
func (i *Int) UnmarshalJSON(b []byte) error {
b = bytes.Trim(b, `"`)
return i.Int.UnmarshalJSON(b)
Expand Down
1 change: 1 addition & 0 deletions types/networks.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package types

// Network represents the network entity data.
type Network struct {
ID int64 `json:"id"`
Name string `json:"name"`
Expand Down
1 change: 1 addition & 0 deletions types/quotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
DepositTypeDirect DepositType = "direct"
)

// EstimatedFee represents the estimated fee for a specific token.
type EstimatedFee struct {
FeeBps *Int `json:"fee_bps"`
NetworkID uint64 `json:"network_id"`
Expand Down
Loading