Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring: deprecate Feeder API from v0.13.2 #37

Merged
merged 2 commits into from
Sep 4, 2024
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
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INDEXER_BRIDGED_TOKENS_FILE=mainnet.json # full list of files you can find in repo ./build/bridged_tokens/
INDEXER_CLASS_INTERFACES_DIR=./interfaces/ # REQUIRED
INDEXER_DATASOURCE=sequencer # REQUIRED: one of 'node' or 'sequencer'
INDEXER_DATASOURCE=node # REQUIRED: 'node' is only one supported value
HASURA_HOST=hasura
HASURA_POSTGRES_HOST=db
LOG_LEVEL=info
Expand All @@ -9,6 +9,5 @@ POSTGRES_HOST=db
POSTGRES_DB=starknet
POSTGRES_PASSWORD=<TYPE_SOMETHING_STRONG> # REQUIRED
STARKNET_NODE_URL=<URL_HERE> # REQUIRED if INDEXER_DATASOURCE=node
STARKNET_SEQUENCER_FEEDER_GATEWAY=<URL_HERE> # REQUIRED if INDEXER_DATASOURCE=sequencer
NODE_APIKEY=<API_KEY_FROM_NODE_PROVIDER> # REQUIRED if your node provider has api key. It's api key.
NODE_HEADER_APIKEY=<HEADER_NAME> # REQUIRED if your node provider has api key. It's header name.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Starknet indexer
This is an indexing layer for Starknet written in Golang that operates on top of the (Feeder) Gateway API and stores data in a Postgres database.
This is an indexing layer for Starknet written in Golang that operates on top of the Node API and stores data in a Postgres database.

It can be used in multiple ways and for various purposes:
- As a base component for the [DipDup Vertical](https://dipdup.io) — GraphQL federation providing a wide range of APIs for accessing both on-chain and off-chain data/metadata
Expand Down
3 changes: 0 additions & 3 deletions build/dipdup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ datasources:
node:
url: ${STARKNET_NODE_URL}
rps: ${STARKNET_NODE_RPS:-5}
sequencer:
url: ${STARKNET_SEQUENCER_FEEDER_GATEWAY:-https://alpha-mainnet.starknet.io/feeder_gateway}
rps: ${STARKNET_SEQUENCER_RPS:-3}

database:
kind: postgres
Expand Down
7 changes: 3 additions & 4 deletions pkg/indexer/receiver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"time"

"github.com/dipdup-io/starknet-go-api/pkg/data"
starknetData "github.com/dipdup-io/starknet-go-api/pkg/data"
starknet "github.com/dipdup-io/starknet-go-api/pkg/sequencer"
"github.com/dipdup-io/starknet-indexer/internal/storage"
Expand Down Expand Up @@ -36,9 +35,9 @@ type Block struct {

type Transaction struct {
Type string
Version data.Felt
Hash data.Felt
ActualFee data.Felt
Version starknetData.Felt
Hash starknetData.Felt
ActualFee starknetData.Felt

Body any
}
5 changes: 2 additions & 3 deletions pkg/indexer/receiver/feeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"time"

"github.com/dipdup-io/starknet-go-api/pkg/data"
starknetData "github.com/dipdup-io/starknet-go-api/pkg/data"
"github.com/dipdup-io/starknet-go-api/pkg/encoding"
starknet "github.com/dipdup-io/starknet-go-api/pkg/sequencer"
Expand Down Expand Up @@ -36,8 +35,8 @@ func (f *Feeder) GetBlock(ctx context.Context, blockId starknetData.BlockID) (bl

block.Height = response.BlockNumber
block.Time = time.Unix(response.Timestamp, 0).UTC()
block.Hash = data.Felt(response.BlockHash).Bytes()
block.ParentHash = data.Felt(response.ParentHash).Bytes()
block.Hash = starknetData.Felt(response.BlockHash).Bytes()
block.ParentHash = starknetData.Felt(response.ParentHash).Bytes()
block.NewRoot = encoding.MustDecodeHex(response.NewRoot)
block.SequencerAddress = encoding.MustDecodeHex(response.SequencerAddress)
block.Version = response.StarknetVersion
Expand Down
5 changes: 2 additions & 3 deletions pkg/indexer/receiver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"time"

"github.com/dipdup-io/starknet-go-api/pkg/data"
starknetData "github.com/dipdup-io/starknet-go-api/pkg/data"
"github.com/dipdup-io/starknet-go-api/pkg/encoding"
starknet "github.com/dipdup-io/starknet-go-api/pkg/rpc"
Expand Down Expand Up @@ -39,8 +38,8 @@ func (n *Node) GetBlock(ctx context.Context, blockId starknetData.BlockID) (bloc

block.Height = response.Result.BlockNumber
block.Time = time.Unix(response.Result.Timestamp, 0).UTC()
block.Hash = data.Felt(response.Result.BlockHash).Bytes()
block.ParentHash = data.Felt(response.Result.ParentHash).Bytes()
block.Hash = starknetData.Felt(response.Result.BlockHash).Bytes()
block.ParentHash = starknetData.Felt(response.Result.ParentHash).Bytes()
block.NewRoot = encoding.MustDecodeHex(response.Result.NewRoot)
block.SequencerAddress = encoding.MustDecodeHex(response.Result.SequencerAddress)
block.Version = response.Result.Version
Expand Down
4 changes: 2 additions & 2 deletions pkg/indexer/receiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func NewReceiver(cfg config.Config, ds map[string]ddConfig.DataSource) (*Receive
switch cfg.Datasource {
case "node":
api = NewNode(dsCfg)
case "sequencer":
api = NewFeeder(dsCfg)
default:
return nil, errors.Errorf("usupported datasource type: %s", cfg.Datasource)
}

receiver := &Receiver{
Expand Down
Loading