Skip to content

Commit

Permalink
Add tx hash to rollup action
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Mar 12, 2024
1 parent a1ce82e commit acad7b6
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.2'
go-version: '1.22.1'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
go-version: 1.22.x
- uses: actions/cache@v3
with:
path: |
Expand Down
2 changes: 1 addition & 1 deletion build/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------------------
# The first stage container, for building the application
# ---------------------------------------------------------------------
FROM golang:1.21.2-alpine as builder
FROM golang:1.22.1-alpine as builder

ENV CGO_ENABLED=0
ENV GO111MODULE=on
Expand Down
2 changes: 1 addition & 1 deletion build/indexer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------------------
# The first stage container, for building the application
# ---------------------------------------------------------------------
FROM golang:1.21.2-alpine as builder
FROM golang:1.22.1-alpine as builder

ENV CGO_ENABLED=0
ENV GO111MODULE=on
Expand Down
10 changes: 0 additions & 10 deletions cmd/api/docs/docs.go

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

10 changes: 0 additions & 10 deletions cmd/api/docs/swagger.json

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

8 changes: 0 additions & 8 deletions cmd/api/docs/swagger.yaml

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

4 changes: 0 additions & 4 deletions cmd/api/handler/responses/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type Action struct {
Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"`
Position int64 `example:"1" format:"int64" json:"position" swaggertype:"integer"`
Type types.ActionType `example:"sequence" format:"string" json:"type" swaggertype:"string"`
TxId uint64 `example:"10" format:"int64" json:"tx_id" swaggertype:"integer"`
TxHash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"binary" json:"tx_hash,omitempty" swaggertype:"string"`

Data map[string]any `json:"data"`
Expand All @@ -31,7 +30,6 @@ func NewAction(action storage.Action) Action {
Time: action.Time,
Position: action.Position,
Type: action.Type,
TxId: action.TxId,
Data: action.Data,
}
}
Expand All @@ -43,7 +41,6 @@ func NewActionWithTx(action storage.ActionWithTx) Action {
Time: action.Time,
Position: action.Position,
Type: action.Type,
TxId: action.TxId,
Data: action.Data,
}

Expand All @@ -59,7 +56,6 @@ func NewAddressAction(action storage.AddressAction) Action {
Id: action.ActionId,
Height: action.Height,
Time: action.Time,
TxId: action.TxId,
Type: action.ActionType,
}

Expand Down
10 changes: 9 additions & 1 deletion cmd/api/handler/responses/rollup_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

package responses

import "github.com/celenium-io/astria-indexer/internal/storage"
import (
"encoding/hex"

"github.com/celenium-io/astria-indexer/internal/storage"
)

type RollupAction struct {
Action
Expand All @@ -16,6 +20,10 @@ func NewRollupAction(action storage.RollupAction) RollupAction {
Action: NewAction(*action.Action),
}

if action.Tx != nil {
result.TxHash = hex.EncodeToString(action.Tx.Hash)
}

if action.Rollup != nil {
r := NewRollup(action.Rollup)
result.Rollup = &r
Expand Down
1 change: 0 additions & 1 deletion cmd/api/handler/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ func (s *TxTestSuite) TestGetActions() {
s.Require().EqualValues(100, actions[0].Height)
s.Require().EqualValues(1, actions[0].Position)
s.Require().Equal(testTime, actions[0].Time)
s.Require().EqualValues(1, actions[0].TxId)
s.Require().EqualValues(string(types.ActionTypeSequence), actions[0].Type)
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/celenium-io/astria-indexer

go 1.21.2
go 1.22.1

require (
buf.build/gen/go/astria/astria/protocolbuffers/go v1.32.0-20240102174805-d9fa6929f260.1
Expand All @@ -15,7 +15,7 @@ require (
github.com/go-testfixtures/testfixtures/v3 v3.9.0
github.com/goccy/go-json v0.10.2
github.com/gorilla/websocket v1.5.0
github.com/grafana/pyroscope-go v1.0.4
github.com/grafana/pyroscope-go v1.1.1
github.com/json-iterator/go v1.1.12
github.com/labstack/echo-contrib v0.15.0
github.com/labstack/echo/v4 v4.11.4
Expand Down Expand Up @@ -81,7 +81,7 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.4 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
Expand Down
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grafana/pyroscope-go v1.0.4 h1:oyQX0BOkL+iARXzHuCdIF5TQ7/sRSel1YFViMHC7Bm0=
github.com/grafana/pyroscope-go v1.0.4/go.mod h1:0d7ftwSMBV/Awm7CCiYmHQEG8Y44Ma3YSjt+nWcWztY=
github.com/grafana/pyroscope-go/godeltaprof v0.1.4 h1:mDsJ3ngul7UfrHibGQpV66PbZ3q1T8glz/tK3bQKKEk=
github.com/grafana/pyroscope-go/godeltaprof v0.1.4/go.mod h1:1HSPtjU8vLG0jE9JrTdzjgFqdJ/VgN7fvxBNq3luJko=
github.com/grafana/pyroscope-go v1.1.1 h1:PQoUU9oWtO3ve/fgIiklYuGilvsm8qaGhlY4Vw6MAcQ=
github.com/grafana/pyroscope-go v1.1.1/go.mod h1:Mw26jU7jsL/KStNSGGuuVYdUq7Qghem5P8aXYXSXG88=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 h1:nEdZ8louGAplSvIJi1HVp7kWvFvdiiYg3COLlTwJiFo=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down Expand Up @@ -221,6 +221,7 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down
4 changes: 2 additions & 2 deletions internal/storage/postgres/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ func (s Storage) createScripts(ctx context.Context, conn *database.Bun, subFolde
if len(query) == 0 {
continue
}
if _, err := s.Connection().DB().NewRaw(string(query)).Exec(ctx); err != nil {
if _, err := conn.DB().NewRaw(string(query)).Exec(ctx); err != nil {
return errors.Wrapf(err, "creating %s '%s'", subFolder, files[i].Name())
}
}
} else {
if _, err := s.Connection().DB().NewRaw(string(raw)).Exec(ctx); err != nil {
if _, err := conn.DB().NewRaw(string(raw)).Exec(ctx); err != nil {
return errors.Wrapf(err, "creating %s '%s'", subFolder, files[i].Name())
}
}
Expand Down

0 comments on commit acad7b6

Please sign in to comment.