Skip to content

Commit

Permalink
[SDK] Add Transaction History (#288)
Browse files Browse the repository at this point in the history
* tx history

* fix

* fix

* pr review refactor

* pr review refactor

* fix

* pr review refactor

* exclude gosec G115 Integer Overflow Conversion

* ignore some gosec errs

* ignore some gosec errs

* ignore createdat in test assertion

* Fixes (#7)

* Fixes

* Fixes

* Update golang (#8)

* update gha golangci-lint version

* update gha golangci-lint version

* fix linting issues

* fix linting issues

* fix linting issues

* add linter timeout

---------

Co-authored-by: Pietralberto Mazza <[email protected]>
  • Loading branch information
sekulicd and altafan authored Sep 10, 2024
1 parent 4da76ec commit a8cf0ed
Show file tree
Hide file tree
Showing 22 changed files with 830 additions and 40 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ark.unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ jobs:
go-version: '>=1.22.6'
- uses: actions/checkout@v3
- name: check linting
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.54
version: v1.61
working-directory: ./server
args: --timeout 5m
- name: check code integrity
uses: securego/gosec@master
with:
args: "-severity high -quiet ./..."
args: "-severity high -quiet -exclude=G115 ./..."
- run: go get -v -t -d ./...
- name: unit testing
run: make test
Expand All @@ -71,14 +72,15 @@ jobs:
go-version: '>=1.22.6'
- uses: actions/checkout@v3
- name: check linting
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.54
version: v1.61
working-directory: ./pkg/client-sdk
args: --timeout 5m
- name: check code integrity
uses: securego/gosec@master
with:
args: "-severity high -quiet ./..."
args: "-severity high -quiet -exclude=G115 ./..."
- run: go get -v -t -d ./...
- name: unit testing
run: make test
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# First image used to build the sources
FROM golang:1.21.0 AS builder
FROM golang:1.23.1 AS builder

ARG VERSION
ARG TARGETOS
Expand All @@ -14,7 +14,7 @@ RUN cd server && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -l
RUN cd client && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.Version=${VERSION}'" -o ../bin/ark .

# Second image, running the arkd executable
FROM alpine:3.18
FROM alpine:3.20

RUN apk update && apk upgrade

Expand Down
2 changes: 1 addition & 1 deletion buf.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine3.18 as builder
FROM golang:1.23.1-alpine3.20 as builder

RUN apk add --no-cache git

Expand Down
2 changes: 1 addition & 1 deletion client/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ark-network/ark/client

go 1.22.6
go 1.23.1

replace github.com/ark-network/ark/common => ../common

Expand Down
1 change: 1 addition & 0 deletions client/utils/cypher.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (c *cypher) decrypt(encrypted, password []byte) ([]byte, error) {
return nil, err
}
nonce, text := data[:gcm.NonceSize()], data[gcm.NonceSize():]
// #nosec G407
plaintext, err := gcm.Open(nil, nonce, text, nil)
if err != nil {
return nil, fmt.Errorf("invalid password")
Expand Down
2 changes: 1 addition & 1 deletion common/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ark-network/ark/common

go 1.22.6
go 1.23.1

replace github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.3

Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.22.6
go 1.23.1

use (
./api-spec
Expand Down
1 change: 1 addition & 0 deletions pkg/client-sdk/ark_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ArkClient interface {
SendAsync(ctx context.Context, withExpiryCoinselect bool, receivers []Receiver) (string, error)
Claim(ctx context.Context) (string, error)
ListVtxos(ctx context.Context) ([]client.Vtxo, []client.Vtxo, error)
GetTransactionHistory(ctx context.Context) ([]Transaction, error)
}

type Receiver interface {
Expand Down
4 changes: 4 additions & 0 deletions pkg/client-sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,7 @@ func getWalletStore(storeType, datadir string) (walletstore.WalletStore, error)
return nil, fmt.Errorf("unknown wallet store type")
}
}

func getCreatedAtFromExpiry(roundLifetime int64, expiry time.Time) time.Time {
return expiry.Add(-time.Duration(roundLifetime) * time.Second)
}
Loading

0 comments on commit a8cf0ed

Please sign in to comment.