Skip to content

Commit

Permalink
Upgrade libraries and change ORM
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Aug 19, 2023
1 parent 833d7d5 commit e83a4c4
Show file tree
Hide file tree
Showing 22 changed files with 585 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: install Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
go-version: 1.20.x
- name: checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
Expand Down
13 changes: 4 additions & 9 deletions cmd/starknet-id/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/dipdup-io/starknet-id/internal/storage"
"github.com/dipdup-io/starknet-id/internal/storage/postgres"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/go-pg/pg/v10"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/uptrace/bun"
)

// Action
Expand Down Expand Up @@ -49,7 +49,7 @@ func NewStore(pg postgres.Storage) Store {
// Save -
func (s Store) Save(ctx context.Context, blockCtx *BlockContext) error {
since := time.Now()
tx, err := s.pg.Transactable.BeginTransaction(ctx)
tx, err := postgres.BeginTransaction(ctx, s.pg.Transactable)
if err != nil {
return err
}
Expand All @@ -73,12 +73,7 @@ func (s Store) Save(ctx context.Context, blockCtx *BlockContext) error {
}
}

if _, err := tx.Exec(ctx, `INSERT INTO state (name, last_height, last_time)
VALUES (?,?,?)
ON CONFLICT (name)
DO
UPDATE SET last_height = excluded.last_height, last_time = excluded.last_time
`, blockCtx.state.Name, blockCtx.state.LastHeight, blockCtx.state.LastTime); err != nil {
if err := tx.SaveState(ctx, blockCtx.state); err != nil {
return tx.HandleError(ctx, err)
}

Expand Down Expand Up @@ -140,7 +135,7 @@ func (s Store) saveStarknetId(ctx context.Context, tx sdk.Transaction, blockCtx
}
}
if len(burned) > 0 {
if _, err := tx.Exec(ctx, `DELETE FROM starknet_id WHERE starknet_id IN (?)`, pg.In(burned)); err != nil {
if _, err := tx.Exec(ctx, `DELETE FROM starknet_id WHERE starknet_id IN (?)`, bun.In(burned)); err != nil {
return errors.Wrap(err, "saving burned starknet id")
}
}
Expand Down
109 changes: 80 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,64 +1,115 @@
module github.com/dipdup-io/starknet-id

go 1.19
go 1.20

require (
github.com/dipdup-io/starknet-go-api v0.0.0-20230601120914-cb5965133047
github.com/dipdup-io/starknet-indexer v0.0.0-20230608111641-c52d65847045
github.com/dipdup-net/go-lib v0.2.38
github.com/dipdup-net/indexer-sdk v0.0.0-20230607120505-500072a4250b
github.com/go-pg/pg/v10 v10.11.0
github.com/dipdup-io/starknet-go-api v0.0.0-20230818110656-b2736a55da83
github.com/dipdup-io/starknet-indexer v0.0.0-20230819141739-8eb8f315fb6b
github.com/dipdup-net/go-lib v0.3.0
github.com/dipdup-net/indexer-sdk v0.0.0-20230819120445-392cbc4cfb65
github.com/go-testfixtures/testfixtures/v3 v3.9.0
github.com/goccy/go-json v0.10.2
github.com/karlseguin/ccache/v2 v2.0.8
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.29.1
github.com/rs/zerolog v1.30.0
github.com/shopspring/decimal v1.3.1
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
github.com/uptrace/bun v1.1.14
golang.org/x/time v0.3.0
)

require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/dipdup-net/workerpool v0.0.2 // indirect
github.com/ethereum/go-ethereum v1.11.4 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/ClickHouse/ch-go v0.58.0 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.13.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/containerd v1.7.3 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dipdup-io/workerpool v0.0.3 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.5+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.6.1 // indirect
github.com/go-pg/pg/v10 v10.11.1 // indirect
github.com/go-pg/zerochecker v0.2.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/go-playground/validator/v10 v10.15.0 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0-rc.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.5 // 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
github.com/jackc/pgx/v5 v5.3.1 // indirect
github.com/jackc/pgx/v5 v5.4.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.2 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
github.com/opencontainers/runc v1.1.9 // indirect
github.com/paulmach/orb v0.10.0 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/testcontainers/testcontainers-go v0.22.0 // indirect
github.com/testcontainers/testcontainers-go/modules/postgres v0.22.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/uptrace/bun/dialect/pgdialect v1.1.14 // indirect
github.com/vmihailenco/bufpool v0.1.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
github.com/wealdtech/go-merkletree v1.0.1-0.20230205101955-ec7a95ea11ca // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/tools v0.12.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.4.7 // indirect
gorm.io/driver/postgres v1.5.0 // indirect
gorm.io/driver/sqlite v1.4.4 // indirect
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11 // indirect
gorm.io/driver/mysql v1.5.1 // indirect
gorm.io/driver/postgres v1.5.2 // indirect
gorm.io/driver/sqlite v1.5.2 // indirect
gorm.io/gorm v1.25.3 // indirect
mellium.im/sasl v0.3.1 // indirect
)
Loading

0 comments on commit e83a4c4

Please sign in to comment.