// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"net/http"
"github.com/celenium-io/astria-indexer/cmd/api/bus"
"github.com/celenium-io/astria-indexer/cmd/api/cache"
"github.com/celenium-io/astria-indexer/cmd/api/handler/websocket"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/grafana/pyroscope-go"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
"go.uber.org/fx"
)
type App struct {
e *echo.Echo
db *postgres.Storage
wsManager *websocket.Manager
dispatcher *bus.Dispatcher
constantCache *cache.ConstantsCache
endpointCache *cache.Cache
prscp *pyroscope.Profiler
constants storage.IConstant
}
func newApp(
lc fx.Lifecycle,
cfg *Config,
e *echo.Echo,
db *postgres.Storage,
wsManager *websocket.Manager,
dispatcher *bus.Dispatcher,
constantCache *cache.ConstantsCache,
endpointCache *cache.Cache,
prscp *pyroscope.Profiler,
constants storage.IConstant,
) *App {
app := &App{
e: e,
db: db,
wsManager: wsManager,
dispatcher: dispatcher,
constantCache: constantCache,
endpointCache: endpointCache,
prscp: prscp,
constants: constants,
}
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
dispatcher.Start(ctx)
wsManager.Start(ctx)
endpointCache.Start(ctx)
if err := constantCache.Start(ctx, app.constants); err != nil {
return errors.Wrap(err, "start constant cache")
}
if err := app.e.Start(cfg.ApiConfig.Bind); err != nil && errors.Is(err, http.ErrServerClosed) {
return errors.Wrap(err, "shutting down the server")
}
return nil
},
OnStop: func(ctx context.Context) error {
if app.wsManager != nil {
if err := app.wsManager.Close(); err != nil {
return errors.Wrap(err, "closing websocket manager")
}
}
if app.endpointCache != nil {
if err := app.endpointCache.Close(); err != nil {
return errors.Wrap(err, "closing cache")
}
}
if app.constantCache != nil {
if err := app.constantCache.Close(); err != nil {
return errors.Wrap(err, "closing constant cache")
}
}
if app.dispatcher != nil {
if err := app.dispatcher.Close(); err != nil {
return errors.Wrap(err, "closing bus dispatcher")
}
}
if err := app.e.Shutdown(ctx); err != nil {
return errors.Wrap(err, "closing server")
}
if app.prscp != nil {
if err := app.prscp.Stop(); err != nil {
return errors.Wrap(err, "closing profler")
}
}
if err := app.db.Close(); err != nil {
return errors.Wrap(err, "closing database")
}
return nil
},
})
return app
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package bus
import (
"context"
"encoding/json"
"strconv"
"sync"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-io/workerpool"
"github.com/lib/pq"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
type Dispatcher struct {
listener storage.Listener
blocks storage.IBlock
mx *sync.RWMutex
observers []*Observer
g workerpool.Group
}
func NewDispatcher(
factory storage.ListenerFactory,
blocks storage.IBlock,
) (*Dispatcher, error) {
if factory == nil {
return nil, errors.New("nil listener factory")
}
listener := factory.CreateListener()
return &Dispatcher{
listener: listener,
blocks: blocks,
observers: make([]*Observer, 0),
mx: new(sync.RWMutex),
g: workerpool.NewGroup(),
}, nil
}
func (d *Dispatcher) Observe(channels ...string) *Observer {
if observer := NewObserver(channels...); observer != nil {
d.mx.Lock()
d.observers = append(d.observers, observer)
d.mx.Unlock()
return observer
}
return nil
}
func (d *Dispatcher) Start(ctx context.Context) {
if err := d.listener.Subscribe(ctx, storage.ChannelHead, storage.ChannelBlock); err != nil {
log.Err(err).Msg("subscribe on postgres notifications")
return
}
d.g.GoCtx(ctx, d.listen)
}
func (d *Dispatcher) Close() error {
d.g.Wait()
d.mx.Lock()
for i := range d.observers {
if err := d.observers[i].Close(); err != nil {
return err
}
}
d.mx.Unlock()
return nil
}
func (d *Dispatcher) listen(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
case notification, ok := <-d.listener.Listen():
if !ok {
return
}
if notification == nil {
log.Warn().Msg("nil notification")
continue
}
if err := d.handleNotification(ctx, notification); err != nil {
log.Err(err).Str("channel", notification.Channel).Msg("handle notification")
}
}
}
}
func (d *Dispatcher) handleNotification(ctx context.Context, notification *pq.Notification) error {
switch notification.Channel {
case storage.ChannelBlock:
id, err := strconv.ParseUint(notification.Extra, 10, 64)
if err != nil {
return errors.Wrapf(err, "parse block id: %s", notification.Extra)
}
return d.handleBlock(ctx, id)
case storage.ChannelHead:
return d.handleHead(notification.Extra)
case storage.ChannelConstant:
return d.handleConstant(notification.Extra)
default:
return errors.Errorf("unknown channel name: %s", notification.Channel)
}
}
func (d *Dispatcher) handleBlock(ctx context.Context, id uint64) error {
block, err := d.blocks.ByIdWithRelations(ctx, id)
if err != nil {
return err
}
d.mx.RLock()
for i := range d.observers {
d.observers[i].notifyBlocks(&block)
}
d.mx.RUnlock()
return nil
}
func (d *Dispatcher) handleHead(msg string) error {
var state storage.State
if err := json.Unmarshal([]byte(msg), &state); err != nil {
return err
}
d.mx.RLock()
for i := range d.observers {
d.observers[i].notifyState(&state)
}
d.mx.RUnlock()
return nil
}
func (d *Dispatcher) handleConstant(msg string) error {
var c storage.Constant
if err := json.Unmarshal([]byte(msg), &c); err != nil {
return err
}
d.mx.RLock()
for i := range d.observers {
d.observers[i].notifyConstants(&c)
}
d.mx.RUnlock()
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package bus
import (
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-io/workerpool"
)
type Observer struct {
blocks chan *storage.Block
head chan *storage.State
constants chan *storage.Constant
listenHead bool
listenBlocks bool
listenConstants bool
g workerpool.Group
}
func NewObserver(channels ...string) *Observer {
if len(channels) == 0 {
return nil
}
observer := &Observer{
blocks: make(chan *storage.Block, 1024),
head: make(chan *storage.State, 1024),
constants: make(chan *storage.Constant, 1024),
g: workerpool.NewGroup(),
}
for i := range channels {
switch channels[i] {
case storage.ChannelBlock:
observer.listenBlocks = true
case storage.ChannelHead:
observer.listenHead = true
case storage.ChannelConstant:
observer.listenConstants = true
}
}
return observer
}
func (observer Observer) Close() error {
observer.g.Wait()
close(observer.blocks)
close(observer.head)
close(observer.constants)
return nil
}
func (observer Observer) notifyBlocks(block *storage.Block) {
if observer.listenBlocks {
observer.blocks <- block
}
}
func (observer Observer) notifyState(state *storage.State) {
if observer.listenHead {
observer.head <- state
}
}
func (observer Observer) notifyConstants(constant *storage.Constant) {
if observer.listenConstants {
observer.constants <- constant
}
}
func (observer Observer) Blocks() <-chan *storage.Block {
return observer.blocks
}
func (observer Observer) Head() <-chan *storage.State {
return observer.head
}
func (observer Observer) Constants() <-chan *storage.Constant {
return observer.constants
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package cache
import (
"context"
"net/http"
"sync"
"github.com/celenium-io/astria-indexer/cmd/api/bus"
"github.com/dipdup-io/workerpool"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pkg/errors"
)
type Cache struct {
maxEntitiesCount int
observer *bus.Observer
m map[string][]byte
queue []string
mx *sync.RWMutex
g workerpool.Group
}
type Config struct {
MaxEntitiesCount int
}
func NewCache(cfg Config, observer *bus.Observer) *Cache {
return &Cache{
maxEntitiesCount: cfg.MaxEntitiesCount,
observer: observer,
m: make(map[string][]byte),
queue: make([]string, cfg.MaxEntitiesCount),
mx: new(sync.RWMutex),
g: workerpool.NewGroup(),
}
}
func (c *Cache) Start(ctx context.Context) {
c.g.GoCtx(ctx, c.listen)
}
func (c *Cache) listen(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
case <-c.observer.Head():
c.Clear()
}
}
}
func (c *Cache) Close() error {
c.g.Wait()
return nil
}
func (c *Cache) Get(key string) ([]byte, bool) {
c.mx.RLock()
data, ok := c.m[key]
c.mx.RUnlock()
return data, ok
}
func (c *Cache) Set(key string, data []byte) {
c.mx.Lock()
queueIdx := len(c.m)
if _, ok := c.m[key]; ok {
c.m[key] = data
} else {
c.m[key] = data
if queueIdx == c.maxEntitiesCount {
keyForRemove := c.queue[queueIdx-1]
c.queue = append([]string{key}, c.queue[:queueIdx-1]...)
delete(c.m, keyForRemove)
} else {
c.queue[queueIdx] = key
}
}
c.mx.Unlock()
}
func (c *Cache) Clear() {
c.mx.Lock()
for key := range c.m {
delete(c.m, key)
}
c.queue = make([]string, c.maxEntitiesCount)
c.mx.Unlock()
}
type CacheMiddleware struct {
cache *Cache
skipper middleware.Skipper
}
func Middleware(cache *Cache, skipper middleware.Skipper) echo.MiddlewareFunc {
mdlwr := CacheMiddleware{
cache: cache,
skipper: skipper,
}
return mdlwr.Handler
}
func (m *CacheMiddleware) Handler(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
if m.skipper != nil {
if m.skipper(c) {
return next(c)
}
}
path := c.Request().URL.String()
if data, ok := m.cache.Get(path); ok {
entry := new(CacheEntry)
if err := entry.Decode(data); err != nil {
return err
}
return entry.Replay(c.Response())
}
recorder := NewResponseRecorder(c.Response().Writer)
c.Response().Writer = recorder
if err := next(c); err != nil {
return err
}
return m.cacheResult(path, recorder)
}
}
func (m *CacheMiddleware) cacheResult(key string, r *ResponseRecorder) error {
result := r.Result()
if !m.isStatusCacheable(result) {
return nil
}
data, err := result.Encode()
if err != nil {
return errors.Wrap(err, "unable to read recorded response")
}
m.cache.Set(key, data)
return nil
}
func (m *CacheMiddleware) isStatusCacheable(e *CacheEntry) bool {
return e.StatusCode == http.StatusOK || e.StatusCode == http.StatusNoContent
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package cache
import (
"context"
"sync"
"github.com/celenium-io/astria-indexer/cmd/api/bus"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
)
type ConstantsCache struct {
data map[string]map[string]string
observer *bus.Observer
wg *sync.WaitGroup
mx *sync.RWMutex
}
func NewConstantsCache(observer *bus.Observer) *ConstantsCache {
return &ConstantsCache{
data: make(map[string]map[string]string),
observer: observer,
wg: new(sync.WaitGroup),
mx: new(sync.RWMutex),
}
}
func (c *ConstantsCache) Start(ctx context.Context, repo storage.IConstant) error {
constants, err := repo.All(ctx)
if err != nil {
return err
}
for i := range constants {
c.addConstant(&constants[i])
}
c.wg.Add(1)
go c.listen(ctx)
return nil
}
func (c *ConstantsCache) listen(ctx context.Context) {
defer c.wg.Done()
for {
select {
case <-ctx.Done():
return
case constant := <-c.observer.Constants():
c.addConstant(constant)
}
}
}
func (c *ConstantsCache) addConstant(constant *storage.Constant) {
c.mx.Lock()
{
module := string(constant.Module)
if _, ok := c.data[module]; !ok {
c.data[module] = make(map[string]string)
}
c.data[module][constant.Name] = constant.Value
}
c.mx.Unlock()
}
func (c *ConstantsCache) Get(module types.ModuleName, name string) (string, bool) {
c.mx.RLock()
defer c.mx.RUnlock()
if m, ok := c.data[string(module)]; ok {
val, ok := m[name]
return val, ok
}
return "", false
}
func (c *ConstantsCache) Close() error {
c.wg.Wait()
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package cache
import (
"bytes"
"encoding/gob"
"net/http"
)
type ResponseRecorder struct {
http.ResponseWriter
status int
body bytes.Buffer
headers http.Header
headerCopied bool
}
func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder {
return &ResponseRecorder{
ResponseWriter: w,
headers: make(http.Header),
}
}
func (w *ResponseRecorder) Write(b []byte) (int, error) {
w.copyHeaders()
i, err := w.ResponseWriter.Write(b)
if err != nil {
return i, err
}
return w.body.Write(b[:i])
}
func (r *ResponseRecorder) copyHeaders() {
if r.headerCopied {
return
}
r.headerCopied = true
copyHeaders(r.ResponseWriter.Header(), r.headers)
}
func (w *ResponseRecorder) WriteHeader(statusCode int) {
w.copyHeaders()
w.status = statusCode
w.ResponseWriter.WriteHeader(statusCode)
}
func (r *ResponseRecorder) Result() *CacheEntry {
r.copyHeaders()
return &CacheEntry{
Header: r.headers,
StatusCode: r.status,
Body: r.body.Bytes(),
}
}
func copyHeaders(src, dst http.Header) {
for k, v := range src {
for _, val := range v {
dst.Set(k, val)
}
}
}
type CacheEntry struct {
Header http.Header
StatusCode int
Body []byte
}
func (c *CacheEntry) Encode() ([]byte, error) {
var buf bytes.Buffer
if err := gob.NewEncoder(&buf).Encode(c); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (c *CacheEntry) Decode(b []byte) error {
dec := gob.NewDecoder(bytes.NewReader(b))
return dec.Decode(c)
}
func (c *CacheEntry) Replay(w http.ResponseWriter) error {
copyHeaders(c.Header, w.Header())
if c.StatusCode != 0 {
w.WriteHeader(c.StatusCode)
}
if len(c.Body) == 0 {
return nil
}
_, err := w.Write(c.Body)
return err
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"github.com/celenium-io/astria-indexer/internal/profiler"
indexerConfig "github.com/celenium-io/astria-indexer/pkg/indexer/config"
"github.com/dipdup-net/go-lib/config"
)
type Config struct {
*config.Config `yaml:",inline"`
LogLevel string `validate:"omitempty,oneof=debug trace info warn error fatal panic" yaml:"log_level"`
ApiConfig ApiConfig `validate:"required" yaml:"api"`
Profiler *profiler.Config `validate:"omitempty" yaml:"profiler"`
Indexer indexerConfig.Indexer `validate:"required" yaml:"indexer"`
Environment string `validate:"omitempty,oneof=development production" yaml:"environment"`
}
type ApiConfig struct {
Bind string `validate:"required,hostname_port" yaml:"bind"`
RateLimit float64 `validate:"omitempty,min=0" yaml:"rate_limit"`
Prometheus bool `validate:"omitempty" yaml:"prometheus"`
RequestTimeout int `validate:"omitempty,min=1" yaml:"request_timeout"`
BlobReceiver string `validate:"required" yaml:"blob_receiver"`
SentryDsn string `validate:"omitempty" yaml:"sentry_dsn"`
Websocket bool `validate:"omitempty" yaml:"websocket"`
}
func indexerName(cfg *Config) string {
return cfg.Indexer.Name
}
func databaseConfig(cfg *Config) config.Database {
return cfg.Database
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/app": {
"get": {
"description": "List applications info",
"produces": [
"application/json"
],
"tags": [
"applications"
],
"summary": "List applications info",
"operationId": "list-applications",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order. Default: desc",
"name": "sort",
"in": "query"
},
{
"enum": [
"time",
"actions_count",
"size"
],
"type": "string",
"description": "Sort field. Default: size",
"name": "sort_by",
"in": "query"
},
{
"type": "string",
"description": "Comma-separated application category list",
"name": "category",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.AppWithStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/app/{slug}": {
"get": {
"description": "Get application info",
"produces": [
"application/json"
],
"tags": [
"applications"
],
"summary": "Get application info",
"operationId": "get-application",
"parameters": [
{
"type": "string",
"description": "Slug",
"name": "slug",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.AppWithStats"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address": {
"get": {
"description": "List address info",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "List address info",
"operationId": "list-address",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
},
{
"type": "string",
"description": "Required balance asset",
"name": "asset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Address"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address/count": {
"get": {
"description": "Get count of addresses in network",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "Get count of addresses in network",
"operationId": "get-address-count",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "integer"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address/{hash}": {
"get": {
"description": "Get address info",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "Get address info",
"operationId": "get-address",
"parameters": [
{
"maxLength": 48,
"minLength": 48,
"type": "string",
"description": "Hash",
"name": "hash",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Address"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address/{hash}/actions": {
"get": {
"description": "Get address actions",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "Get address actions",
"operationId": "address-actions",
"parameters": [
{
"maxLength": 48,
"minLength": 48,
"type": "string",
"description": "Hash",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"minimum": 1,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
},
{
"enum": [
"transfer",
"rollup_data_submission",
"validator_update",
"sudo_address_change",
"ibc_relay",
"ics20_withdrawal",
"ibc_relayer_change",
"fee_asset_change",
"init_bridge_account",
"bridge_lock",
"bridge_unlock",
"bridge_sudo_change_action",
"fee_change",
"ibc_sudo_change_action",
"bridge_transfer",
"recover_ibc_client",
"currency_pairs_change",
"markets_change"
],
"type": "string",
"description": "Comma-separated action types list",
"name": "action_types",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Action"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address/{hash}/deposits": {
"get": {
"description": "Get bridge deposits",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "Get bridge deposits",
"operationId": "get-address-deposits",
"parameters": [
{
"maxLength": 48,
"minLength": 48,
"type": "string",
"description": "Hash",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Deposit"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address/{hash}/fees": {
"get": {
"description": "Get address paid fees",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "Get address paid fees",
"operationId": "get-address-fees",
"parameters": [
{
"maxLength": 48,
"minLength": 48,
"type": "string",
"description": "Hash",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.FullFee"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address/{hash}/roles": {
"get": {
"description": "Get address roles in bridges",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "Get address roles in bridges",
"operationId": "address-roles",
"parameters": [
{
"maxLength": 48,
"minLength": 48,
"type": "string",
"description": "Hash",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Bridge"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address/{hash}/rollups": {
"get": {
"description": "Get rollups in which the address pushed something",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "Get rollups in which the address pushed something",
"operationId": "address-rollups",
"parameters": [
{
"maxLength": 48,
"minLength": 48,
"type": "string",
"description": "Hash",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"minimum": 1,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Rollup"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/address/{hash}/txs": {
"get": {
"description": "Get address transactions",
"produces": [
"application/json"
],
"tags": [
"address"
],
"summary": "Get address transactions",
"operationId": "address-transactions",
"parameters": [
{
"maxLength": 48,
"minLength": 48,
"type": "string",
"description": "Hash",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"minimum": 1,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
},
{
"enum": [
"success",
"failed"
],
"type": "string",
"description": "Comma-separated status list",
"name": "status",
"in": "query"
},
{
"enum": [
"transfer",
"rollup_data_submission",
"validator_update",
"sudo_address_change",
"ibc_relay",
"ics20_withdrawal",
"ibc_relayer_change",
"fee_asset_change",
"init_bridge_account",
"bridge_lock",
"bridge_unlock",
"bridge_sudo_change_action",
"fee_change",
"ibc_sudo_change_action",
"bridge_transfer",
"recover_ibc_client",
"currency_pairs_change",
"markets_change"
],
"type": "string",
"description": "Comma-separated action types list",
"name": "action_types",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Time from in unix timestamp",
"name": "from",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Time to in unix timestamp",
"name": "to",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Block number",
"name": "height",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Tx"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/asset": {
"get": {
"description": "Get assets info",
"produces": [
"application/json"
],
"tags": [
"assets"
],
"summary": "Get assets info",
"operationId": "get-asset",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
},
{
"enum": [
"fee",
"fee_count",
"transferred",
"transfer_count",
"supply"
],
"type": "string",
"description": "Field using for sorting. Default: fee",
"name": "sort_by",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Asset"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/block": {
"get": {
"description": "List blocks info",
"produces": [
"application/json"
],
"tags": [
"block"
],
"summary": "List blocks info",
"operationId": "list-block",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
},
{
"type": "boolean",
"description": "Need join stats for block",
"name": "stats",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Block"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/block/count": {
"get": {
"description": "Get count of blocks in network",
"produces": [
"application/json"
],
"tags": [
"block"
],
"summary": "Get count of blocks in network",
"operationId": "get-block-count",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "integer"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/block/{height}": {
"get": {
"description": "Get block info",
"produces": [
"application/json"
],
"tags": [
"block"
],
"summary": "Get block info",
"operationId": "get-block",
"parameters": [
{
"minimum": 1,
"type": "integer",
"description": "Block height",
"name": "height",
"in": "path",
"required": true
},
{
"type": "boolean",
"description": "Need join stats for block",
"name": "stats",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Block"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/block/{height}/actions": {
"get": {
"description": "Get actions from begin and end of block",
"produces": [
"application/json"
],
"tags": [
"block"
],
"summary": "Get actions from begin and end of block",
"operationId": "get-block-actions",
"parameters": [
{
"minimum": 1,
"type": "integer",
"description": "Block height",
"name": "height",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Action"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/block/{height}/rollup_actions": {
"get": {
"description": "Get rollup actions in the block",
"produces": [
"application/json"
],
"tags": [
"block"
],
"summary": "Get rollup actions in the block",
"operationId": "get-block-rollup-actions",
"parameters": [
{
"minimum": 1,
"type": "integer",
"description": "Block height",
"name": "height",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.RollupAction"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/block/{height}/rollup_actions/count": {
"get": {
"description": "Get count of rollup actions",
"produces": [
"application/json"
],
"tags": [
"block"
],
"summary": "Get count of rollup actions",
"operationId": "get-block-rollup-actions-count",
"parameters": [
{
"minimum": 1,
"type": "integer",
"description": "Block height",
"name": "height",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "integer"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/block/{height}/stats": {
"get": {
"description": "Get block stats by height",
"produces": [
"application/json"
],
"tags": [
"block"
],
"summary": "Get block stats by height",
"operationId": "get-block-stats",
"parameters": [
{
"minimum": 1,
"type": "integer",
"description": "Block height",
"name": "height",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.BlockStats"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/block/{height}/txs": {
"get": {
"description": "Get transactions are contained in the block",
"produces": [
"application/json"
],
"tags": [
"block"
],
"summary": "Get transactions are contained in the block",
"operationId": "get-block-transactions",
"parameters": [
{
"minimum": 1,
"type": "integer",
"description": "Block height",
"name": "height",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Tx"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/constants": {
"get": {
"description": "Get network constants",
"produces": [
"application/json"
],
"tags": [
"general"
],
"summary": "Get network constants",
"operationId": "get-constants",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Constants"
}
},
"204": {
"description": "No Content"
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/enums": {
"get": {
"description": "Get astria explorer enumerators",
"produces": [
"application/json"
],
"tags": [
"general"
],
"summary": "Get astria explorer enumerators",
"operationId": "get-enums",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Enums"
}
}
}
}
},
"/v1/head": {
"get": {
"description": "Get current indexer head",
"produces": [
"application/json"
],
"tags": [
"general"
],
"summary": "Get current indexer head",
"operationId": "head",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.State"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/price": {
"get": {
"description": "Get all currency pairs",
"produces": [
"application/json"
],
"tags": [
"price"
],
"summary": "Get all currency pairs",
"operationId": "list-markets",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Market"
}
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/price/:pair": {
"get": {
"description": "Get the latest price and market info",
"produces": [
"application/json"
],
"tags": [
"price"
],
"summary": "Get the latest price and market info",
"operationId": "get-market",
"parameters": [
{
"type": "string",
"description": "Currency pair",
"name": "pair",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Market"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/price/:pair/:timeframe": {
"get": {
"description": "Get price series",
"produces": [
"application/json"
],
"tags": [
"price"
],
"summary": "Get price series",
"operationId": "get-price-series",
"parameters": [
{
"type": "string",
"description": "Currency pair",
"name": "pair",
"in": "path",
"required": true
},
{
"enum": [
"hour",
"day"
],
"type": "string",
"description": "Timeframe",
"name": "timeframe",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Candle"
}
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/rollup": {
"get": {
"description": "List rollups info",
"produces": [
"application/json"
],
"tags": [
"rollup"
],
"summary": "List rollups info",
"operationId": "list-rollups",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
},
{
"enum": [
"id",
"size"
],
"type": "string",
"description": "Field using for sorting. Default: id",
"name": "sort_by",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Rollup"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/rollup/count": {
"get": {
"description": "Get count of rollups in network",
"produces": [
"application/json"
],
"tags": [
"rollup"
],
"summary": "Get count of rollups in network",
"operationId": "get-rollup-count",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "integer"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/rollup/{hash}": {
"get": {
"description": "Get rollup info",
"produces": [
"application/json"
],
"tags": [
"rollup"
],
"summary": "Get rollup info",
"operationId": "get-rollup",
"parameters": [
{
"type": "string",
"description": "Base64Url encoded rollup id",
"name": "hash",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Rollup"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/rollup/{hash}/actions": {
"get": {
"description": "Get rollup actions",
"produces": [
"application/json"
],
"tags": [
"rollup"
],
"summary": "Get rollup actions",
"operationId": "rollup-actions",
"parameters": [
{
"type": "string",
"description": "Base64Url encoded rollup id",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"minimum": 1,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.RollupAction"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/rollup/{hash}/addresses": {
"get": {
"description": "List addresses which pushed something in the rollup",
"produces": [
"application/json"
],
"tags": [
"rollup"
],
"summary": "List addresses which pushed something in the rollup",
"operationId": "get-rollup-addresses",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Address"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/rollup/{hash}/all_actions": {
"get": {
"description": "Get rollup actions with actions of all connected bridges",
"produces": [
"application/json"
],
"tags": [
"rollup"
],
"summary": "Get rollup actions with actions of all connected bridges",
"operationId": "rollup-all-actions",
"parameters": [
{
"type": "string",
"description": "Base64Url encoded rollup id",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"minimum": 1,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
},
{
"type": "boolean",
"description": "If true join rollup actions. Default: true",
"name": "rollup_actions",
"in": "query"
},
{
"type": "boolean",
"description": "If true join brigde actions. Default: true",
"name": "bridge_actions",
"in": "query"
},
{
"enum": [
"transfer",
"rollup_data_submission",
"validator_update",
"sudo_address_change",
"ibc_relay",
"ics20_withdrawal",
"ibc_relayer_change",
"fee_asset_change",
"init_bridge_account",
"bridge_lock",
"bridge_unlock",
"bridge_sudo_change_action",
"fee_change",
"ibc_sudo_change_action",
"bridge_transfer",
"recover_ibc_client",
"currency_pairs_change",
"markets_change"
],
"type": "string",
"description": "Comma-separated action types list",
"name": "action_types",
"in": "query"
},
{
"type": "integer",
"description": "Time from in unix timestamp",
"name": "from",
"in": "query"
},
{
"type": "integer",
"description": "Time to in unix timestamp",
"name": "to",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Action"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/rollup/{hash}/bridges": {
"get": {
"description": "Get rollup bridges",
"produces": [
"application/json"
],
"tags": [
"rollup"
],
"summary": "Get rollup bridges",
"operationId": "rollup-bridges",
"parameters": [
{
"type": "string",
"description": "Base64Url encoded rollup id",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"minimum": 1,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"minimum": 1,
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Bridge"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/rollup/{hash}/deposits": {
"get": {
"description": "Get rollup deposits",
"produces": [
"application/json"
],
"tags": [
"rollup"
],
"summary": "Get rollup deposits",
"operationId": "get-rollup-deposits",
"parameters": [
{
"type": "string",
"description": "Base64Url encoded rollup id",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Deposit"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/search": {
"get": {
"produces": [
"application/json"
],
"tags": [
"search"
],
"summary": "Search by hash or text",
"operationId": "search",
"parameters": [
{
"type": "string",
"description": "Search string",
"name": "query",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.SearchResult"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/stats/fee/summary": {
"get": {
"description": "Get fee summary",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Get fee summary",
"operationId": "stats-fee-summary",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.FeeSummary"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/stats/rollup/series/{hash}/{name}/{timeframe}": {
"get": {
"description": "Get histogram with precomputed rollup by series name and timeframe",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Get histogram with precomputed rollup stats",
"operationId": "stats-rollup-series",
"parameters": [
{
"type": "string",
"description": "Base64Url encoded rollup id",
"name": "hash",
"in": "path",
"required": true
},
{
"enum": [
"hour",
"day",
"month"
],
"type": "string",
"description": "Timeframe",
"name": "timeframe",
"in": "path",
"required": true
},
{
"enum": [
"size",
"avg_size",
"min_size",
"max_size",
"actions_count"
],
"type": "string",
"description": "Series name",
"name": "name",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Time from in unix timestamp",
"name": "from",
"in": "query"
},
{
"type": "integer",
"description": "Time to in unix timestamp",
"name": "to",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.RollupSeriesItem"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/stats/series/{name}/{timeframe}": {
"get": {
"description": "Get histogram with precomputed stats by series name and timeframe",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Get histogram with precomputed stats",
"operationId": "stats-series",
"parameters": [
{
"enum": [
"hour",
"day",
"month"
],
"type": "string",
"description": "Timeframe",
"name": "timeframe",
"in": "path",
"required": true
},
{
"enum": [
"data_size",
"tps",
"bps",
"rbps",
"fee",
"supply_change",
"block_time",
"tx_count",
"bytes_in_block"
],
"type": "string",
"description": "Series name",
"name": "name",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Time from in unix timestamp",
"name": "from",
"in": "query"
},
{
"type": "integer",
"description": "Time to in unix timestamp",
"name": "to",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.SeriesItem"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/stats/summary": {
"get": {
"description": "Get network summary",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Get network summary",
"operationId": "stats-summary",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.NetworkSummary"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/stats/summary/active_addresses_count": {
"get": {
"description": "Active adddresses count",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Active adddresses count",
"operationId": "stats-active-addresses-count",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "integer"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/stats/summary/{timeframe}": {
"get": {
"description": "Get network summary for the last period",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Get network summary for the last period",
"operationId": "stats-summary-timeframe",
"parameters": [
{
"enum": [
"day",
"week",
"month"
],
"type": "string",
"description": "Timeframe",
"name": "timeframe",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.NetworkSummaryWithChange"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/stats/token/transfer_distribution": {
"get": {
"description": "Token transfer distribution",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Token transfer distribution",
"operationId": "stats-token-transfer-distribution",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.TokenTransferDistributionItem"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/tx": {
"get": {
"description": "List transactions info",
"produces": [
"application/json"
],
"tags": [
"transactions"
],
"summary": "List transactions info",
"operationId": "list-transactions",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
},
{
"enum": [
"success",
"failed"
],
"type": "string",
"description": "Comma-separated status list",
"name": "status",
"in": "query"
},
{
"enum": [
"transfer",
"rollup_data_submission",
"validator_update",
"sudo_address_change",
"ibc_relay",
"ics20_withdrawal",
"ibc_relayer_change",
"fee_asset_change",
"init_bridge_account",
"bridge_lock",
"bridge_unlock",
"bridge_sudo_change_action",
"fee_change",
"ibc_sudo_change_action",
"bridge_transfer",
"recover_ibc_client",
"currency_pairs_change",
"markets_change"
],
"type": "string",
"description": "Comma-separated action types list",
"name": "action_types",
"in": "query"
},
{
"type": "integer",
"description": "Time from in unix timestamp",
"name": "from",
"in": "query"
},
{
"type": "integer",
"description": "Time to in unix timestamp",
"name": "to",
"in": "query"
},
{
"type": "integer",
"description": "Block number",
"name": "height",
"in": "query"
},
{
"type": "boolean",
"description": "If true join actions",
"name": "messages",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Tx"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/tx/count": {
"get": {
"description": "Get count of transactions in network",
"produces": [
"application/json"
],
"tags": [
"transactions"
],
"summary": "Get count of transactions in network",
"operationId": "get-transactions-count",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "integer"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/tx/{hash}": {
"get": {
"description": "Get transaction by hash",
"produces": [
"application/json"
],
"tags": [
"transactions"
],
"summary": "Get transaction by hash",
"operationId": "get-transaction",
"parameters": [
{
"maxLength": 64,
"minLength": 64,
"type": "string",
"description": "Transaction hash in hexadecimal",
"name": "hash",
"in": "path",
"required": true
},
{
"type": "boolean",
"description": "Flag which indicates need join full transaction fees",
"name": "fee",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Tx"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/tx/{hash}/actions": {
"get": {
"description": "Get transaction actions",
"produces": [
"application/json"
],
"tags": [
"transactions"
],
"summary": "Get transaction actions",
"operationId": "get-transaction-actions",
"parameters": [
{
"maxLength": 64,
"minLength": 64,
"type": "string",
"description": "Transaction hash in hexadecimal",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Action"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/tx/{hash}/fees": {
"get": {
"description": "Get transaction fees",
"produces": [
"application/json"
],
"tags": [
"transactions"
],
"summary": "Get transaction fees",
"operationId": "get-transaction-fees",
"parameters": [
{
"maxLength": 64,
"minLength": 64,
"type": "string",
"description": "Transaction hash in hexadecimal",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.FullFee"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/tx/{hash}/rollup_actions": {
"get": {
"description": "List transaction's rollup actions",
"produces": [
"application/json"
],
"tags": [
"transactions"
],
"summary": "List transaction's rollup actions",
"operationId": "list-transactions-rollup-actions",
"parameters": [
{
"maxLength": 64,
"minLength": 64,
"type": "string",
"description": "Transaction hash in hexadecimal",
"name": "hash",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.RollupAction"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/tx/{hash}/rollup_actions/count": {
"get": {
"description": "Count of rollup actions",
"produces": [
"application/json"
],
"tags": [
"transactions"
],
"summary": "Count of rollup actions",
"operationId": "list-transactions-rollup-actions-count",
"parameters": [
{
"maxLength": 64,
"minLength": 64,
"type": "string",
"description": "Transaction hash in hexadecimal",
"name": "hash",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "integer"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/validators": {
"get": {
"description": "List validators sorted by power",
"produces": [
"application/json",
"application/json"
],
"tags": [
"validator"
],
"summary": "List validators",
"operationId": "list-validator",
"parameters": [
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Validator"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/validators/{id}": {
"get": {
"description": "Get validator info",
"produces": [
"application/json"
],
"tags": [
"validator"
],
"summary": "Get validator info",
"operationId": "get-validator",
"parameters": [
{
"type": "integer",
"description": "Internal validator id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.Validator"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/validators/{id}/blocks": {
"get": {
"description": "List blocks which was proposed by validator",
"produces": [
"application/json"
],
"tags": [
"validator"
],
"summary": "List blocks which was proposed by validator",
"operationId": "get-validator-blocks",
"parameters": [
{
"type": "integer",
"description": "Internal validator id",
"name": "id",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested entities",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"enum": [
"asc",
"desc"
],
"type": "string",
"description": "Sort order",
"name": "sort",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Block"
}
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/validators/{id}/uptime": {
"get": {
"description": "Get validator's uptime and history of signed block",
"produces": [
"application/json"
],
"tags": [
"validator"
],
"summary": "Get validator's uptime and history of signed block",
"operationId": "get-validator-uptime",
"parameters": [
{
"type": "integer",
"description": "Internal validator id",
"name": "id",
"in": "path",
"required": true
},
{
"maximum": 100,
"type": "integer",
"description": "Count of requested blocks",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/responses.ValidatorUptime"
}
},
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handler.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.Error"
}
}
}
}
},
"/v1/ws": {
"get": {
"description": "## Documentation for websocket API\n\n### Notification\n\nThe structure of notification is following in all channels:\n\n` + "`" + `` + "`" + `` + "`" + `json\n{\n \"channel\": \"channel_name\",\n \"body\": \"\u003cobject or array\u003e\" // depends on channel\n}\n` + "`" + `` + "`" + `` + "`" + `\n\n### Subscribe\n\nTo receive updates from websocket API send ` + "`" + `subscribe` + "`" + ` request to server.\n\n` + "`" + `` + "`" + `` + "`" + `json\n{\n \"method\": \"subscribe\",\n \"body\": {\n \"channel\": \"\u003cCHANNEL_NAME\u003e\",\n \"filters\": {\n // pass channel filters\n }\n }\n}\n` + "`" + `` + "`" + `` + "`" + `\n\nNow 2 channels are supported:\n\n* ` + "`" + `head` + "`" + ` - receive information about indexer state update. Channel does not have any filters. Subscribe message should looks like:\n\n` + "`" + `` + "`" + `` + "`" + `json\n{\n \"method\": \"subscribe\",\n \"body\": {\n \"channel\": \"head\"\n }\n}\n` + "`" + `` + "`" + `` + "`" + `\n\nNotification body of ` + "`" + `responses.State` + "`" + ` type will be sent to the channel.\n\n* ` + "`" + `blocks` + "`" + ` - receive information about new blocks. Channel does not have any filters. Subscribe message should looks like:\n\n` + "`" + `` + "`" + `` + "`" + `json\n{\n \"method\": \"subscribe\",\n \"body\": {\n \"channel\": \"blocks\"\n }\n}\n` + "`" + `` + "`" + `` + "`" + `\n\nNotification body of ` + "`" + `responses.Block` + "`" + ` type will be sent to the channel.\n\n\n### Unsubscribe\n\nTo unsubscribe send ` + "`" + `unsubscribe` + "`" + ` message containing one of channel name describing above.\n\n\n` + "`" + `` + "`" + `` + "`" + `json\n{\n \"method\": \"unsubscribe\",\n \"body\": {\n \"channel\": \"\u003cCHANNEL_NAME\u003e\",\n }\n}\n` + "`" + `` + "`" + `` + "`" + `\n",
"produces": [
"application/json"
],
"tags": [
"websocket"
],
"summary": "Websocket API",
"operationId": "websocket",
"responses": {}
}
}
},
"definitions": {
"handler.Error": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
},
"responses.Action": {
"type": "object",
"properties": {
"data": {
"type": "object",
"additionalProperties": {}
},
"fee": {
"$ref": "#/definitions/responses.Fee"
},
"height": {
"type": "integer",
"format": "int64",
"example": 1000
},
"id": {
"type": "integer",
"format": "int64",
"example": 1
},
"position": {
"type": "integer",
"format": "int64",
"example": 1
},
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"tx_hash": {
"type": "string",
"format": "binary",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"type": {
"type": "string",
"format": "string",
"example": "rollup_data_submission"
}
}
},
"responses.Address": {
"description": "address information",
"type": "object",
"properties": {
"actions_count": {
"type": "integer",
"example": 10
},
"balances": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Balance"
}
},
"bridge": {
"$ref": "#/definitions/responses.Bridge"
},
"first_height": {
"type": "integer",
"example": 100
},
"hash": {
"type": "string",
"example": "astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2"
},
"id": {
"type": "integer",
"example": 321
},
"is_bridge": {
"type": "boolean",
"example": false
},
"is_ibc_relayer": {
"type": "boolean",
"example": false
},
"is_ibc_sudo": {
"type": "boolean",
"example": false
},
"is_sudo": {
"type": "boolean",
"example": false
},
"nonce": {
"type": "integer",
"example": 10
},
"signed_tx_count": {
"type": "integer",
"example": 10
}
}
},
"responses.AppWithStats": {
"type": "object",
"properties": {
"actions_count": {
"type": "integer",
"format": "integer",
"example": 2
},
"avg_size": {
"type": "integer",
"format": "integer",
"example": 1000
},
"category": {
"type": "string",
"format": "string",
"example": "nft"
},
"description": {
"type": "string",
"format": "string",
"example": "Long rollup description"
},
"explorer": {
"type": "string",
"format": "string",
"example": "https://explorer.karak.network/"
},
"first_message_time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"github": {
"type": "string",
"format": "string",
"example": "https://github.com/account"
},
"id": {
"type": "integer",
"format": "integer",
"example": 321
},
"l2_beat": {
"type": "string",
"format": "string",
"example": "https://l2beat.com/scaling/projects/karak"
},
"last_message_time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"links": {
"type": "array",
"items": {
"type": "string"
}
},
"logo": {
"type": "string",
"format": "string",
"example": "https://some_link.com/image.png"
},
"max_size": {
"type": "integer",
"format": "integer",
"example": 1000
},
"min_size": {
"type": "integer",
"format": "integer",
"example": 1000
},
"name": {
"type": "string",
"format": "string",
"example": "Rollup name"
},
"native_bridge": {
"type": "string",
"format": "string",
"example": "astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2"
},
"provider": {
"type": "string",
"format": "string",
"example": "name"
},
"rollup": {
"type": "string",
"format": "string",
"example": "O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc="
},
"size": {
"type": "integer",
"format": "integer",
"example": 1000
},
"slug": {
"type": "string",
"format": "string",
"example": "rollup_slug"
},
"stack": {
"type": "string",
"format": "string",
"example": "op_stack"
},
"twitter": {
"type": "string",
"format": "string",
"example": "https://x.com/account"
},
"type": {
"type": "string",
"format": "string",
"example": "settled"
},
"vm": {
"type": "string",
"format": "string",
"example": "evm"
},
"website": {
"type": "string",
"format": "string",
"example": "https://website.com"
}
}
},
"responses.Asset": {
"type": "object",
"properties": {
"asset": {
"type": "string",
"format": "string",
"example": "nria"
},
"fee": {
"type": "string",
"format": "string",
"example": "1000"
},
"fee_count": {
"type": "integer",
"format": "number",
"example": 100
},
"supply": {
"type": "string",
"format": "string",
"example": "1000"
},
"transfer_count": {
"type": "integer",
"format": "number",
"example": 100
},
"transferred": {
"type": "string",
"format": "string",
"example": "1000"
}
}
},
"responses.Balance": {
"description": "Balance of address information",
"type": "object",
"properties": {
"currency": {
"type": "string",
"example": "nria"
},
"value": {
"type": "string",
"example": "10000000000"
}
}
},
"responses.Block": {
"type": "object",
"properties": {
"action_types": {
"type": "string",
"example": "rollup_data_submission,transfer"
},
"app_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"consensus_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"data_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"evidence_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"height": {
"type": "integer",
"example": 100
},
"id": {
"type": "integer",
"example": 321
},
"last_commit_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"last_results_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"next_validators_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"parent_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"proposer": {
"$ref": "#/definitions/responses.ShortValidator"
},
"stats": {
"$ref": "#/definitions/responses.BlockStats"
},
"time": {
"type": "string",
"example": "2023-07-04T03:10:57+00:00"
},
"validators_hash": {
"type": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"version_app": {
"type": "string",
"example": "1"
},
"version_block": {
"type": "string",
"example": "11"
}
}
},
"responses.BlockStats": {
"type": "object",
"properties": {
"block_time": {
"type": "integer",
"example": 12354
},
"bytes_in_block": {
"type": "integer",
"example": 1234
},
"fee": {
"type": "string",
"example": "28347628346"
},
"supply_change": {
"type": "string",
"example": "8635234"
},
"tx_count": {
"type": "integer",
"example": 12
}
}
},
"responses.Bridge": {
"description": "bridge account information",
"type": "object",
"properties": {
"address": {
"type": "string",
"example": "astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2"
},
"asset": {
"type": "string",
"example": "nria"
},
"fee_asset": {
"type": "string",
"example": "nria"
},
"rollup": {
"type": "string",
"example": "O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc="
},
"sudo": {
"type": "string",
"example": "astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2"
},
"withdrawer": {
"type": "string",
"example": "astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2"
}
}
},
"responses.Candle": {
"type": "object",
"properties": {
"close": {
"type": "string",
"format": "string",
"example": "0.17632"
},
"high": {
"type": "string",
"format": "string",
"example": "0.17632"
},
"low": {
"type": "string",
"format": "string",
"example": "0.17632"
},
"open": {
"type": "string",
"format": "string",
"example": "0.17632"
},
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
}
}
},
"responses.Constants": {
"type": "object",
"properties": {
"module": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/responses.Params"
}
}
}
},
"responses.Deposit": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"format": "string",
"example": "1000"
},
"asset": {
"type": "string",
"format": "string",
"example": "nria"
},
"bridge": {
"type": "string",
"format": "string",
"example": "astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2"
},
"destination_chain_address": {
"type": "string",
"format": "string",
"example": "0x8bAec8896775DDa83796eda3e7E67217b5E3C5dA"
},
"height": {
"type": "integer",
"format": "int64",
"example": 100
},
"id": {
"type": "integer",
"format": "int64",
"example": 321
},
"rollup": {
"type": "string",
"format": "string",
"example": "O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc="
},
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"tx_hash": {
"type": "string",
"format": "binary",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
}
}
},
"responses.Enums": {
"type": "object",
"properties": {
"action_type": {
"type": "array",
"items": {
"type": "string"
}
},
"status": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"responses.Fee": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"format": "string",
"example": "1000"
},
"asset": {
"type": "string",
"format": "string",
"example": "nria"
}
}
},
"responses.FeeSummary": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"format": "integer",
"example": "1000000"
},
"asset": {
"type": "string",
"format": "string",
"example": "nria"
},
"fee_count": {
"type": "integer",
"format": "integer",
"example": 1000000
},
"max_amount": {
"type": "string",
"format": "integer",
"example": "1000000"
},
"min_amount": {
"type": "string",
"format": "integer",
"example": "1000000"
}
}
},
"responses.FullFee": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"format": "string",
"example": "1000"
},
"asset": {
"type": "string",
"format": "string",
"example": "nria"
},
"height": {
"type": "integer",
"format": "int64",
"example": 100
},
"payer": {
"type": "string",
"format": "string",
"example": "astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2"
},
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"tx_hash": {
"type": "string",
"format": "binary",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
}
}
},
"responses.Market": {
"type": "object",
"properties": {
"base": {
"type": "string",
"format": "string",
"example": "BTC"
},
"decimals": {
"type": "integer",
"format": "integer",
"example": 8
},
"enabled": {
"type": "boolean",
"format": "boolean",
"example": true
},
"min_provider_count": {
"type": "integer",
"format": "integer",
"example": 1
},
"pair": {
"type": "string",
"format": "string",
"example": "BTC/USDT"
},
"price": {
"$ref": "#/definitions/responses.Price"
},
"quote": {
"type": "string",
"format": "string",
"example": "USDT"
}
}
},
"responses.NetworkSummary": {
"type": "object",
"properties": {
"block_time": {
"type": "number",
"format": "number",
"example": 2345
},
"bps": {
"type": "number",
"format": "number",
"example": 0.17632
},
"bytes_in_block": {
"type": "integer",
"format": "integer",
"example": 1024
},
"data_size": {
"type": "integer",
"format": "integer",
"example": 1000000
},
"fee": {
"type": "string",
"format": "string",
"example": "1012012"
},
"rbps": {
"type": "number",
"format": "number",
"example": 0.17632
},
"supply": {
"type": "string",
"format": "string",
"example": "1029129"
},
"tps": {
"type": "number",
"format": "number",
"example": 0.17632
},
"tx_count": {
"type": "integer",
"format": "integer",
"example": 100
}
}
},
"responses.NetworkSummaryWithChange": {
"type": "object",
"properties": {
"block_time": {
"type": "number",
"format": "number",
"example": 2345
},
"block_time_pct": {
"type": "number",
"format": "number",
"example": 17.632
},
"bps": {
"type": "number",
"format": "number",
"example": 0.17632
},
"bps_pct": {
"type": "number",
"format": "number",
"example": 17.632
},
"bytes_in_block": {
"type": "integer",
"format": "integer",
"example": 1024
},
"bytes_in_block_pct": {
"type": "number",
"format": "number",
"example": 17.632
},
"data_size": {
"type": "integer",
"format": "integer",
"example": 1000000
},
"data_size_pct": {
"type": "number",
"format": "number",
"example": 17.632
},
"rbps": {
"type": "number",
"format": "number",
"example": 0.17632
},
"rbps_pct": {
"type": "number",
"format": "number",
"example": 17.632
},
"tps": {
"type": "number",
"format": "number",
"example": 0.17632
},
"tps_pct": {
"type": "number",
"format": "number",
"example": 17.632
},
"tx_count": {
"type": "integer",
"format": "integer",
"example": 100
},
"tx_count_pct": {
"type": "number",
"format": "number",
"example": 17.632
}
}
},
"responses.Params": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"responses.Price": {
"type": "object",
"properties": {
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"value": {
"type": "string",
"format": "string",
"example": "50.00"
}
}
},
"responses.Rollup": {
"type": "object",
"properties": {
"actions_count": {
"type": "integer",
"example": 101
},
"app": {
"$ref": "#/definitions/responses.AppWithStats"
},
"bridge_count": {
"type": "integer",
"example": 2
},
"first_height": {
"type": "integer",
"example": 100
},
"hash": {
"type": "string",
"example": "O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc="
},
"id": {
"type": "integer",
"example": 321
},
"size": {
"type": "integer",
"example": 100
}
}
},
"responses.RollupAction": {
"type": "object",
"properties": {
"data": {
"type": "object",
"additionalProperties": {}
},
"fee": {
"$ref": "#/definitions/responses.Fee"
},
"height": {
"type": "integer",
"format": "int64",
"example": 1000
},
"id": {
"type": "integer",
"format": "int64",
"example": 1
},
"position": {
"type": "integer",
"format": "int64",
"example": 1
},
"rollup": {
"$ref": "#/definitions/responses.Rollup"
},
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"tx_hash": {
"type": "string",
"format": "binary",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"type": {
"type": "string",
"format": "string",
"example": "rollup_data_submission"
}
}
},
"responses.RollupSeriesItem": {
"type": "object",
"properties": {
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"value": {
"type": "string",
"format": "string",
"example": "0.17632"
}
}
},
"responses.SearchResult": {
"type": "object",
"properties": {
"body": {},
"type": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"responses.SeriesItem": {
"type": "object",
"properties": {
"max": {
"type": "string",
"format": "string",
"example": "0.17632"
},
"min": {
"type": "string",
"format": "string",
"example": "0.17632"
},
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"value": {
"type": "string",
"format": "string",
"example": "0.17632"
}
}
},
"responses.ShortValidator": {
"type": "object",
"properties": {
"address": {
"type": "string",
"example": "E641C7A2C964833E556AEF934FBF166B712874B6"
},
"id": {
"type": "integer",
"example": 321
},
"name": {
"type": "string",
"example": "Node0"
}
}
},
"responses.SignedBlocks": {
"type": "object",
"properties": {
"height": {
"type": "integer",
"example": 100
},
"signed": {
"type": "boolean",
"example": true
}
}
},
"responses.State": {
"type": "object",
"properties": {
"chain_id": {
"type": "string",
"format": "string",
"example": "astria-dusk-7"
},
"hash": {
"type": "string",
"format": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"id": {
"type": "integer",
"format": "int64",
"example": 321
},
"last_height": {
"type": "integer",
"format": "int64",
"example": 100
},
"last_time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
},
"name": {
"type": "string",
"format": "string",
"example": "indexer"
},
"synced": {
"type": "boolean",
"format": "boolean",
"example": true
},
"total_accounts": {
"type": "integer",
"format": "int64",
"example": 43
},
"total_bridges": {
"type": "integer",
"format": "int64",
"example": 312
},
"total_bytes": {
"type": "integer",
"format": "int64",
"example": 312
},
"total_rollups": {
"type": "integer",
"format": "int64",
"example": 312
},
"total_supply": {
"type": "string",
"format": "string",
"example": "312"
},
"total_tx": {
"type": "integer",
"format": "int64",
"example": 23456
}
}
},
"responses.TokenTransferDistributionItem": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"format": "integer",
"example": "1000000"
},
"asset": {
"type": "string",
"format": "string",
"example": "nria"
},
"transfers_count": {
"type": "integer",
"format": "integer",
"example": 1000000
}
}
},
"responses.Tx": {
"type": "object",
"properties": {
"action_types": {
"type": "string",
"format": "string",
"example": "rollup_data_submission,transfer"
},
"actions": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.Action"
}
},
"actions_count": {
"type": "integer",
"format": "int64",
"example": 1
},
"codespace": {
"type": "string",
"format": "string",
"example": "sdk"
},
"error": {
"type": "string",
"format": "string",
"example": "some error text"
},
"fees": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.TxFee"
}
},
"hash": {
"type": "string",
"format": "binary",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"height": {
"type": "integer",
"format": "int64",
"example": 100
},
"id": {
"type": "integer",
"format": "int64",
"example": 321
},
"nonce": {
"type": "integer",
"format": "int64",
"example": 1
},
"position": {
"type": "integer",
"format": "int64",
"example": 11
},
"signature": {
"type": "string",
"format": "string",
"example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF"
},
"signer": {
"type": "string",
"format": "string",
"example": "115F94D8C98FFD73FE65182611140F0EDC7C3C94"
},
"status": {
"type": "string",
"format": "string",
"example": "success"
},
"time": {
"type": "string",
"format": "date-time",
"example": "2023-07-04T03:10:57+00:00"
}
}
},
"responses.TxFee": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"format": "string",
"example": "1000"
},
"asset": {
"type": "string",
"format": "string",
"example": "nria"
}
}
},
"responses.Validator": {
"type": "object",
"properties": {
"address": {
"type": "string",
"example": "E641C7A2C964833E556AEF934FBF166B712874B6"
},
"id": {
"type": "integer",
"example": 321
},
"name": {
"type": "string",
"example": "Node0"
},
"power": {
"type": "string",
"example": "100"
},
"pubkey": {
"type": "string",
"example": "a497aa4a22ca8232876082920b110678988c86194b0c2e12a04dcf6f53688bb2"
},
"pubkey_type": {
"type": "string",
"example": "tendermint/PubKeyEd25519"
}
}
},
"responses.ValidatorUptime": {
"type": "object",
"properties": {
"blocks": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.SignedBlocks"
}
},
"uptime": {
"type": "string",
"example": "0.97"
}
}
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "api.astrotrek.io",
BasePath: "",
Schemes: []string{},
Title: "Swagger Astria Explorer API",
Description: "This is docs of Astria Explorer API.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"time"
"github.com/celenium-io/astria-indexer/cmd/api/cache"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
)
type AddressHandler struct {
constantCache *cache.ConstantsCache
address storage.IAddress
txs storage.ITx
actions storage.IAction
rollups storage.IRollup
fees storage.IFee
bridge storage.IBridge
deposits storage.IDeposit
state storage.IState
indexerName string
}
func NewAddressHandler(
constantCache *cache.ConstantsCache,
address storage.IAddress,
txs storage.ITx,
actions storage.IAction,
rollups storage.IRollup,
fees storage.IFee,
bridge storage.IBridge,
deposits storage.IDeposit,
state storage.IState,
indexerName string,
) *AddressHandler {
return &AddressHandler{
constantCache: constantCache,
address: address,
txs: txs,
actions: actions,
rollups: rollups,
fees: fees,
bridge: bridge,
deposits: deposits,
state: state,
indexerName: indexerName,
}
}
var _ Handler = (*AddressHandler)(nil)
func (handler *AddressHandler) InitRoutes(srvr *echo.Group) {
addressesGroup := srvr.Group("/address")
{
addressesGroup.GET("", handler.List)
addressesGroup.GET("/count", handler.Count)
addressGroup := addressesGroup.Group("/:hash")
{
addressGroup.GET("", handler.Get)
addressGroup.GET("/txs", handler.Transactions)
addressGroup.GET("/actions", handler.Actions)
addressGroup.GET("/rollups", handler.Rollups)
addressGroup.GET("/roles", handler.Roles)
addressGroup.GET("/fees", handler.Fees)
addressGroup.GET("/deposits", handler.Deposits)
}
}
}
type getAddressRequest struct {
Hash string `param:"hash" validate:"required,address"`
}
// Get godoc
//
// @Summary Get address info
// @Description Get address info
// @Tags address
// @ID get-address
// @Param hash path string true "Hash" minlength(48) maxlength(48)
// @Produce json
// @Success 200 {object} responses.Address
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/address/{hash} [get]
func (handler *AddressHandler) Get(c echo.Context) error {
req, err := bindAndValidate[getAddressRequest](c)
if err != nil {
return badRequestError(c, err)
}
address, err := handler.address.ByHash(c.Request().Context(), req.Hash)
if err != nil {
return handleError(c, err, handler.address)
}
sudoAddress, _ := handler.constantCache.Get(types.ModuleNameGeneric, "authority_sudo_address")
ibcSudoAddress, _ := handler.constantCache.Get(types.ModuleNameGeneric, "ibc_sudo_address")
bridge, err := handler.bridge.ByAddress(c.Request().Context(), address.Id)
if err != nil {
if !handler.bridge.IsNoRows(err) {
return handleError(c, err, handler.address)
}
return c.JSON(http.StatusOK, responses.NewAddress(address, nil, sudoAddress, ibcSudoAddress))
}
return c.JSON(http.StatusOK, responses.NewAddress(address, &bridge, sudoAddress, ibcSudoAddress))
}
type listAddressRequest struct {
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
Asset string `query:"asset" validate:"omitempty"`
}
func (p *listAddressRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
}
// List godoc
//
// @Summary List address info
// @Description List address info
// @Tags address
// @ID list-address
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Param asset query string false "Required balance asset"
// @Produce json
// @Success 200 {array} responses.Address
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/address [get]
func (handler *AddressHandler) List(c echo.Context) error {
req, err := bindAndValidate[listAddressRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
fltrs := storage.AddressListFilter{
Limit: int(req.Limit),
Offset: int(req.Offset),
Sort: pgSort(req.Sort),
Asset: req.Asset,
}
address, err := handler.address.ListWithBalance(c.Request().Context(), fltrs)
if err != nil {
return handleError(c, err, handler.address)
}
sudoAddress, _ := handler.constantCache.Get(types.ModuleNameGeneric, "authority_sudo_address")
ibcSudoAddress, _ := handler.constantCache.Get(types.ModuleNameGeneric, "ibc_sudo_address")
response := make([]responses.Address, len(address))
for i := range address {
response[i] = responses.NewAddress(address[i], nil, sudoAddress, ibcSudoAddress)
}
return returnArray(c, response)
}
type addressTxRequest struct {
Hash string `param:"hash" validate:"required,address"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
Height uint64 `query:"height" validate:"omitempty,min=1"`
Status StringArray `query:"status" validate:"omitempty,dive,status"`
ActionTypes StringArray `query:"action_types" validate:"omitempty,dive,action_type"`
From int64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To int64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
}
func (p *addressTxRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
}
// Transactions godoc
//
// @Summary Get address transactions
// @Description Get address transactions
// @Tags address
// @ID address-transactions
// @Param hash path string true "Hash" minlength(48) maxlength(48)
// @Param limit query integer false "Count of requested entities" minimum(1) maximum(100)
// @Param offset query integer false "Offset" minimum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Param status query types.Status false "Comma-separated status list"
// @Param action_types query types.ActionType false "Comma-separated action types list"
// @Param from query integer false "Time from in unix timestamp" minimum(1)
// @Param to query integer false "Time to in unix timestamp" minimum(1)
// @Param height query integer false "Block number" minimum(1)
// @Produce json
// @Success 200 {array} responses.Tx
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/address/{hash}/txs [get]
func (handler *AddressHandler) Transactions(c echo.Context) error {
req, err := bindAndValidate[addressTxRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
address, err := handler.address.ByHash(c.Request().Context(), req.Hash)
if err != nil {
return handleError(c, err, handler.address)
}
fltrs := storage.TxFilter{
Limit: int(req.Limit),
Offset: int(req.Offset),
Sort: pgSort(req.Sort),
Status: req.Status,
Height: req.Height,
ActionTypes: types.NewActionTypeMask(),
}
if req.From > 0 {
fltrs.TimeFrom = time.Unix(req.From, 0).UTC()
}
if req.To > 0 {
fltrs.TimeTo = time.Unix(req.To, 0).UTC()
}
for i := range req.ActionTypes {
fltrs.ActionTypes.SetType(types.ActionType(req.ActionTypes[i]))
}
txs, err := handler.txs.ByAddress(c.Request().Context(), address.Id, fltrs)
if err != nil {
return handleError(c, err, handler.address)
}
response := make([]responses.Tx, len(txs))
for i := range txs {
response[i] = responses.NewTx(txs[i])
}
return returnArray(c, response)
}
type getAddressMessages struct {
Hash string `param:"hash" validate:"required,address"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
ActionTypes StringArray `query:"action_types" validate:"omitempty,dive,action_type"`
}
func (p *getAddressMessages) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
if p.ActionTypes == nil {
p.ActionTypes = make(StringArray, 0)
}
}
func (p *getAddressMessages) ToFilters() storage.AddressActionsFilter {
fltrs := storage.AddressActionsFilter{
Limit: int(p.Limit),
Offset: int(p.Offset),
Sort: pgSort(p.Sort),
ActionTypes: types.NewActionTypeMask(),
}
for i := range p.ActionTypes {
fltrs.ActionTypes.SetType(types.ActionType(p.ActionTypes[i]))
}
return fltrs
}
// Actions godoc
//
// @Summary Get address actions
// @Description Get address actions
// @Tags address
// @ID address-actions
// @Param hash path string true "Hash" minlength(48) maxlength(48)
// @Param limit query integer false "Count of requested entities" minimum(1) maximum(100)
// @Param offset query integer false "Offset" minimum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Param action_types query types.ActionType false "Comma-separated action types list"
// @Produce json
// @Success 200 {array} responses.Action
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/address/{hash}/actions [get]
func (handler *AddressHandler) Actions(c echo.Context) error {
req, err := bindAndValidate[getAddressMessages](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
address, err := handler.address.ByHash(c.Request().Context(), req.Hash)
if err != nil {
return handleError(c, err, handler.address)
}
filters := req.ToFilters()
actions, err := handler.actions.ByAddress(c.Request().Context(), address.Id, filters)
if err != nil {
return handleError(c, err, handler.address)
}
response := make([]responses.Action, len(actions))
for i := range actions {
response[i] = responses.NewAddressAction(actions[i])
}
return returnArray(c, response)
}
// Count godoc
//
// @Summary Get count of addresses in network
// @Description Get count of addresses in network
// @Tags address
// @ID get-address-count
// @Produce json
// @Success 200 {integer} uint64
// @Failure 500 {object} Error
// @Router /v1/address/count [get]
func (handler *AddressHandler) Count(c echo.Context) error {
state, err := handler.state.ByName(c.Request().Context(), handler.indexerName)
if err != nil {
return handleError(c, err, handler.address)
}
return c.JSON(http.StatusOK, state.TotalAccounts)
}
type getAddressRollups struct {
Hash string `param:"hash" validate:"required,address"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
}
func (p *getAddressRollups) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
}
// Rollups godoc
//
// @Summary Get rollups in which the address pushed something
// @Description Get rollups in which the address pushed something
// @Tags address
// @ID address-rollups
// @Param hash path string true "Hash" minlength(48) maxlength(48)
// @Param limit query integer false "Count of requested entities" minimum(1) maximum(100)
// @Param offset query integer false "Offset" minimum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Produce json
// @Success 200 {array} responses.Rollup
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/address/{hash}/rollups [get]
func (handler *AddressHandler) Rollups(c echo.Context) error {
req, err := bindAndValidate[getAddressRollups](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
address, err := handler.address.ByHash(c.Request().Context(), req.Hash)
if err != nil {
return handleError(c, err, handler.address)
}
rollups, err := handler.rollups.ListRollupsByAddress(c.Request().Context(), address.Id, req.Limit, req.Offset, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.address)
}
response := make([]responses.Rollup, len(rollups))
for i := range rollups {
response[i] = responses.NewRollup(rollups[i].Rollup)
}
return returnArray(c, response)
}
type getAddressRoles struct {
Hash string `param:"hash" validate:"required,address"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
}
func (p *getAddressRoles) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
}
// Roles godoc
//
// @Summary Get address roles in bridges
// @Description Get address roles in bridges
// @Tags address
// @ID address-roles
// @Param hash path string true "Hash" minlength(48) maxlength(48)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.Bridge
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/address/{hash}/roles [get]
func (handler *AddressHandler) Roles(c echo.Context) error {
req, err := bindAndValidate[getAddressRoles](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
address, err := handler.address.ByHash(c.Request().Context(), req.Hash)
if err != nil {
return handleError(c, err, handler.address)
}
roles, err := handler.bridge.ByRoles(c.Request().Context(), address.Id, req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.address)
}
response := make([]responses.Bridge, len(roles))
for i := range roles {
response[i] = responses.NewBridge(roles[i])
}
return returnArray(c, response)
}
type getAddressFees struct {
Hash string `param:"hash" validate:"required,address"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
}
func (p *getAddressFees) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = desc
}
}
// Fees godoc
//
// @Summary Get address paid fees
// @Description Get address paid fees
// @Tags address
// @ID get-address-fees
// @Param hash path string true "Hash" minlength(48) maxlength(48)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.FullFee
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/address/{hash}/fees [get]
func (handler *AddressHandler) Fees(c echo.Context) error {
req, err := bindAndValidate[getAddressFees](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
address, err := handler.address.ByHash(c.Request().Context(), req.Hash)
if err != nil {
return handleError(c, err, handler.address)
}
fees, err := handler.fees.ByPayerId(c.Request().Context(), address.Id, req.Limit, req.Offset, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.address)
}
response := make([]responses.FullFee, len(fees))
for i := range fees {
response[i] = responses.NewFullFee(fees[i])
}
return returnArray(c, response)
}
type getAddressDeposits struct {
Hash string `param:"hash" validate:"required,address"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
}
func (p *getAddressDeposits) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = desc
}
}
// Deposits godoc
//
// @Summary Get bridge deposits
// @Description Get bridge deposits
// @Tags address
// @ID get-address-deposits
// @Param hash path string true "Hash" minlength(48) maxlength(48)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Produce json
// @Success 200 {array} responses.Deposit
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/address/{hash}/deposits [get]
func (handler *AddressHandler) Deposits(c echo.Context) error {
req, err := bindAndValidate[getAddressDeposits](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
address, err := handler.address.ByHash(c.Request().Context(), req.Hash)
if err != nil {
return handleError(c, err, handler.address)
}
if !address.IsBridge {
return handleError(c, errors.Errorf("address %s is not bridge", req.Hash), handler.address)
}
bridge, err := handler.bridge.ByAddress(c.Request().Context(), address.Id)
if err != nil {
return handleError(c, err, handler.address)
}
deposits, err := handler.deposits.ByBridgeId(c.Request().Context(), bridge.Id, req.Limit, req.Offset, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.address)
}
response := make([]responses.Deposit, len(deposits))
for i := range deposits {
response[i] = responses.NewDeposit(deposits[i])
}
return returnArray(c, response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/labstack/echo/v4"
)
type AppHandler struct {
apps storage.IApp
}
func NewAppHandler(
apps storage.IApp,
) *AppHandler {
return &AppHandler{
apps: apps,
}
}
var _ Handler = (*AppHandler)(nil)
func (handler *AppHandler) InitRoutes(srvr *echo.Group) {
apps := srvr.Group("/app")
{
apps.GET("", handler.Leaderboard)
app := apps.Group("/:slug")
{
app.GET("", handler.Get)
}
}
}
type leaderboardRequest struct {
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
SortBy string `query:"sort_by" validate:"omitempty,oneof=time actions_count size"`
Category StringArray `query:"category" validate:"omitempty,dive,app_category"`
}
func (p *leaderboardRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = desc
}
if p.SortBy == "" {
p.SortBy = "size"
}
}
// Leaderboard godoc
//
// @Summary List applications info
// @Description List applications info
// @Tags applications
// @ID list-applications
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order. Default: desc" Enums(asc, desc)
// @Param sort_by query string false "Sort field. Default: size" Enums(time, actions_count, size)
// @Param category query string false "Comma-separated application category list"
// @Produce json
// @Success 200 {array} responses.AppWithStats
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /app [get]
func (handler AppHandler) Leaderboard(c echo.Context) error {
req, err := bindAndValidate[leaderboardRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
categories := make([]types.AppCategory, len(req.Category))
for i := range categories {
categories[i] = types.AppCategory(req.Category[i])
}
apps, err := handler.apps.Leaderboard(c.Request().Context(), storage.LeaderboardFilters{
SortField: req.SortBy,
Sort: pgSort(req.Sort),
Limit: req.Limit,
Offset: req.Offset,
Category: categories,
})
if err != nil {
return handleError(c, err, handler.apps)
}
response := make([]responses.AppWithStats, len(apps))
for i := range apps {
response[i] = responses.NewAppWithStats(apps[i])
}
return returnArray(c, response)
}
type getAppRequest struct {
Slug string `param:"slug" validate:"required"`
}
// Get godoc
//
// @Summary Get application info
// @Description Get application info
// @Tags applications
// @ID get-application
// @Param slug path string true "Slug"
// @Produce json
// @Success 200 {object} responses.AppWithStats
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /app/{slug} [get]
func (handler AppHandler) Get(c echo.Context) error {
req, err := bindAndValidate[getAppRequest](c)
if err != nil {
return badRequestError(c, err)
}
rollup, err := handler.apps.BySlug(c.Request().Context(), req.Slug)
if err != nil {
return handleError(c, err, handler.apps)
}
return c.JSON(http.StatusOK, responses.NewAppWithStats(rollup))
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/labstack/echo/v4"
)
type AssetHandler struct {
asset storage.IAsset
blocks storage.IBlock
}
func NewAssetHandler(
asset storage.IAsset,
blocks storage.IBlock,
) *AssetHandler {
return &AssetHandler{
asset: asset,
blocks: blocks,
}
}
var _ Handler = (*AssetHandler)(nil)
func (handler *AssetHandler) InitRoutes(srvr *echo.Group) {
assets := srvr.Group("/asset")
{
assets.GET("", handler.List)
}
}
type assetListRequest struct {
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
SortField string `query:"sort_by" validate:"omitempty,oneof=fee fee_count transferred transfer_count supply"`
}
func (p *assetListRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = desc
}
}
// List godoc
//
// @Summary Get assets info
// @Description Get assets info
// @Tags assets
// @ID get-asset
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Param sort_by query string false "Field using for sorting. Default: fee" Enums(fee, fee_count, transferred, transfer_count, supply)
// @Produce json
// @Success 200 {object} responses.Asset
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/asset [get]
func (handler *AssetHandler) List(c echo.Context) error {
req, err := bindAndValidate[assetListRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
assets, err := handler.asset.List(c.Request().Context(), int(req.Limit), int(req.Offset), req.SortField, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.blocks)
}
response := make([]responses.Asset, len(assets))
for i := range assets {
response[i] = responses.NewAsset(assets[i])
}
return c.JSON(http.StatusOK, response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/labstack/echo/v4"
)
type BlockHandler struct {
block storage.IBlock
blockStats storage.IBlockStats
txs storage.ITx
actions storage.IAction
rollups storage.IRollup
state storage.IState
indexerName string
}
func NewBlockHandler(
block storage.IBlock,
blockStats storage.IBlockStats,
txs storage.ITx,
actions storage.IAction,
rollups storage.IRollup,
state storage.IState,
indexerName string,
) *BlockHandler {
return &BlockHandler{
block: block,
blockStats: blockStats,
txs: txs,
actions: actions,
rollups: rollups,
state: state,
indexerName: indexerName,
}
}
var _ Handler = (*BlockHandler)(nil)
func (handler *BlockHandler) InitRoutes(srvr *echo.Group) {
blockGroup := srvr.Group("/block")
{
blockGroup.GET("", handler.List)
blockGroup.GET("/count", handler.Count)
heightGroup := blockGroup.Group("/:height")
{
heightGroup.GET("", handler.Get)
heightGroup.GET("/actions", handler.GetActions)
heightGroup.GET("/txs", handler.GetTransactions)
heightGroup.GET("/stats", handler.GetStats)
heightGroup.GET("/rollup_actions", handler.GetRollupActions)
heightGroup.GET("/rollup_actions/count", handler.GetRollupsActionsCount)
}
}
}
type getBlockByHeightRequest struct {
Height types.Level `param:"height" validate:"min=0"`
}
type getBlockRequest struct {
Height types.Level `param:"height" validate:"min=0"`
Stats bool `query:"stats" validate:"omitempty"`
}
// Get godoc
//
// @Summary Get block info
// @Description Get block info
// @Tags block
// @ID get-block
// @Param height path integer true "Block height" minimum(1)
// @Param stats query boolean false "Need join stats for block"
// @Produce json
// @Success 200 {object} responses.Block
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/block/{height} [get]
func (handler *BlockHandler) Get(c echo.Context) error {
req, err := bindAndValidate[getBlockRequest](c)
if err != nil {
return badRequestError(c, err)
}
block, err := handler.block.ByHeight(c.Request().Context(), req.Height, req.Stats)
if err != nil {
return handleError(c, err, handler.block)
}
return c.JSON(http.StatusOK, responses.NewBlock(block))
}
type blockListRequest struct {
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
Stats bool `query:"stats" validate:"omitempty"`
}
func (p *blockListRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
}
// List godoc
//
// @Summary List blocks info
// @Description List blocks info
// @Tags block
// @ID list-block
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Param stats query boolean false "Need join stats for block"
// @Produce json
// @Success 200 {array} responses.Block
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/block [get]
func (handler *BlockHandler) List(c echo.Context) error {
req, err := bindAndValidate[blockListRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
var blocks []*storage.Block
if req.Stats {
blocks, err = handler.block.ListWithStats(c.Request().Context(), req.Limit, req.Offset, pgSort(req.Sort))
} else {
blocks, err = handler.block.List(c.Request().Context(), req.Limit, req.Offset, pgSort(req.Sort))
}
if err != nil {
return handleError(c, err, handler.block)
}
response := make([]responses.Block, len(blocks))
for i := range blocks {
response[i] = responses.NewBlock(*blocks[i])
}
return returnArray(c, response)
}
type listByHeight struct {
Height types.Level `param:"height" validate:"min=0"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
}
func (p *listByHeight) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
}
// GetActions godoc
//
// @Summary Get actions from begin and end of block
// @Description Get actions from begin and end of block
// @Tags block
// @ID get-block-actions
// @Param height path integer true "Block height" minimum(1)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.Action
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/block/{height}/actions [get]
func (handler *BlockHandler) GetActions(c echo.Context) error {
req, err := bindAndValidate[listByHeight](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
actions, err := handler.actions.ByBlock(c.Request().Context(), req.Height, req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.block)
}
response := make([]responses.Action, len(actions))
for i := range actions {
response[i] = responses.NewActionWithTx(actions[i])
}
return returnArray(c, response)
}
// GetStats godoc
//
// @Summary Get block stats by height
// @Description Get block stats by height
// @Tags block
// @ID get-block-stats
// @Param height path integer true "Block height" minimum(1)
// @Produce json
// @Success 200 {object} responses.BlockStats
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/block/{height}/stats [get]
func (handler *BlockHandler) GetStats(c echo.Context) error {
req, err := bindAndValidate[getBlockByHeightRequest](c)
if err != nil {
return badRequestError(c, err)
}
stats, err := handler.blockStats.ByHeight(c.Request().Context(), req.Height)
if err != nil {
return handleError(c, err, handler.block)
}
return c.JSON(http.StatusOK, responses.NewBlockStats(&stats))
}
// GetRollupActions godoc
//
// @Summary Get rollup actions in the block
// @Description Get rollup actions in the block
// @Tags block
// @ID get-block-rollup-actions
// @Param height path integer true "Block height" minimum(1)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.RollupAction
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/block/{height}/rollup_actions [get]
func (handler *BlockHandler) GetRollupActions(c echo.Context) error {
req, err := bindAndValidate[listByHeight](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
actions, err := handler.rollups.ActionsByHeight(c.Request().Context(), req.Height, req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.block)
}
response := make([]responses.RollupAction, len(actions))
for i := range response {
response[i] = responses.NewRollupAction(actions[i])
}
return c.JSON(http.StatusOK, response)
}
// GetRollupsActionsCount godoc
//
// @Summary Get count of rollup actions
// @Description Get count of rollup actions
// @Tags block
// @ID get-block-rollup-actions-count
// @Param height path integer true "Block height" minimum(1)
// @Produce json
// @Success 200 {integer} int64
// @Failure 500 {object} Error
// @Router /v1/block/{height}/rollup_actions/count [get]
func (handler *BlockHandler) GetRollupsActionsCount(c echo.Context) error {
req, err := bindAndValidate[getBlockByHeightRequest](c)
if err != nil {
return badRequestError(c, err)
}
count, err := handler.rollups.CountActionsByHeight(c.Request().Context(), req.Height)
if err != nil {
return handleError(c, err, handler.block)
}
return c.JSON(http.StatusOK, count)
}
// Count godoc
//
// @Summary Get count of blocks in network
// @Description Get count of blocks in network
// @Tags block
// @ID get-block-count
// @Produce json
// @Success 200 {integer} uint64
// @Failure 500 {object} Error
// @Router /v1/block/count [get]
func (handler *BlockHandler) Count(c echo.Context) error {
state, err := handler.state.ByName(c.Request().Context(), handler.indexerName)
if err != nil {
return handleError(c, err, handler.block)
}
return c.JSON(http.StatusOK, state.LastHeight+1) // + genesis block
}
// GetTransactions godoc
//
// @Summary Get transactions are contained in the block
// @Description Get transactions are contained in the block
// @Tags block
// @ID get-block-transactions
// @Param height path integer true "Block height" minimum(1)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.Tx
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/block/{height}/txs [get]
func (handler *BlockHandler) GetTransactions(c echo.Context) error {
req, err := bindAndValidate[listByHeight](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
txs, err := handler.txs.ByHeight(c.Request().Context(), req.Height, req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.block)
}
response := make([]responses.Tx, len(txs))
for i := range response {
response[i] = responses.NewTx(txs[i])
}
return c.JSON(http.StatusOK, response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/labstack/echo/v4"
)
type ConstantHandler struct {
constants storage.IConstant
}
func NewConstantHandler(constants storage.IConstant) *ConstantHandler {
return &ConstantHandler{
constants: constants,
}
}
var _ Handler = (*ConstantHandler)(nil)
func (handler *ConstantHandler) InitRoutes(srvr *echo.Group) {
srvr.GET("/constants", handler.Get)
srvr.GET("/enums", handler.Enums)
}
// Get godoc
//
// @Summary Get network constants
// @Description Get network constants
// @Tags general
// @ID get-constants
// @Produce json
// @Success 200 {object} responses.Constants
// @Success 204
// @Failure 500 {object} Error
// @Router /v1/constants [get]
func (handler *ConstantHandler) Get(c echo.Context) error {
consts, err := handler.constants.All(c.Request().Context())
if err != nil {
return handleError(c, err, handler.constants)
}
return c.JSON(http.StatusOK, responses.NewConstants(consts))
}
// Enums godoc
//
// @Summary Get astria explorer enumerators
// @Description Get astria explorer enumerators
// @Tags general
// @ID get-enums
// @Produce json
// @Success 200 {object} responses.Enums
// @Router /v1/enums [get]
func (handler *ConstantHandler) Enums(c echo.Context) error {
return c.JSON(http.StatusOK, responses.NewEnums())
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"context"
"net/http"
sentryecho "github.com/getsentry/sentry-go/echo"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
)
var (
errInvalidAddress = errors.New("invalid address")
errCancelRequest = "pq: canceling statement due to user request"
)
type NoRows interface {
IsNoRows(err error) bool
}
type Error struct {
Message string `json:"message"`
}
func badRequestError(c echo.Context, err error) error {
return c.JSON(http.StatusBadRequest, Error{
Message: err.Error(),
})
}
func internalServerError(c echo.Context, err error) error {
if hub := sentryecho.GetHubFromContext(c); hub != nil {
hub.CaptureMessage(err.Error())
}
return c.JSON(http.StatusInternalServerError, Error{
Message: err.Error(),
})
}
func handleError(c echo.Context, err error, noRows NoRows) error {
if err == nil {
return nil
}
if err.Error() == errCancelRequest {
return nil
}
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return c.JSON(http.StatusBadGateway, Error{
Message: err.Error(),
})
}
if noRows.IsNoRows(err) {
return c.NoContent(http.StatusNoContent)
}
if errors.Is(err, errInvalidAddress) {
return badRequestError(c, err)
}
return internalServerError(c, err)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/labstack/echo/v4"
)
type PriceHandler struct {
prices storage.IPrice
market storage.IMarket
}
func NewPriceHandler(prices storage.IPrice, market storage.IMarket) *PriceHandler {
return &PriceHandler{
prices: prices,
market: market,
}
}
var _ Handler = (*PriceHandler)(nil)
func (handler *PriceHandler) InitRoutes(srvr *echo.Group) {
price := srvr.Group("/price")
{
price.GET("", handler.List)
pair := price.Group("/:pair")
{
pair.GET("", handler.Last)
pair.GET("/:timeframe", handler.Series)
}
}
}
type priceListRequest struct {
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
}
func (p *priceListRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
}
// List godoc
//
// @Summary Get all currency pairs
// @Description Get all currency pairs
// @Tags price
// @ID list-markets
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.Market
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/price [get]
func (handler *PriceHandler) List(c echo.Context) error {
req, err := bindAndValidate[priceListRequest](c)
if err != nil {
return badRequestError(c, err)
}
markets, err := handler.market.List(c.Request().Context(), req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.prices)
}
response := make([]responses.Market, len(markets))
for i := range markets {
response[i] = responses.NewMarket(markets[i])
}
return returnArray(c, response)
}
type priceLastRequest struct {
Pair string `param:"pair" validate:"required"`
}
// Last godoc
//
// @Summary Get the latest price and market info
// @Description Get the latest price and market info
// @Tags price
// @ID get-market
// @Param pair path string true "Currency pair"
// @Produce json
// @Success 200 {object} responses.Market
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/price/:pair [get]
func (handler *PriceHandler) Last(c echo.Context) error {
req, err := bindAndValidate[priceLastRequest](c)
if err != nil {
return badRequestError(c, err)
}
market, err := handler.market.Get(c.Request().Context(), req.Pair)
if err != nil {
return handleError(c, err, handler.prices)
}
return c.JSON(http.StatusOK, responses.NewMarket(market))
}
type priceSeriesRequest struct {
Pair string `example:"BTC-USDT" param:"pair" swaggertype:"string" validate:"required"`
Timeframe storage.Timeframe `example:"day" param:"timeframe" swaggertype:"string" validate:"required,oneof=hour day"`
}
// Series godoc
//
// @Summary Get price series
// @Description Get price series
// @Tags price
// @ID get-price-series
// @Param pair path string true "Currency pair"
// @Param timeframe path string true "Timeframe" Enums(hour, day)
// @Produce json
// @Success 200 {array} responses.Candle
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/price/:pair/:timeframe [get]
func (handler *PriceHandler) Series(c echo.Context) error {
req, err := bindAndValidate[priceSeriesRequest](c)
if err != nil {
return badRequestError(c, err)
}
decimals, err := handler.market.Decimals(c.Request().Context(), req.Pair)
if err != nil {
return handleError(c, err, handler.prices)
}
prices, err := handler.prices.Series(c.Request().Context(), req.Pair, req.Timeframe)
if err != nil {
return handleError(c, err, handler.prices)
}
response := make([]responses.Candle, len(prices))
for i := range prices {
response[i] = responses.NewCandle(prices[i], decimals)
}
return returnArray(c, response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"strings"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/labstack/echo/v4"
)
const (
asc = "asc"
desc = "desc"
)
func bindAndValidate[T any](c echo.Context) (*T, error) {
req := new(T)
if err := c.Bind(req); err != nil {
return req, err
}
if err := c.Validate(req); err != nil {
return req, err
}
return req, nil
}
func pgSort(sort string) storage.SortOrder {
switch sort {
case asc:
return storage.SortOrderAsc
case desc:
return storage.SortOrderDesc
default:
return storage.SortOrderAsc
}
}
type StringArray []string
func (s *StringArray) UnmarshalParam(param string) error {
*s = StringArray(strings.Split(param, ","))
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/labstack/echo/v4"
)
func returnArray[T any](c echo.Context, arr []T) error {
if arr == nil {
return c.JSON(http.StatusOK, []any{})
}
return c.JSON(http.StatusOK, arr)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"encoding/hex"
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
)
type Action struct {
Id uint64 `example:"1" format:"int64" json:"id" swaggertype:"integer"`
Height pkgTypes.Level `example:"1000" format:"int64" json:"height" swaggertype:"integer"`
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:"rollup_data_submission" format:"string" json:"type" swaggertype:"string"`
TxHash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"binary" json:"tx_hash,omitempty" swaggertype:"string"`
Fee *Fee `json:"fee,omitempty"`
Data map[string]any `json:"data"`
}
type Fee struct {
Amount string `example:"1000" format:"string" json:"amount" swaggertype:"string"`
Asset string `example:"nria" format:"string" json:"asset" swaggertype:"string"`
}
func NewFee(fee *storage.Fee) *Fee {
if fee == nil {
return nil
}
return &Fee{
Amount: fee.Amount.String(),
Asset: fee.Asset,
}
}
func NewAction(action storage.Action) Action {
result := Action{
Id: action.Id,
Height: action.Height,
Time: action.Time,
Position: action.Position,
Type: action.Type,
Data: action.Data,
Fee: NewFee(action.Fee),
}
return result
}
func NewActionWithTx(action storage.ActionWithTx) Action {
result := Action{
Id: action.Id,
Height: action.Height,
Time: action.Time,
Position: action.Position,
Type: action.Type,
Data: action.Data,
Fee: NewFee(action.Fee),
}
if action.Tx != nil {
result.TxHash = hex.EncodeToString(action.Tx.Hash)
}
return result
}
func NewAddressAction(action storage.AddressAction) Action {
result := Action{
Id: action.ActionId,
Height: action.Height,
Time: action.Time,
Type: action.ActionType,
}
if action.Tx != nil {
result.TxHash = hex.EncodeToString(action.Tx.Hash)
}
if action.Action != nil {
result.Data = action.Action.Data
result.Position = action.Action.Position
result.Fee = NewFee(action.Action.Fee)
}
return result
}
func NewActionFromRollupAction(action storage.RollupAction) Action {
result := Action{
Id: action.ActionId,
Height: action.Height,
Time: action.Time,
Type: action.ActionType,
}
if action.Tx != nil {
result.TxHash = hex.EncodeToString(action.Tx.Hash)
}
if action.Action != nil {
result.Data = action.Action.Data
result.Position = action.Action.Position
result.Fee = NewFee(action.Action.Fee)
}
return result
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"github.com/celenium-io/astria-indexer/internal/storage"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
)
// Address model info
//
// @Description address information
type Address struct {
Id uint64 `example:"321" json:"id" swaggertype:"integer"`
Height pkgTypes.Level `example:"100" json:"first_height" swaggertype:"integer"`
ActionsCount int64 `example:"10" json:"actions_count" swaggertype:"integer"`
SignedTxCount int64 `example:"10" json:"signed_tx_count" swaggertype:"integer"`
Nonce uint32 `example:"10" json:"nonce" swaggertype:"integer"`
Hash string `example:"astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2" json:"hash" swaggertype:"string"`
IsBridge bool `example:"false" json:"is_bridge" swaggertype:"boolean"`
IsIbcRelayer bool `example:"false" json:"is_ibc_relayer" swaggertype:"boolean"`
IsSudo bool `example:"false" json:"is_sudo" swaggertype:"boolean"`
IsIbcSudo bool `example:"false" json:"is_ibc_sudo" swaggertype:"boolean"`
Balance []Balance `json:"balances"`
Bridge *Bridge `json:"bridge,omitempty"`
}
func NewAddress(addr storage.Address, bridge *storage.Bridge, sudoAddr, ibcSudoAddr string) Address {
result := Address{
Id: addr.Id,
Height: addr.Height,
ActionsCount: addr.ActionsCount,
SignedTxCount: addr.SignedTxCount,
Nonce: addr.Nonce,
IsBridge: addr.IsBridge,
Hash: addr.String(),
Balance: make([]Balance, 0),
}
result.IsSudo = sudoAddr == result.Hash
result.IsIbcSudo = ibcSudoAddr == result.Hash
for i := range addr.Balance {
result.Balance = append(result.Balance, Balance{
Currency: addr.Balance[i].Currency,
Value: addr.Balance[i].Total.String(),
})
}
if bridge != nil {
b := NewBridge(*bridge)
result.Bridge = &b
}
if addr.IsIbcRelayer != nil {
result.IsIbcRelayer = *addr.IsIbcRelayer
}
return result
}
// Balance info
//
// @Description Balance of address information
type Balance struct {
Currency string `example:"nria" json:"currency" swaggertype:"string"`
Value string `example:"10000000000" json:"value" swaggertype:"string"`
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"encoding/base64"
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
)
type AppWithStats struct {
Id uint64 `example:"321" format:"integer" json:"id" swaggertype:"integer"`
Name string `example:"Rollup name" format:"string" json:"name" swaggertype:"string"`
Description string `example:"Long rollup description" format:"string" json:"description,omitempty" swaggertype:"string"`
Website string `example:"https://website.com" format:"string" json:"website,omitempty" swaggertype:"string"`
Twitter string `example:"https://x.com/account" format:"string" json:"twitter,omitempty" swaggertype:"string"`
Github string `example:"https://github.com/account" format:"string" json:"github,omitempty" swaggertype:"string"`
Logo string `example:"https://some_link.com/image.png" format:"string" json:"logo,omitempty" swaggertype:"string"`
Slug string `example:"rollup_slug" format:"string" json:"slug" swaggertype:"string"`
L2Beat string `example:"https://l2beat.com/scaling/projects/karak" format:"string" json:"l2_beat,omitempty" swaggertype:"string"`
Explorer string `example:"https://explorer.karak.network/" format:"string" json:"explorer,omitempty" swaggertype:"string"`
Stack string `example:"op_stack" format:"string" json:"stack,omitempty" swaggertype:"string"`
Type string `example:"settled" format:"string" json:"type,omitempty" swaggertype:"string"`
Category string `example:"nft" format:"string" json:"category,omitempty" swaggertype:"string"`
VM string `example:"evm" format:"string" json:"vm,omitempty" swaggertype:"string"`
Provider string `example:"name" format:"string" json:"provider,omitempty" swaggertype:"string"`
NativeBridge string `example:"astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2" format:"string" json:"native_bridge" swaggertype:"string"`
Rollup string `example:"O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc=" format:"string" json:"rollup" swaggertype:"string"`
ActionsCount int64 `example:"2" format:"integer" json:"actions_count" swaggertype:"integer"`
Size int64 `example:"1000" format:"integer" json:"size" swaggertype:"integer"`
MinSize int64 `example:"1000" format:"integer" json:"min_size" swaggertype:"integer"`
MaxSize int64 `example:"1000" format:"integer" json:"max_size" swaggertype:"integer"`
AvgSize int64 `example:"1000" format:"integer" json:"avg_size" swaggertype:"integer"`
LastAction time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"last_message_time" swaggertype:"string"`
FirstAction time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"first_message_time" swaggertype:"string"`
Links []string `json:"links,omitempty"`
}
func NewAppWithStats(r storage.AppWithStats) AppWithStats {
app := AppWithStats{
Id: r.Id,
Name: r.Name,
Description: r.Description,
Github: r.Github,
Twitter: r.Twitter,
Website: r.Website,
Logo: r.Logo,
L2Beat: r.L2Beat,
Explorer: r.Explorer,
Links: r.Links,
Stack: r.Stack,
Slug: r.Slug,
ActionsCount: r.ActionsCount,
Size: r.Size,
MinSize: r.MinSize,
MaxSize: r.MaxSize,
AvgSize: int64(r.AvgSize),
LastAction: r.LastActionTime,
FirstAction: r.FirstActionTime,
Category: r.Category.String(),
Type: r.Type.String(),
Provider: r.Provider,
VM: r.VM,
}
if r.Rollup != nil {
app.Rollup = base64.StdEncoding.EncodeToString(r.Rollup.AstriaId)
}
if r.Bridge != nil {
app.NativeBridge = r.Bridge.Hash
}
return app
}
type App struct {
Id uint64 `example:"321" format:"integer" json:"id" swaggertype:"integer"`
Name string `example:"Rollup name" format:"string" json:"name" swaggertype:"string"`
Description string `example:"Long rollup description" format:"string" json:"description,omitempty" swaggertype:"string"`
Website string `example:"https://website.com" format:"string" json:"website,omitempty" swaggertype:"string"`
Twitter string `example:"https://x.com/account" format:"string" json:"twitter,omitempty" swaggertype:"string"`
Github string `example:"https://github.com/account" format:"string" json:"github,omitempty" swaggertype:"string"`
Logo string `example:"https://some_link.com/image.png" format:"string" json:"logo,omitempty" swaggertype:"string"`
Slug string `example:"rollup_slug" format:"string" json:"slug" swaggertype:"string"`
L2Beat string `example:"https://l2beat.com/scaling/projects/karak" format:"string" json:"l2_beat,omitempty" swaggertype:"string"`
Explorer string `example:"https://explorer.karak.network/" format:"string" json:"explorer,omitempty" swaggertype:"string"`
Stack string `example:"op_stack" format:"string" json:"stack,omitempty" swaggertype:"string"`
Type string `example:"settled" format:"string" json:"type,omitempty" swaggertype:"string"`
Category string `example:"nft" format:"string" json:"category,omitempty" swaggertype:"string"`
VM string `example:"evm" format:"string" json:"vm,omitempty" swaggertype:"string"`
Provider string `example:"name" format:"string" json:"provider,omitempty" swaggertype:"string"`
Links []string `json:"links,omitempty"`
}
func NewApp(r storage.App) App {
app := App{
Id: r.Id,
Name: r.Name,
Description: r.Description,
Github: r.Github,
Twitter: r.Twitter,
Website: r.Website,
Logo: r.Logo,
L2Beat: r.L2Beat,
Explorer: r.Explorer,
Links: r.Links,
Stack: r.Stack,
Slug: r.Slug,
Category: r.Category.String(),
Type: r.Type.String(),
Provider: r.Provider,
VM: r.VM,
}
return app
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import "github.com/celenium-io/astria-indexer/internal/storage"
type Asset struct {
Fee string `example:"1000" format:"string" json:"fee" swaggertype:"string"`
FeeCount int `example:"100" format:"number" json:"fee_count" swaggertype:"integer"`
Transferred string `example:"1000" format:"string" json:"transferred" swaggertype:"string"`
TransferCount int `example:"100" format:"number" json:"transfer_count" swaggertype:"integer"`
Asset string `example:"nria" format:"string" json:"asset" swaggertype:"string"`
Supply string `example:"1000" format:"string" json:"supply" swaggertype:"string"`
}
func NewAsset(asset storage.Asset) Asset {
return Asset{
Asset: asset.Asset,
Fee: asset.Fee.String(),
FeeCount: asset.FeeCount,
Transferred: asset.Transferred.String(),
TransferCount: asset.TransferCount,
Supply: asset.Supply.String(),
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"strconv"
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
)
type Block struct {
Id uint64 `example:"321" json:"id" swaggertype:"integer"`
Height uint64 `example:"100" json:"height" swaggertype:"integer"`
Time time.Time `example:"2023-07-04T03:10:57+00:00" json:"time" swaggertype:"string"`
VersionBlock string `example:"11" json:"version_block" swaggertype:"string"`
VersionApp string `example:"1" json:"version_app" swaggertype:"string"`
Hash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"hash" swaggertype:"string"`
ParentHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"parent_hash" swaggertype:"string"`
LastCommitHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"last_commit_hash" swaggertype:"string"`
DataHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"data_hash" swaggertype:"string"`
ValidatorsHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"validators_hash" swaggertype:"string"`
NextValidatorsHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"next_validators_hash" swaggertype:"string"`
ConsensusHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"consensus_hash" swaggertype:"string"`
AppHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"app_hash" swaggertype:"string"`
LastResultsHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"last_results_hash" swaggertype:"string"`
EvidenceHash pkgTypes.Hex `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" json:"evidence_hash" swaggertype:"string"`
ActionTypes []string `example:"rollup_data_submission,transfer" json:"action_types" swaggertype:"string"`
Proposer *ShortValidator `json:"proposer,omitempty"`
Stats *BlockStats `json:"stats,omitempty"`
}
func NewBlock(block storage.Block) Block {
result := Block{
Id: block.Id,
Height: uint64(block.Height),
Time: block.Time,
VersionBlock: strconv.FormatUint(block.VersionBlock, 10),
VersionApp: strconv.FormatUint(block.VersionApp, 10),
Hash: block.Hash,
ParentHash: block.ParentHash,
LastCommitHash: block.LastCommitHash,
DataHash: block.DataHash,
ValidatorsHash: block.ValidatorsHash,
NextValidatorsHash: block.NextValidatorsHash,
ConsensusHash: block.ConsensusHash,
AppHash: block.AppHash,
LastResultsHash: block.LastResultsHash,
EvidenceHash: block.EvidenceHash,
ActionTypes: types.NewActionTypeMaskBits(block.ActionTypes).Strings(),
}
result.Proposer = NewShortValidator(block.Proposer)
if block.Stats != nil {
result.Stats = NewBlockStats(block.Stats)
}
return result
}
type BlockStats struct {
TxCount int64 `example:"12" json:"tx_count" swaggertype:"integer"`
Fee string `example:"28347628346" json:"fee" swaggertype:"string"`
SupplyChange string `example:"8635234" json:"supply_change" swaggertype:"string"`
BlockTime uint64 `example:"12354" json:"block_time" swaggertype:"integer"`
BytesInBlock int64 `example:"1234" json:"bytes_in_block" swaggertype:"integer"`
}
func NewBlockStats(stats *storage.BlockStats) *BlockStats {
return &BlockStats{
TxCount: stats.TxCount,
Fee: stats.Fee.String(),
SupplyChange: stats.SupplyChange.String(),
BlockTime: stats.BlockTime,
BytesInBlock: stats.BytesInBlock,
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import "github.com/celenium-io/astria-indexer/internal/storage"
// Bridge model info
//
// @Description bridge account information
type Bridge struct {
Address string `example:"astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2" json:"address" swaggertype:"string"`
Rollup []byte `example:"O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc=" json:"rollup" swaggertype:"string"`
Sudo string `example:"astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2" json:"sudo,omitempty" swaggertype:"string"`
Withdrawer string `example:"astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2" json:"withdrawer,omitempty" swaggertype:"string"`
Asset string `example:"nria" json:"asset" swaggertype:"string"`
FeeAsset string `example:"nria" json:"fee_asset" swaggertype:"string"`
}
func NewBridge(b storage.Bridge) Bridge {
bridge := Bridge{
Asset: b.Asset,
FeeAsset: b.FeeAsset,
}
if b.Address != nil {
bridge.Address = b.Address.Hash
}
if b.Sudo != nil {
bridge.Sudo = b.Sudo.Hash
}
if b.Withdrawer != nil {
bridge.Withdrawer = b.Withdrawer.Hash
}
if b.Rollup != nil {
bridge.Rollup = b.Rollup.AstriaId
}
return bridge
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/shopspring/decimal"
)
type Constants struct {
Module map[string]Params `json:"module"`
}
type Params map[string]string
func roundCounstant(val string) string {
d, err := decimal.NewFromString(val)
if err != nil {
return val
}
return d.String()
}
func NewConstants(consts []storage.Constant) Constants {
response := Constants{
Module: make(map[string]Params),
}
for i := range consts {
if params, ok := response.Module[string(consts[i].Module)]; ok {
params[consts[i].Name] = roundCounstant(consts[i].Value)
} else {
response.Module[string(consts[i].Module)] = Params{
consts[i].Name: roundCounstant(consts[i].Value),
}
}
}
return response
}
type Enums struct {
Status []string `json:"status"`
ActionType []string `json:"action_type"`
}
func NewEnums() Enums {
return Enums{
Status: types.StatusNames(),
ActionType: types.ActionTypeNames(),
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"encoding/hex"
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
)
type Deposit struct {
Id uint64 `example:"321" format:"int64" json:"id" swaggertype:"integer"`
Height pkgTypes.Level `example:"100" format:"int64" json:"height" swaggertype:"integer"`
Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"`
Amount string `example:"1000" format:"string" json:"amount" swaggertype:"string"`
Asset string `example:"nria" format:"string" json:"asset" swaggertype:"string"`
DestinationChainAddress string `example:"0x8bAec8896775DDa83796eda3e7E67217b5E3C5dA" format:"string" json:"destination_chain_address" swaggertype:"string"`
TxHash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"binary" json:"tx_hash,omitempty" swaggertype:"string"`
Rollup []byte `example:"O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc=" format:"string" json:"rollup,omitempty" swaggertype:"string"`
Bridge string `example:"astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2" format:"string" json:"bridge,omitempty" swaggertype:"string"`
}
func NewDeposit(d storage.Deposit) Deposit {
deposit := Deposit{
Id: d.Id,
Height: d.Height,
Time: d.Time,
Amount: d.Amount.String(),
Asset: d.Asset,
DestinationChainAddress: d.DestinationChainAddress,
}
if d.Tx != nil {
deposit.TxHash = hex.EncodeToString(d.Tx.Hash)
}
if d.Rollup != nil {
deposit.Rollup = d.Rollup.AstriaId
}
if d.Bridge != nil && d.Bridge.Address != nil {
deposit.Bridge = d.Bridge.Address.Hash
}
return deposit
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"encoding/hex"
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
)
type FullFee struct {
Amount string `example:"1000" format:"string" json:"amount" swaggertype:"string"`
Asset string `example:"nria" format:"string" json:"asset" swaggertype:"string"`
Payer string `example:"astria1phym4uktjn6gjle226009ge7u82w0dgtszs8x2" format:"string" json:"payer,omitempty" swaggertype:"string"`
TxHash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"binary" json:"tx_hash,omitempty" swaggertype:"string"`
Height pkgTypes.Level `example:"100" format:"int64" json:"height" swaggertype:"integer"`
Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"`
}
func NewFullFee(fee storage.Fee) FullFee {
ff := FullFee{
Time: fee.Time,
Height: fee.Height,
Asset: fee.Asset,
Amount: fee.Amount.String(),
}
if fee.Payer != nil {
ff.Payer = fee.Payer.Hash
}
if fee.Tx != nil {
ff.TxHash = hex.EncodeToString(fee.Tx.Hash)
}
return ff
}
type TxFee struct {
Amount string `example:"1000" format:"string" json:"amount" swaggertype:"string"`
Asset string `example:"nria" format:"string" json:"asset" swaggertype:"string"`
}
func NewTxFee(fee storage.Fee) TxFee {
return TxFee{
Asset: fee.Asset,
Amount: fee.Amount.String(),
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/shopspring/decimal"
)
type Price struct {
Price string `example:"50.00" format:"string" json:"value" swaggertype:"string"`
Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"`
}
func NewPrice(price storage.Price) Price {
return Price{
Price: price.Price.String(),
Time: price.Time,
}
}
type Market struct {
Pair string `example:"BTC/USDT" format:"string" json:"pair" swaggertype:"string"`
Base string `example:"BTC" format:"string" json:"base" swaggertype:"string"`
Quote string `example:"USDT" format:"string" json:"quote" swaggertype:"string"`
Decimals int `example:"8" format:"integer" json:"decimals" swaggertype:"integer"`
Enabled bool `example:"true" format:"boolean" json:"enabled" swaggertype:"boolean"`
MinProviderCount int `example:"1" format:"integer" json:"min_provider_count" swaggertype:"integer"`
Price *Price `json:"price,omitempty"`
Providers []Provider `json:"providers,omitempty" swaggertype:"array,object"`
}
func NewMarket(market storage.Market) Market {
result := Market{
Pair: market.Pair,
Base: market.Base,
Quote: market.Quote,
Decimals: market.Decimals,
Enabled: market.Enabled,
MinProviderCount: market.MinProviderCount,
Providers: make([]Provider, len(market.Providers)),
}
if market.Price != nil {
result.Price = &Price{
Price: decimalPrice(market.Price.Price, market.Decimals),
Time: market.Price.Time,
}
}
for i := range market.Providers {
result.Providers[i] = NewProvider(market.Providers[i])
}
return result
}
func decimalPrice(price decimal.Decimal, decimals int) string {
dec := decimal.NewFromInt(10).Pow(decimal.NewFromInt(int64(-decimals)))
return price.Mul(dec).String()
}
type Provider struct {
Provider string `example:"binance" format:"string" json:"provider" swaggertype:"string"`
OffChainTicker string `example:"BTC/USDT" format:"string" json:"off_chain_ticker" swaggertype:"string"`
}
func NewProvider(provider *storage.MarketProvider) Provider {
return Provider{
Provider: provider.Provider,
OffChainTicker: provider.OffChainTicker,
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
)
type Rollup struct {
Id uint64 `example:"321" json:"id" swaggertype:"integer"`
FirstHeight types.Level `example:"100" json:"first_height" swaggertype:"integer"`
AstriaId []byte `example:"O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc=" json:"hash" swaggertype:"string"`
ActionsCount int64 `example:"101" json:"actions_count" swaggertype:"integer"`
BridgeCount int64 `example:"2" json:"bridge_count" swaggertype:"integer"`
Size int64 `example:"100" json:"size" swaggertype:"integer"`
App *AppWithStats `json:"app,omitempty"`
}
func NewRollup(rollup *storage.Rollup) Rollup {
r := Rollup{
Id: rollup.Id,
AstriaId: rollup.AstriaId,
FirstHeight: rollup.FirstHeight,
ActionsCount: rollup.ActionsCount,
BridgeCount: rollup.BridgeCount,
Size: rollup.Size,
}
return r
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"encoding/hex"
"github.com/celenium-io/astria-indexer/internal/storage"
)
type RollupAction struct {
Action
Rollup *Rollup `json:"rollup,omitempty"`
}
func NewRollupAction(action storage.RollupAction) RollupAction {
result := 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
}
return result
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
type SearchResult struct {
Value string `json:"value"`
Type string `json:"type"`
Body any `json:"body,omitempty"`
}
func NewSearchResult(value, typ string, body any) SearchResult {
return SearchResult{
Value: value,
Type: typ,
Body: body,
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"encoding/hex"
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/celenium-io/astria-indexer/internal/storage"
)
type State struct {
Id uint64 `example:"321" format:"int64" json:"id" swaggertype:"integer"`
Name string `example:"indexer" format:"string" json:"name" swaggertype:"string"`
ChainID string `example:"astria-dusk-7" format:"string" json:"chain_id" swaggertype:"string"`
LastHeight pkgTypes.Level `example:"100" format:"int64" json:"last_height" swaggertype:"integer"`
LastHash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"string" json:"hash" swaggertype:"string"`
LastTime time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"last_time" swaggertype:"string"`
TotalTx int64 `example:"23456" format:"int64" json:"total_tx" swaggertype:"integer"`
TotalAccounts int64 `example:"43" format:"int64" json:"total_accounts" swaggertype:"integer"`
TotalRollups int64 `example:"312" format:"int64" json:"total_rollups" swaggertype:"integer"`
TotalBridges int64 `example:"312" format:"int64" json:"total_bridges" swaggertype:"integer"`
TotalBytes int64 `example:"312" format:"int64" json:"total_bytes" swaggertype:"integer"`
TotalSupply string `example:"312" format:"string" json:"total_supply" swaggertype:"string"`
Synced bool `example:"true" format:"boolean" json:"synced" swaggertype:"boolean"`
}
func NewState(state storage.State) State {
return State{
Id: state.Id,
Name: state.Name,
ChainID: state.ChainId,
LastHeight: state.LastHeight,
LastHash: hex.EncodeToString(state.LastHash),
LastTime: state.LastTime,
TotalTx: state.TotalTx,
TotalAccounts: state.TotalAccounts,
TotalRollups: state.TotalRollups,
TotalBridges: state.TotalBridges,
TotalBytes: state.TotalBytes,
TotalSupply: state.TotalSupply.String(),
Synced: !state.LastTime.UTC().Add(2 * time.Minute).Before(time.Now().UTC()),
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
)
type SeriesItem struct {
Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"`
Value string `example:"0.17632" format:"string" json:"value" swaggertype:"string"`
Max string `example:"0.17632" format:"string" json:"max,omitempty" swaggertype:"string"`
Min string `example:"0.17632" format:"string" json:"min,omitempty" swaggertype:"string"`
}
func NewSeriesItem(item storage.SeriesItem) SeriesItem {
return SeriesItem{
Time: item.Time,
Value: item.Value,
Max: item.Max,
Min: item.Min,
}
}
type RollupSeriesItem struct {
Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"`
Value string `example:"0.17632" format:"string" json:"value" swaggertype:"string"`
}
func NewRollupSeriesItem(item storage.SeriesItem) RollupSeriesItem {
return RollupSeriesItem{
Time: item.Time,
Value: item.Value,
}
}
type NetworkSummary struct {
DataSize int64 `example:"1000000" format:"integer" json:"data_size"`
TxCount int64 `example:"100" format:"integer" json:"tx_count"`
BytesInBlock int64 `example:"1024" format:"integer" json:"bytes_in_block"`
TPS float64 `example:"0.17632" format:"number" json:"tps"`
BPS float64 `example:"0.17632" format:"number" json:"bps"`
RBPS float64 `example:"0.17632" format:"number" json:"rbps"`
BlockTime float64 `example:"2345" format:"number" json:"block_time"`
Fee string `example:"1012012" format:"string" json:"fee"`
Supply string `example:"1029129" format:"string" json:"supply"`
}
func NewNetworkSummary(summary storage.NetworkSummary) NetworkSummary {
return NetworkSummary{
DataSize: summary.DataSize,
TxCount: summary.TxCount,
BytesInBlock: summary.BytesInBlock,
TPS: summary.TPS,
BPS: summary.BPS,
RBPS: summary.RBPS,
BlockTime: summary.BlockTime,
Fee: summary.Fee.String(),
Supply: summary.Supply.String(),
}
}
type NetworkSummaryWithChange struct {
DataSize int64 `example:"1000000" format:"integer" json:"data_size"`
DataSizePct float64 `example:"17.632" format:"number" json:"data_size_pct"`
TxCount int64 `example:"100" format:"integer" json:"tx_count"`
TxCountPct float64 `example:"17.632" format:"number" json:"tx_count_pct"`
BytesInBlock int64 `example:"1024" format:"integer" json:"bytes_in_block"`
BytesInBlockPct float64 `example:"17.632" format:"number" json:"bytes_in_block_pct"`
TPS float64 `example:"0.17632" format:"number" json:"tps"`
TPSPct float64 `example:"17.632" format:"number" json:"tps_pct"`
BPS float64 `example:"0.17632" format:"number" json:"bps"`
BPSPct float64 `example:"17.632" format:"number" json:"bps_pct"`
RBPS float64 `example:"0.17632" format:"number" json:"rbps"`
RBPSPct float64 `example:"17.632" format:"number" json:"rbps_pct"`
BlockTime float64 `example:"2345" format:"number" json:"block_time"`
BlockTimePct float64 `example:"17.632" format:"number" json:"block_time_pct"`
}
func NewNetworkSummaryWithChange(summary storage.NetworkSummaryWithChange) NetworkSummaryWithChange {
return NetworkSummaryWithChange{
DataSize: summary.DataSize,
DataSizePct: summary.DataSizePct,
TxCount: summary.TxCount,
TxCountPct: summary.TxCountPct,
BytesInBlock: summary.BytesInBlock,
BytesInBlockPct: summary.BytesInBlockPct,
TPS: summary.TPS,
TPSPct: summary.TPSPct,
BPS: summary.BPS,
BPSPct: summary.BPSPct,
RBPS: summary.RBPS,
RBPSPct: summary.RBPSPct,
BlockTime: summary.BlockTime,
BlockTimePct: summary.BlockTimePct,
}
}
type FeeSummary struct {
Asset string `example:"nria" format:"string" json:"asset"`
Amount string `example:"1000000" format:"integer" json:"amount"`
MinAmount string `example:"1000000" format:"integer" json:"min_amount"`
MaxAmount string `example:"1000000" format:"integer" json:"max_amount"`
FeeCount int64 `example:"1000000" format:"integer" json:"fee_count"`
}
func NewFeeSummary(summary storage.FeeSummary) FeeSummary {
return FeeSummary{
Asset: summary.Asset,
Amount: summary.Amount,
MinAmount: summary.MinAmount,
MaxAmount: summary.MaxAmount,
FeeCount: summary.FeeCount,
}
}
type TokenTransferDistributionItem struct {
Asset string `example:"nria" format:"string" json:"asset"`
Amount string `example:"1000000" format:"integer" json:"amount"`
TransfersCount int64 `example:"1000000" format:"integer" json:"transfers_count"`
}
func NewTokenTransferDistributionItem(summary storage.TokenTransferDistributionItem) TokenTransferDistributionItem {
return TokenTransferDistributionItem{
Asset: summary.Asset,
Amount: summary.Amount,
TransfersCount: summary.TransfersCount,
}
}
type Candle struct {
Open string `example:"0.17632" format:"string" json:"open"`
Close string `example:"0.17632" format:"string" json:"close"`
High string `example:"0.17632" format:"string" json:"high"`
Low string `example:"0.17632" format:"string" json:"low"`
Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"`
}
func NewCandle(candle storage.Candle, decimals int) Candle {
return Candle{
Open: decimalPrice(candle.Open, decimals),
Close: decimalPrice(candle.Close, decimals),
High: decimalPrice(candle.High, decimals),
Low: decimalPrice(candle.Low, decimals),
Time: candle.Time,
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"encoding/hex"
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
)
type Tx struct {
Id uint64 `example:"321" format:"int64" json:"id" swaggertype:"integer"`
Height pkgTypes.Level `example:"100" format:"int64" json:"height" swaggertype:"integer"`
Position int64 `example:"11" format:"int64" json:"position" swaggertype:"integer"`
ActionsCount int64 `example:"1" format:"int64" json:"actions_count" swaggertype:"integer"`
Nonce uint32 `example:"1" format:"int64" json:"nonce" swaggertype:"integer"`
Hash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"binary" json:"hash" swaggertype:"string"`
Error string `example:"some error text" format:"string" json:"error,omitempty" swaggertype:"string"`
Codespace string `example:"sdk" format:"string" json:"codespace,omitempty" swaggertype:"string"`
Signature string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"string" json:"signature" swaggertype:"string"`
Signer string `example:"115F94D8C98FFD73FE65182611140F0EDC7C3C94" format:"string" json:"signer" swaggertype:"string"`
Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"`
Status types.Status `example:"success" format:"string" json:"status" swaggertype:"string"`
ActionTypes []string `example:"rollup_data_submission,transfer" format:"string" json:"action_types" swaggertype:"string"`
Actions []Action `json:"actions,omitempty"`
Fees []TxFee `json:"fees,omitempty"`
}
func NewTx(tx storage.Tx) Tx {
result := Tx{
Id: tx.Id,
Height: tx.Height,
Time: tx.Time,
Position: tx.Position,
ActionsCount: tx.ActionsCount,
Nonce: tx.Nonce,
Status: tx.Status,
Error: tx.Error,
Codespace: tx.Codespace,
Hash: hex.EncodeToString(tx.Hash),
Signature: hex.EncodeToString(tx.Signature),
Actions: make([]Action, len(tx.Actions)),
ActionTypes: types.NewActionTypeMaskBits(tx.ActionTypes).Strings(),
}
if tx.Signer != nil {
result.Signer = tx.Signer.String()
}
for i := range tx.Actions {
result.Actions[i] = NewAction(tx.Actions[i])
}
return result
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"encoding/hex"
"fmt"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
)
type ShortValidator struct {
Id uint64 `example:"321" json:"id" swaggertype:"integer"`
ConsAddress string `example:"E641C7A2C964833E556AEF934FBF166B712874B6" json:"address" swaggertype:"string"`
Name string `example:"Node0" json:"name" swaggertype:"string"`
}
func NewShortValidator(val *storage.Validator) *ShortValidator {
if val == nil || val.Id == 0 { // for genesis block
return nil
}
return &ShortValidator{
Id: val.Id,
ConsAddress: val.Address,
Name: val.Name,
}
}
type Validator struct {
Id uint64 `example:"321" json:"id" swaggertype:"integer"`
ConsAddress string `example:"E641C7A2C964833E556AEF934FBF166B712874B6" json:"address" swaggertype:"string"`
Name string `example:"Node0" json:"name" swaggertype:"string"`
PubkeyType string `example:"tendermint/PubKeyEd25519" json:"pubkey_type" swaggertype:"string"`
Pubkey string `example:"a497aa4a22ca8232876082920b110678988c86194b0c2e12a04dcf6f53688bb2" json:"pubkey" swaggertype:"string"`
Power string `example:"100" json:"power" swaggertype:"string"`
}
func NewValidator(val *storage.Validator) *Validator {
if val == nil || val.Id == 0 { // for genesis block
return nil
}
return &Validator{
Id: val.Id,
ConsAddress: val.Address,
Name: val.Name,
PubkeyType: val.PubkeyType,
Pubkey: hex.EncodeToString(val.PubKey),
Power: val.Power.String(),
}
}
type ValidatorUptime struct {
Uptime string `example:"0.97" json:"uptime" swaggertype:"string"`
Blocks []SignedBlocks `json:"blocks"`
}
type SignedBlocks struct {
Height types.Level `example:"100" json:"height" swaggertype:"integer"`
Signed bool `example:"true" json:"signed" swaggertype:"boolean"`
}
func NewValidatorUptime(levels []types.Level, currentLevel types.Level, count types.Level) (uptime ValidatorUptime) {
var (
levelIndex = 0
blockIndex = 0
threshold = count
)
if threshold > currentLevel {
threshold = currentLevel
}
uptime.Blocks = make([]SignedBlocks, threshold)
for i := currentLevel; i > currentLevel-threshold; i-- {
if levelIndex < len(levels) && levels[levelIndex] == i {
levelIndex++
uptime.Blocks[blockIndex] = SignedBlocks{
Signed: true,
Height: i,
}
} else {
uptime.Blocks[blockIndex] = SignedBlocks{
Signed: false,
Height: i,
}
}
blockIndex++
}
uptime.Uptime = fmt.Sprintf("%.4f", float64(levelIndex)/float64(threshold))
return uptime
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"encoding/base64"
"net/http"
"time"
"github.com/celenium-io/astria-indexer/cmd/api/cache"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
testsuite "github.com/celenium-io/astria-indexer/internal/test_suite"
"github.com/labstack/echo/v4"
)
type RollupHandler struct {
constantCache *cache.ConstantsCache
rollups storage.IRollup
actions storage.IAction
bridge storage.IBridge
deposits storage.IDeposit
app storage.IApp
state storage.IState
indexerName string
}
func NewRollupHandler(
constantCache *cache.ConstantsCache,
rollups storage.IRollup,
actions storage.IAction,
bridge storage.IBridge,
deposits storage.IDeposit,
app storage.IApp,
state storage.IState,
indexerName string,
) *RollupHandler {
return &RollupHandler{
constantCache: constantCache,
rollups: rollups,
actions: actions,
bridge: bridge,
deposits: deposits,
app: app,
state: state,
indexerName: indexerName,
}
}
var _ Handler = (*RollupHandler)(nil)
func (handler *RollupHandler) InitRoutes(srvr *echo.Group) {
rollupsGroup := srvr.Group("/rollup")
{
rollupsGroup.GET("", handler.List)
rollupsGroup.GET("/count", handler.Count)
rollupGroup := rollupsGroup.Group("/:hash")
{
rollupGroup.GET("", handler.Get)
rollupGroup.GET("/actions", handler.Actions)
rollupGroup.GET("/all_actions", handler.AllActions)
rollupGroup.GET("/addresses", handler.Addresses)
rollupGroup.GET("/bridges", handler.Bridges)
rollupGroup.GET("/deposits", handler.Deposits)
}
}
}
type getRollupRequest struct {
Hash string `param:"hash" validate:"required,base64url"`
}
// Get godoc
//
// @Summary Get rollup info
// @Description Get rollup info
// @Tags rollup
// @ID get-rollup
// @Param hash path string true "Base64Url encoded rollup id"
// @Produce json
// @Success 200 {object} responses.Rollup
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/rollup/{hash} [get]
func (handler *RollupHandler) Get(c echo.Context) error {
req, err := bindAndValidate[getRollupRequest](c)
if err != nil {
return badRequestError(c, err)
}
hash, err := base64.URLEncoding.DecodeString(req.Hash)
if err != nil {
return handleError(c, err, handler.rollups)
}
rollup, err := handler.rollups.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.rollups)
}
response := responses.NewRollup(&rollup)
if app, err := handler.app.ByRollupId(c.Request().Context(), rollup.Id); err != nil {
if !handler.app.IsNoRows(err) {
return handleError(c, err, handler.rollups)
}
} else {
appResp := responses.NewAppWithStats(app)
response.App = &appResp
}
return c.JSON(http.StatusOK, response)
}
type listRollupsRequest struct {
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
SortField string `query:"sort_by" validate:"omitempty,oneof=size id"`
}
func (p *listRollupsRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = desc
}
}
// List godoc
//
// @Summary List rollups info
// @Description List rollups info
// @Tags rollup
// @ID list-rollups
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Param sort_by query string false "Field using for sorting. Default: id" Enums(id, size)
// @Produce json
// @Success 200 {array} responses.Rollup
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/rollup [get]
func (handler *RollupHandler) List(c echo.Context) error {
req, err := bindAndValidate[listRollupsRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
fltrs := storage.RollupListFilter{
Limit: req.Limit,
Offset: req.Offset,
SortOrder: pgSort(req.Sort),
SortField: req.SortField,
}
rollups, err := handler.rollups.ListExt(c.Request().Context(), fltrs)
if err != nil {
return handleError(c, err, handler.rollups)
}
response := make([]responses.Rollup, len(rollups))
for i := range rollups {
response[i] = responses.NewRollup(&rollups[i])
}
return returnArray(c, response)
}
type getRollupList struct {
Hash string `param:"hash" validate:"required,base64url"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
}
func (p *getRollupList) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
}
// Actions godoc
//
// @Summary Get rollup actions
// @Description Get rollup actions
// @Tags rollup
// @ID rollup-actions
// @Param hash path string true "Base64Url encoded rollup id"
// @Param limit query integer false "Count of requested entities" minimum(1) maximum(100)
// @Param offset query integer false "Offset" minimum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Produce json
// @Success 200 {array} responses.RollupAction
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/rollup/{hash}/actions [get]
func (handler *RollupHandler) Actions(c echo.Context) error {
req, err := bindAndValidate[getRollupList](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
hash, err := base64.URLEncoding.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
rollup, err := handler.rollups.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.rollups)
}
actions, err := handler.actions.ByRollup(c.Request().Context(), rollup.Id, req.Limit, req.Offset, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.rollups)
}
response := make([]responses.RollupAction, len(actions))
for i := range actions {
response[i] = responses.NewRollupAction(actions[i])
}
return returnArray(c, response)
}
// Count godoc
//
// @Summary Get count of rollups in network
// @Description Get count of rollups in network
// @Tags rollup
// @ID get-rollup-count
// @Produce json
// @Success 200 {integer} uint64
// @Failure 500 {object} Error
// @Router /v1/rollup/count [get]
func (handler *RollupHandler) Count(c echo.Context) error {
state, err := handler.state.ByName(c.Request().Context(), handler.indexerName)
if err != nil {
return handleError(c, err, handler.rollups)
}
return c.JSON(http.StatusOK, state.TotalRollups)
}
// Addresses godoc
//
// @Summary List addresses which pushed something in the rollup
// @Description List addresses which pushed something in the rollup
// @Tags rollup
// @ID get-rollup-addresses
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Produce json
// @Success 200 {array} responses.Address
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/rollup/{hash}/addresses [get]
func (handler *RollupHandler) Addresses(c echo.Context) error {
req, err := bindAndValidate[getRollupList](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
hash, err := base64.URLEncoding.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
rollup, err := handler.rollups.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.rollups)
}
addresses, err := handler.rollups.Addresses(c.Request().Context(), rollup.Id, req.Limit, req.Offset, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.rollups)
}
response := make([]responses.Address, len(addresses))
for i := range addresses {
if addresses[i].Address != nil {
sudoAddress, _ := handler.constantCache.Get(types.ModuleNameGeneric, "authority_sudo_address")
ibcSudoAddress, _ := handler.constantCache.Get(types.ModuleNameGeneric, "ibc_sudo_address")
response[i] = responses.NewAddress(*addresses[i].Address, nil, sudoAddress, ibcSudoAddress)
}
}
return returnArray(c, response)
}
// Bridges godoc
//
// @Summary Get rollup bridges
// @Description Get rollup bridges
// @Tags rollup
// @ID rollup-bridges
// @Param hash path string true "Base64Url encoded rollup id"
// @Param limit query integer false "Count of requested entities" minimum(1) maximum(100)
// @Param offset query integer false "Offset" minimum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Produce json
// @Success 200 {array} responses.Bridge
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/rollup/{hash}/bridges [get]
func (handler *RollupHandler) Bridges(c echo.Context) error {
req, err := bindAndValidate[getRollupList](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
hash, err := base64.URLEncoding.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
rollup, err := handler.rollups.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.rollups)
}
bridges, err := handler.bridge.ByRollup(c.Request().Context(), rollup.Id, req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.rollups)
}
response := make([]responses.Bridge, len(bridges))
for i := range bridges {
response[i] = responses.NewBridge(bridges[i])
}
return returnArray(c, response)
}
type allRollupActionsRequest struct {
Hash string `param:"hash" validate:"required,base64url"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
RollupActions *bool `query:"rollup_actions" validate:"omitempty"`
BridgeActions *bool `query:"bridge_actions" validate:"omitempty"`
ActionTypes StringArray `query:"action_types" validate:"omitempty,dive,action_type"`
From int64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To int64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
}
func (p *allRollupActionsRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
if p.BridgeActions == nil {
p.BridgeActions = testsuite.Ptr(true)
}
if p.RollupActions == nil {
p.RollupActions = testsuite.Ptr(true)
}
}
func (p *allRollupActionsRequest) toDbRequest() storage.RollupAndBridgeActionsFilter {
fltrs := storage.RollupAndBridgeActionsFilter{
Limit: p.Limit,
Offset: p.Offset,
Sort: pgSort(p.Sort),
RollupActions: *p.RollupActions,
BridgeActions: *p.BridgeActions,
ActionTypes: types.NewActionTypeMask(),
}
if p.From > 0 {
fltrs.From = time.Unix(p.From, 0).UTC()
}
if p.To > 0 {
fltrs.To = time.Unix(p.To, 0).UTC()
}
for i := range p.ActionTypes {
fltrs.ActionTypes.SetType(types.ActionType(p.ActionTypes[i]))
}
return fltrs
}
// AllActions godoc
//
// @Summary Get rollup actions with actions of all connected bridges
// @Description Get rollup actions with actions of all connected bridges
// @Tags rollup
// @ID rollup-all-actions
// @Param hash path string true "Base64Url encoded rollup id"
// @Param limit query integer false "Count of requested entities" minimum(1) maximum(100)
// @Param offset query integer false "Offset" minimum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Param rollup_actions query boolean false "If true join rollup actions. Default: true"
// @Param bridge_actions query boolean false "If true join brigde actions. Default: true"
// @Param action_types query types.ActionType false "Comma-separated action types list"
// @Param from query integer false "Time from in unix timestamp" mininum(1)
// @Param to query integer false "Time to in unix timestamp" mininum(1)
// @Produce json
// @Success 200 {array} responses.Action
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/rollup/{hash}/all_actions [get]
func (handler *RollupHandler) AllActions(c echo.Context) error {
req, err := bindAndValidate[allRollupActionsRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
hash, err := base64.URLEncoding.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
rollup, err := handler.rollups.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.rollups)
}
actions, err := handler.actions.ByRollupAndBridge(c.Request().Context(), rollup.Id, req.toDbRequest())
if err != nil {
return handleError(c, err, handler.rollups)
}
response := make([]responses.Action, len(actions))
for i := range actions {
response[i] = responses.NewActionWithTx(actions[i])
}
return returnArray(c, response)
}
type getRollupDeposits struct {
Hash string `param:"hash" validate:"required,base64url"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
}
func (p *getRollupDeposits) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = desc
}
}
// Deposits godoc
//
// @Summary Get rollup deposits
// @Description Get rollup deposits
// @Tags rollup
// @ID get-rollup-deposits
// @Param hash path string true "Base64Url encoded rollup id"
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Produce json
// @Success 200 {array} responses.Deposit
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/rollup/{hash}/deposits [get]
func (handler *RollupHandler) Deposits(c echo.Context) error {
req, err := bindAndValidate[getRollupDeposits](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
hash, err := base64.URLEncoding.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
rollup, err := handler.rollups.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.rollups)
}
deposits, err := handler.deposits.ByRollupId(c.Request().Context(), rollup.Id, req.Limit, req.Offset, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.rollups)
}
response := make([]responses.Deposit, len(deposits))
for i := range deposits {
response[i] = responses.NewDeposit(deposits[i])
}
return returnArray(c, response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"github.com/celenium-io/astria-indexer/cmd/api/cache"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/labstack/echo/v4"
)
type SearchHandler struct {
constantCache *cache.ConstantsCache
search storage.ISearch
address storage.IAddress
blocks storage.IBlock
txs storage.ITx
rollups storage.IRollup
bridges storage.IBridge
validators storage.IValidator
app storage.IApp
}
func NewSearchHandler(
constantCache *cache.ConstantsCache,
search storage.ISearch,
address storage.IAddress,
blocks storage.IBlock,
txs storage.ITx,
rollups storage.IRollup,
bridges storage.IBridge,
validators storage.IValidator,
app storage.IApp,
) *SearchHandler {
return &SearchHandler{
constantCache: constantCache,
search: search,
address: address,
blocks: blocks,
txs: txs,
rollups: rollups,
bridges: bridges,
validators: validators,
app: app,
}
}
var _ Handler = (*SearchHandler)(nil)
func (s *SearchHandler) InitRoutes(srvr *echo.Group) {
srvr.GET("/search", s.Search)
}
type searchRequest struct {
Search string `query:"query" validate:"required"`
}
// Search godoc
//
// @Summary Search by hash or text
// @Tags search
// @ID search
// @Param query query string true "Search string"
// @Produce json
// @Success 200 {array} responses.SearchResult
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/search [get]
func (s *SearchHandler) Search(c echo.Context) error {
req, err := bindAndValidate[searchRequest](c)
if err != nil {
return badRequestError(c, err)
}
results, err := s.search.Search(c.Request().Context(), req.Search)
if err != nil {
return handleError(c, err, s.address)
}
response := make([]responses.SearchResult, len(results))
for i := range results {
var body any
switch results[i].Type {
case "block":
block, err := s.blocks.GetByID(c.Request().Context(), results[i].Id)
if err != nil {
return handleError(c, err, s.address)
}
body = responses.NewBlock(*block)
case "tx":
tx, err := s.txs.GetByID(c.Request().Context(), results[i].Id)
if err != nil {
return handleError(c, err, s.address)
}
body = responses.NewTx(*tx)
case "rollup":
rollup, err := s.rollups.GetByID(c.Request().Context(), results[i].Id)
if err != nil {
return handleError(c, err, s.address)
}
body = responses.NewRollup(rollup)
case "address":
address, err := s.address.GetByID(c.Request().Context(), results[i].Id)
if err != nil {
return handleError(c, err, s.address)
}
sudoAddress, _ := s.constantCache.Get(types.ModuleNameGeneric, "authority_sudo_address")
ibcSudoAddress, _ := s.constantCache.Get(types.ModuleNameGeneric, "ibc_sudo_address")
body = responses.NewAddress(*address, nil, sudoAddress, ibcSudoAddress)
case "validator":
validator, err := s.validators.GetByID(c.Request().Context(), results[i].Id)
if err != nil {
return handleError(c, err, s.address)
}
body = responses.NewShortValidator(validator)
case "bridge":
bridge, err := s.bridges.ById(c.Request().Context(), results[i].Id)
if err != nil {
return handleError(c, err, s.address)
}
body = responses.NewBridge(bridge)
case "app":
app, err := s.app.GetByID(c.Request().Context(), results[i].Id)
if err != nil {
return handleError(c, err, s.address)
}
body = responses.NewApp(*app)
}
response[i] = responses.NewSearchResult(results[i].Value, results[i].Type, body)
}
return returnArray(c, response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/labstack/echo/v4"
)
type StateHandler struct {
state storage.IState
}
func NewStateHandler(state storage.IState) *StateHandler {
return &StateHandler{
state: state,
}
}
var _ Handler = (*StateHandler)(nil)
func (sh *StateHandler) InitRoutes(srvr *echo.Group) {
srvr.GET("/head", sh.Head)
}
// Head godoc
//
// @Summary Get current indexer head
// @Description Get current indexer head
// @Tags general
// @ID head
// @Produce json
// @Success 200 {object} responses.State
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/head [get]
func (sh *StateHandler) Head(c echo.Context) error {
state, err := sh.state.List(c.Request().Context(), 1, 0, sdk.SortOrderAsc)
if err != nil {
return handleError(c, err, sh.state)
}
if len(state) == 0 {
return c.NoContent(http.StatusNoContent)
}
return c.JSON(http.StatusOK, responses.NewState(*state[0]))
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"encoding/base64"
"net/http"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/labstack/echo/v4"
)
type StatsHandler struct {
repo storage.IStats
rollups storage.IRollup
}
func NewStatsHandler(repo storage.IStats, rollups storage.IRollup) *StatsHandler {
return &StatsHandler{
repo: repo,
rollups: rollups,
}
}
var _ Handler = (*StatsHandler)(nil)
func (sh *StatsHandler) InitRoutes(srvr *echo.Group) {
stats := srvr.Group("/stats")
{
stats.GET("/summary", sh.Summary)
stats.GET("/summary/:timeframe", sh.SummaryTimeframe)
stats.GET("/summary/active_addresses_count", sh.ActiveAddressesCount)
stats.GET("/series/:name/:timeframe", sh.Series)
rollup := stats.Group("/rollup")
{
rollup.GET("/series/:hash/:name/:timeframe", sh.RollupSeries)
}
fee := stats.Group("/fee")
{
fee.GET("/summary", sh.FeeSummary)
}
token := stats.Group("/token")
{
token.GET("/transfer_distribution", sh.TokenTransferDistribution)
}
}
}
// Summary godoc
//
// @Summary Get network summary
// @Description Get network summary
// @Tags stats
// @ID stats-summary
// @Produce json
// @Success 200 {array} responses.NetworkSummary
// @Failure 500 {object} Error
// @Router /v1/stats/summary [get]
func (sh *StatsHandler) Summary(c echo.Context) error {
summary, err := sh.repo.Summary(c.Request().Context())
if err != nil {
return handleError(c, err, sh.rollups)
}
return c.JSON(http.StatusOK, responses.NewNetworkSummary(summary))
}
type summaryTimeframeRequest struct {
Timeframe storage.Timeframe `example:"day" param:"timeframe" swaggertype:"string" validate:"required,oneof=day week month"`
}
// SummaryTimeframe godoc
//
// @Summary Get network summary for the last period
// @Description Get network summary for the last period
// @Tags stats
// @ID stats-summary-timeframe
// @Param timeframe path string true "Timeframe" Enums(day, week, month)
// @Produce json
// @Success 200 {array} responses.NetworkSummaryWithChange
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/stats/summary/{timeframe} [get]
func (sh *StatsHandler) SummaryTimeframe(c echo.Context) error {
req, err := bindAndValidate[summaryTimeframeRequest](c)
if err != nil {
return badRequestError(c, err)
}
summary, err := sh.repo.SummaryTimeframe(c.Request().Context(), req.Timeframe)
if err != nil {
return handleError(c, err, sh.rollups)
}
return c.JSON(http.StatusOK, responses.NewNetworkSummaryWithChange(summary))
}
type seriesRequest struct {
Timeframe string `example:"hour" param:"timeframe" swaggertype:"string" validate:"required,oneof=hour day month"`
SeriesName string `example:"tps" param:"name" swaggertype:"string" validate:"required,oneof=data_size tps bps rbps fee supply_change block_time tx_count bytes_in_block"`
From int64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To int64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
}
// Series godoc
//
// @Summary Get histogram with precomputed stats
// @Description Get histogram with precomputed stats by series name and timeframe
// @Tags stats
// @ID stats-series
// @Param timeframe path string true "Timeframe" Enums(hour, day, month)
// @Param name path string true "Series name" Enums(data_size, tps, bps, rbps, fee, supply_change, block_time, tx_count, bytes_in_block)
// @Param from query integer false "Time from in unix timestamp" mininum(1)
// @Param to query integer false "Time to in unix timestamp" mininum(1)
// @Produce json
// @Success 200 {array} responses.SeriesItem
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/stats/series/{name}/{timeframe} [get]
func (sh *StatsHandler) Series(c echo.Context) error {
req, err := bindAndValidate[seriesRequest](c)
if err != nil {
return badRequestError(c, err)
}
histogram, err := sh.repo.Series(
c.Request().Context(),
storage.Timeframe(req.Timeframe),
req.SeriesName,
storage.NewSeriesRequest(req.From, req.To),
)
if err != nil {
return handleError(c, err, sh.rollups)
}
response := make([]responses.SeriesItem, len(histogram))
for i := range histogram {
response[i] = responses.NewSeriesItem(histogram[i])
}
return returnArray(c, response)
}
type rollupSeriesRequest struct {
Hash string `example:"O0Ia+lPYYMf3iFfxBaWXCSdlhphc6d4ZoBXINov6Tjc=" param:"hash" swaggertype:"string" validate:"required,base64url"`
Timeframe string `example:"hour" param:"timeframe" swaggertype:"string" validate:"required,oneof=hour day month"`
SeriesName string `example:"size" param:"name" swaggertype:"string" validate:"required,oneof=size avg_size min_size max_size actions_count"`
From int64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To int64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
}
// RollupSeries godoc
//
// @Summary Get histogram with precomputed rollup stats
// @Description Get histogram with precomputed rollup by series name and timeframe
// @Tags stats
// @ID stats-rollup-series
// @Param hash path string true "Base64Url encoded rollup id"
// @Param timeframe path string true "Timeframe" Enums(hour, day, month)
// @Param name path string true "Series name" Enums(size, avg_size, min_size, max_size, actions_count)
// @Param from query integer false "Time from in unix timestamp" mininum(1)
// @Param to query integer false "Time to in unix timestamp" mininum(1)
// @Produce json
// @Success 200 {array} responses.RollupSeriesItem
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/stats/rollup/series/{hash}/{name}/{timeframe} [get]
func (sh *StatsHandler) RollupSeries(c echo.Context) error {
req, err := bindAndValidate[rollupSeriesRequest](c)
if err != nil {
return badRequestError(c, err)
}
hash, err := base64.URLEncoding.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
rollup, err := sh.rollups.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, sh.rollups)
}
histogram, err := sh.repo.RollupSeries(
c.Request().Context(),
rollup.Id,
storage.Timeframe(req.Timeframe),
req.SeriesName,
storage.NewSeriesRequest(req.From, req.To),
)
if err != nil {
return handleError(c, err, sh.rollups)
}
response := make([]responses.RollupSeriesItem, len(histogram))
for i := range histogram {
response[i] = responses.NewRollupSeriesItem(histogram[i])
}
return returnArray(c, response)
}
// FeeSummary godoc
//
// @Summary Get fee summary
// @Description Get fee summary
// @Tags stats
// @ID stats-fee-summary
// @Produce json
// @Success 200 {array} responses.FeeSummary
// @Failure 500 {object} Error
// @Router /v1/stats/fee/summary [get]
func (sh *StatsHandler) FeeSummary(c echo.Context) error {
summary, err := sh.repo.FeeSummary(c.Request().Context())
if err != nil {
return handleError(c, err, sh.rollups)
}
response := make([]responses.FeeSummary, len(summary))
for i := range summary {
response[i] = responses.NewFeeSummary(summary[i])
}
return c.JSON(http.StatusOK, response)
}
type tokenTransferDistributionRequest struct {
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
}
func (p *tokenTransferDistributionRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
}
// TokenTransferDistribution godoc
//
// @Summary Token transfer distribution
// @Description Token transfer distribution
// @Tags stats
// @ID stats-token-transfer-distribution
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Produce json
// @Success 200 {array} responses.TokenTransferDistributionItem
// @Failure 500 {object} Error
// @Router /v1/stats/token/transfer_distribution [get]
func (sh *StatsHandler) TokenTransferDistribution(c echo.Context) error {
req, err := bindAndValidate[tokenTransferDistributionRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
items, err := sh.repo.TokenTransferDistribution(c.Request().Context(), int(req.Limit))
if err != nil {
return handleError(c, err, sh.rollups)
}
response := make([]responses.TokenTransferDistributionItem, len(items))
for i := range items {
response[i] = responses.NewTokenTransferDistributionItem(items[i])
}
return c.JSON(http.StatusOK, response)
}
// ActiveAddressesCount godoc
//
// @Summary Active adddresses count
// @Description Active adddresses count
// @Tags stats
// @ID stats-active-addresses-count
// @Produce json
// @Success 200 {integer} int64
// @Failure 500 {object} Error
// @Router /v1/stats/summary/active_addresses_count [get]
func (sh *StatsHandler) ActiveAddressesCount(c echo.Context) error {
count, err := sh.repo.ActiveAddressesCount(c.Request().Context())
if err != nil {
return handleError(c, err, sh.rollups)
}
return c.JSON(http.StatusOK, count)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"encoding/hex"
"net/http"
"time"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/labstack/echo/v4"
)
type TxHandler struct {
tx storage.ITx
actions storage.IAction
rollups storage.IRollup
fees storage.IFee
state storage.IState
indexerName string
}
func NewTxHandler(
tx storage.ITx,
actions storage.IAction,
rollups storage.IRollup,
fees storage.IFee,
state storage.IState,
indexerName string,
) *TxHandler {
return &TxHandler{
tx: tx,
actions: actions,
rollups: rollups,
fees: fees,
state: state,
indexerName: indexerName,
}
}
var _ Handler = (*TxHandler)(nil)
func (handler *TxHandler) InitRoutes(srvr *echo.Group) {
txGroup := srvr.Group("/tx")
{
txGroup.GET("", handler.List)
txGroup.GET("/count", handler.Count)
hashGroup := txGroup.Group("/:hash")
{
hashGroup.GET("", handler.Get)
hashGroup.GET("/actions", handler.GetActions)
hashGroup.GET("/fees", handler.GetFees)
hashGroup.GET("/rollup_actions", handler.RollupActions)
hashGroup.GET("/rollup_actions/count", handler.RollupActionsCount)
}
}
}
type getTxRequest struct {
Hash string `param:"hash" validate:"required,hexadecimal,len=64"`
Fee bool `query:"fee" validate:"omitempty"`
}
// Get godoc
//
// @Summary Get transaction by hash
// @Description Get transaction by hash
// @Tags transactions
// @ID get-transaction
// @Param hash path string true "Transaction hash in hexadecimal" minlength(64) maxlength(64)
// @Param fee query boolean false "Flag which indicates need join full transaction fees"
// @Produce json
// @Success 200 {object} responses.Tx
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/tx/{hash} [get]
func (handler *TxHandler) Get(c echo.Context) error {
req, err := bindAndValidate[getTxRequest](c)
if err != nil {
return badRequestError(c, err)
}
hash, err := hex.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
tx, err := handler.tx.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.tx)
}
response := responses.NewTx(tx)
if req.Fee {
fees, err := handler.fees.FullTxFee(c.Request().Context(), tx.Id)
if err != nil {
return handleError(c, err, handler.tx)
}
response.Fees = make([]responses.TxFee, len(fees))
for i := range fees {
response.Fees[i] = responses.NewTxFee(fees[i])
}
}
return c.JSON(http.StatusOK, response)
}
type txListRequest struct {
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
Height uint64 `query:"height" validate:"omitempty,min=1"`
Status StringArray `query:"status" validate:"omitempty,dive,status"`
ActionTypes StringArray `query:"action_types" validate:"omitempty,dive,action_type"`
WithActions bool `query:"with_actions" validate:"omitempty"`
From int64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To int64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
}
func (p *txListRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
}
// List godoc
//
// @Summary List transactions info
// @Description List transactions info
// @Tags transactions
// @ID list-transactions
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Param status query types.Status false "Comma-separated status list"
// @Param action_types query types.ActionType false "Comma-separated action types list"
// @Param from query integer false "Time from in unix timestamp" mininum(1)
// @Param to query integer false "Time to in unix timestamp" mininum(1)
// @Param height query integer false "Block number" mininum(1)
// @Param messages query boolean false "If true join actions" mininum(1)
// @Produce json
// @Success 200 {array} responses.Tx
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/tx [get]
func (handler *TxHandler) List(c echo.Context) error {
req, err := bindAndValidate[txListRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
fltrs := storage.TxFilter{
Limit: int(req.Limit),
Offset: int(req.Offset),
Sort: pgSort(req.Sort),
Status: req.Status,
Height: req.Height,
ActionTypes: types.NewActionTypeMask(),
WithActions: req.WithActions,
}
if req.From > 0 {
fltrs.TimeFrom = time.Unix(req.From, 0).UTC()
}
if req.To > 0 {
fltrs.TimeTo = time.Unix(req.To, 0).UTC()
}
for i := range req.ActionTypes {
fltrs.ActionTypes.SetType(types.ActionType(req.ActionTypes[i]))
}
txs, err := handler.tx.Filter(c.Request().Context(), fltrs)
if err != nil {
return handleError(c, err, handler.tx)
}
response := make([]responses.Tx, len(txs))
for i := range txs {
response[i] = responses.NewTx(txs[i])
}
return returnArray(c, response)
}
type txRequestWithPagination struct {
Hash string `param:"hash" validate:"required,hexadecimal,len=64"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
}
func (p *txRequestWithPagination) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
}
// GetActions godoc
//
// @Summary Get transaction actions
// @Description Get transaction actions
// @Tags transactions
// @ID get-transaction-actions
// @Param hash path string true "Transaction hash in hexadecimal" minlength(64) maxlength(64)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.Action
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/tx/{hash}/actions [get]
func (handler *TxHandler) GetActions(c echo.Context) error {
req, err := bindAndValidate[txRequestWithPagination](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
hash, err := hex.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
tx, err := handler.tx.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.tx)
}
events, err := handler.actions.ByTxId(c.Request().Context(), tx.Id, req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.tx)
}
response := make([]responses.Action, len(events))
for i := range events {
response[i] = responses.NewAction(events[i])
}
return returnArray(c, response)
}
// Count godoc
//
// @Summary Get count of transactions in network
// @Description Get count of transactions in network
// @Tags transactions
// @ID get-transactions-count
// @Produce json
// @Success 200 {integer} uint64
// @Failure 500 {object} Error
// @Router /v1/tx/count [get]
func (handler *TxHandler) Count(c echo.Context) error {
state, err := handler.state.ByName(c.Request().Context(), handler.indexerName)
if err != nil {
return handleError(c, err, handler.tx)
}
return c.JSON(http.StatusOK, state.TotalTx)
}
// RollupActions godoc
//
// @Summary List transaction's rollup actions
// @Description List transaction's rollup actions
// @Tags transactions
// @ID list-transactions-rollup-actions
// @Param hash path string true "Transaction hash in hexadecimal" minlength(64) maxlength(64)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.RollupAction
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/tx/{hash}/rollup_actions [get]
func (handler *TxHandler) RollupActions(c echo.Context) error {
req, err := bindAndValidate[txRequestWithPagination](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
hash, err := hex.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
tx, err := handler.tx.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.tx)
}
actions, err := handler.rollups.ActionsByTxId(c.Request().Context(), tx.Id, req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.tx)
}
response := make([]responses.RollupAction, len(actions))
for i := range actions {
response[i] = responses.NewRollupAction(actions[i])
}
return returnArray(c, response)
}
// RollupActionsCount godoc
//
// @Summary Count of rollup actions
// @Description Count of rollup actions
// @Tags transactions
// @ID list-transactions-rollup-actions-count
// @Param hash path string true "Transaction hash in hexadecimal" minlength(64) maxlength(64)
// @Produce json
// @Success 200 {integer} uint64
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/tx/{hash}/rollup_actions/count [get]
func (handler *TxHandler) RollupActionsCount(c echo.Context) error {
req, err := bindAndValidate[getTxRequest](c)
if err != nil {
return badRequestError(c, err)
}
hash, err := hex.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
tx, err := handler.tx.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.tx)
}
count, err := handler.rollups.CountActionsByTxId(c.Request().Context(), tx.Id)
if err != nil {
return handleError(c, err, handler.tx)
}
return c.JSON(http.StatusOK, count)
}
// GetFees godoc
//
// @Summary Get transaction fees
// @Description Get transaction fees
// @Tags transactions
// @ID get-transaction-fees
// @Param hash path string true "Transaction hash in hexadecimal" minlength(64) maxlength(64)
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Produce json
// @Success 200 {array} responses.FullFee
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/tx/{hash}/fees [get]
func (handler *TxHandler) GetFees(c echo.Context) error {
req, err := bindAndValidate[txRequestWithPagination](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
hash, err := hex.DecodeString(req.Hash)
if err != nil {
return badRequestError(c, err)
}
tx, err := handler.tx.ByHash(c.Request().Context(), hash)
if err != nil {
return handleError(c, err, handler.tx)
}
fees, err := handler.fees.ByTxId(c.Request().Context(), tx.Id, req.Limit, req.Offset)
if err != nil {
return handleError(c, err, handler.tx)
}
response := make([]responses.FullFee, len(fees))
for i := range fees {
response[i] = responses.NewFullFee(fees[i])
}
return returnArray(c, response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/labstack/echo/v4"
)
type ValidatorHandler struct {
validators storage.IValidator
blocks storage.IBlock
blockSignatures storage.IBlockSignature
state storage.IState
indexerName string
}
func NewValidatorHandler(
validators storage.IValidator,
blocks storage.IBlock,
blockSignatures storage.IBlockSignature,
state storage.IState,
indexerName string,
) *ValidatorHandler {
return &ValidatorHandler{
validators: validators,
blocks: blocks,
blockSignatures: blockSignatures,
state: state,
indexerName: indexerName,
}
}
var _ Handler = (*ValidatorHandler)(nil)
func (handler *ValidatorHandler) InitRoutes(srvr *echo.Group) {
validators := srvr.Group("/validators")
{
validators.GET("", handler.List)
validatorGroup := validators.Group("/:id")
{
validatorGroup.GET("", handler.Get)
validatorGroup.GET("/blocks", handler.Blocks)
validatorGroup.GET("/uptime", handler.Uptime)
}
}
}
type validatorRequest struct {
Id uint64 `param:"id" validate:"required,min=1"`
}
// Get godoc
//
// @Summary Get validator info
// @Description Get validator info
// @Tags validator
// @ID get-validator
// @Param id path integer true "Internal validator id"
// @Produce json
// @Success 200 {object} responses.Validator
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/validators/{id} [get]
func (handler *ValidatorHandler) Get(c echo.Context) error {
req, err := bindAndValidate[validatorRequest](c)
if err != nil {
return badRequestError(c, err)
}
validator, err := handler.validators.GetByID(c.Request().Context(), req.Id)
if err != nil {
return handleError(c, err, handler.validators)
}
return c.JSON(http.StatusOK, responses.NewValidator(validator))
}
type validatorsRequest struct {
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
}
func (p *validatorsRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = asc
}
}
// List godoc
//
// @Summary List validators
// @Description List validators sorted by power
// @Tags validator
// @ID list-validator
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Produce json
// @Produce json
// @Success 200 {array} responses.Validator
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/validators [get]
func (handler *ValidatorHandler) List(c echo.Context) error {
req, err := bindAndValidate[validatorsRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
validators, err := handler.validators.ListByPower(c.Request().Context(), req.Limit, req.Offset, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.validators)
}
response := make([]responses.Validator, len(validators))
for i := range validators {
response[i] = *responses.NewValidator(&validators[i])
}
return returnArray(c, response)
}
type listValidatorRequest struct {
Id uint64 `param:"id" validate:"required,min=1"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
}
func (p *listValidatorRequest) SetDefault() {
if p.Limit == 0 {
p.Limit = 10
}
if p.Sort == "" {
p.Sort = desc
}
}
// Blocks godoc
//
// @Summary List blocks which was proposed by validator
// @Description List blocks which was proposed by validator
// @Tags validator
// @ID get-validator-blocks
// @Param id path integer true "Internal validator id"
// @Param limit query integer false "Count of requested entities" mininum(1) maximum(100)
// @Param offset query integer false "Offset" mininum(1)
// @Param sort query string false "Sort order" Enums(asc, desc)
// @Produce json
// @Success 200 {array} responses.Block
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/validators/{id}/blocks [get]
func (handler *ValidatorHandler) Blocks(c echo.Context) error {
req, err := bindAndValidate[listValidatorRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
blocks, err := handler.blocks.ByProposer(c.Request().Context(), req.Id, req.Limit, req.Offset, pgSort(req.Sort))
if err != nil {
return handleError(c, err, handler.blocks)
}
response := make([]responses.Block, len(blocks))
for i := range blocks {
response[i] = responses.NewBlock(blocks[i])
}
return returnArray(c, response)
}
type validatorUptimeRequest struct {
Id uint64 `param:"id" validate:"required,min=1"`
Limit types.Level `query:"limit" validate:"omitempty,min=1,max=100"`
}
func (r *validatorUptimeRequest) SetDefault() {
if r.Limit == 0 {
r.Limit = 10
}
}
// Uptime godoc
//
// @Summary Get validator's uptime and history of signed block
// @Description Get validator's uptime and history of signed block
// @Tags validator
// @ID get-validator-uptime
// @Param id path integer true "Internal validator id"
// @Param limit query integer false "Count of requested blocks" mininum(1) maximum(100)
// @Produce json
// @Success 200 {object} responses.ValidatorUptime
// @Success 204
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/validators/{id}/uptime [get]
func (handler *ValidatorHandler) Uptime(c echo.Context) error {
req, err := bindAndValidate[validatorUptimeRequest](c)
if err != nil {
return badRequestError(c, err)
}
req.SetDefault()
state, err := handler.state.ByName(c.Request().Context(), handler.indexerName)
if err != nil {
return handleError(c, err, handler.blockSignatures)
}
startHeight := state.LastHeight - req.Limit - 1
levels, err := handler.blockSignatures.LevelsByValidator(c.Request().Context(), req.Id, startHeight)
if err != nil {
return handleError(c, err, handler.blockSignatures)
}
response := responses.NewValidatorUptime(levels, state.LastHeight-1, req.Limit)
return c.JSON(http.StatusOK, response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/internal/astria"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/go-playground/validator/v10"
"github.com/labstack/echo/v4"
)
type ApiValidator struct {
validator *validator.Validate
}
func NewApiValidator() *ApiValidator {
v := validator.New()
if err := v.RegisterValidation("address", addressValidator()); err != nil {
panic(err)
}
if err := v.RegisterValidation("status", statusValidator()); err != nil {
panic(err)
}
if err := v.RegisterValidation("action_type", actionTypeValidator()); err != nil {
panic(err)
}
if err := v.RegisterValidation("app_category", categoryValidator()); err != nil {
panic(err)
}
return &ApiValidator{validator: v}
}
func (v *ApiValidator) Validate(i interface{}) error {
if err := v.validator.Struct(i); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
return nil
}
func isAddress(address string) bool {
return astria.IsAddress(address)
}
func addressValidator() validator.Func {
return func(fl validator.FieldLevel) bool {
return isAddress(fl.Field().String())
}
}
func statusValidator() validator.Func {
return func(fl validator.FieldLevel) bool {
_, err := types.ParseStatus(fl.Field().String())
return err == nil
}
}
func actionTypeValidator() validator.Func {
return func(fl validator.FieldLevel) bool {
_, err := types.ParseActionType(fl.Field().String())
return err == nil
}
}
func categoryValidator() validator.Func {
return func(fl validator.FieldLevel) bool {
_, err := types.ParseAppCategory(fl.Field().String())
return err == nil
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package websocket
import (
sdkSync "github.com/dipdup-net/indexer-sdk/pkg/sync"
"github.com/pkg/errors"
)
type processor[I any, M INotification] func(data I) Notification[M]
type Channel[I any, M INotification] struct {
clients *sdkSync.Map[uint64, client]
processor processor[I, M]
filters Filterable[M]
}
func NewChannel[I any, M INotification](processor processor[I, M], filters Filterable[M]) *Channel[I, M] {
return &Channel[I, M]{
clients: sdkSync.NewMap[uint64, client](),
processor: processor,
filters: filters,
}
}
func (channel *Channel[I, M]) AddClient(c client) {
channel.clients.Set(c.Id(), c)
}
func (channel *Channel[I, M]) RemoveClient(id uint64) {
channel.clients.Delete(id)
}
func (channel *Channel[I, M]) processMessage(msg I) error {
if channel.clients.Len() == 0 {
return nil
}
data := channel.processor(msg)
if err := channel.clients.Range(func(_ uint64, value client) (error, bool) {
if channel.filters.Filter(value, data) {
value.Notify(data)
}
return nil, false
}); err != nil {
return errors.Wrap(err, "write message to client")
}
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package websocket
import (
"context"
"io"
"net"
"sync/atomic"
"time"
"github.com/dipdup-io/workerpool"
"github.com/goccy/go-json"
"github.com/gorilla/websocket"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
)
type client interface {
Id() uint64
ApplyFilters(msg Subscribe) error
DetachFilters(msg Unsubscribe) error
Notify(msg any)
WriteMessages(ctx context.Context, ws *websocket.Conn, log echo.Logger)
ReadMessages(ctx context.Context, ws *websocket.Conn, sub *Client, log echo.Logger)
Filters() *Filters
io.Closer
}
const (
// pongWait is how long we will await a pong response from client
pongWait = 10 * time.Second
// pingInterval has to be less than pongWait, We cant multiply by 0.9 to get 90% of time
// Because that can make decimals, so instead *9 / 10 to get 90%
// The reason why it has to be less than PingRequency is because otherwise it will send a new Ping before getting response
pingInterval = (pongWait * 9) / 10
)
type Client struct {
id uint64
manager *Manager
filters *Filters
ch chan any
g workerpool.Group
closed *atomic.Bool
}
func newClient(id uint64, manager *Manager) *Client {
closed := new(atomic.Bool)
closed.Store(false)
return &Client{
id: id,
manager: manager,
ch: make(chan any, 1024),
g: workerpool.NewGroup(),
closed: closed,
}
}
func (c *Client) Id() uint64 {
return c.id
}
func (c *Client) Filters() *Filters {
return c.filters
}
func (c *Client) ApplyFilters(msg Subscribe) error {
if c.filters == nil {
c.filters = &Filters{}
}
switch msg.Channel {
case ChannelHead:
c.filters.head = true
case ChannelBlocks:
c.filters.blocks = true
default:
return errors.Wrap(ErrUnknownChannel, msg.Channel)
}
return nil
}
func (c *Client) DetachFilters(msg Unsubscribe) error {
if c.filters == nil {
return nil
}
switch msg.Channel {
case ChannelHead:
c.filters.head = false
case ChannelBlocks:
c.filters.blocks = false
default:
return errors.Wrap(ErrUnknownChannel, msg.Channel)
}
return nil
}
func (c *Client) Notify(msg any) {
if c.closed.Load() {
return
}
c.ch <- msg
}
func (c *Client) Close() error {
c.g.Wait()
c.closed.Store(true)
close(c.ch)
return nil
}
func (c *Client) writeThread(ctx context.Context, ws *websocket.Conn, log echo.Logger) {
ticker := time.NewTicker(pingInterval)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
if err := ws.WriteMessage(websocket.PingMessage, []byte{}); err != nil {
log.Errorf("writemsg: %s", err)
return
}
case msg, ok := <-c.ch:
if !ok {
if err := ws.WriteMessage(websocket.CloseMessage, nil); err != nil {
log.Errorf("send close message: %s", err)
}
return
}
if err := ws.WriteJSON(msg); err != nil {
log.Errorf("send client message: %s", err)
}
}
}
}
func (c *Client) WriteMessages(ctx context.Context, ws *websocket.Conn, log echo.Logger) {
c.g.GoCtx(ctx, func(ctx context.Context) {
c.writeThread(ctx, ws, log)
})
}
func (c *Client) ReadMessages(ctx context.Context, ws *websocket.Conn, sub *Client, log echo.Logger) {
if err := ws.SetReadDeadline(time.Now().Add(pongWait)); err != nil {
log.Error(err)
return
}
ws.SetPongHandler(func(_ string) error {
return ws.SetReadDeadline(time.Now().Add(pongWait))
})
for {
select {
case <-ctx.Done():
return
default:
if err := c.read(ctx, ws); err != nil {
timeoutErr, ok := err.(net.Error)
switch {
case err == io.EOF:
return
case errors.Is(err, websocket.ErrCloseSent):
return
case ok && timeoutErr.Timeout():
return
case websocket.IsCloseError(err,
websocket.CloseNormalClosure,
websocket.CloseAbnormalClosure,
websocket.CloseNoStatusReceived,
websocket.CloseGoingAway):
c.manager.RemoveClientFromChannel(ChannelHead, c)
c.manager.RemoveClientFromChannel(ChannelBlocks, c)
return
}
log.Errorf("read websocket message: %s", err.Error())
}
}
}
}
func (c *Client) read(ctx context.Context, ws *websocket.Conn) error {
var msg Message
if err := ws.ReadJSON(&msg); err != nil {
return err
}
switch msg.Method {
case MethodSubscribe:
return c.handleSubscribeMessage(ctx, msg)
case MethodUnsubscribe:
return c.handleUnsubscribeMessage(ctx, msg)
default:
return errors.Wrap(ErrUnknownMethod, msg.Method)
}
}
func (c *Client) handleSubscribeMessage(_ context.Context, msg Message) error {
var subscribeMsg Subscribe
if err := json.Unmarshal(msg.Body, &subscribeMsg); err != nil {
return err
}
if err := c.ApplyFilters(subscribeMsg); err != nil {
return err
}
c.manager.AddClientToChannel(subscribeMsg.Channel, c)
return nil
}
func (c *Client) handleUnsubscribeMessage(_ context.Context, msg Message) error {
var unsubscribeMsg Unsubscribe
if err := json.Unmarshal(msg.Body, &unsubscribeMsg); err != nil {
return err
}
if err := c.DetachFilters(unsubscribeMsg); err != nil {
return err
}
c.manager.RemoveClientFromChannel(unsubscribeMsg.Channel, c)
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package websocket
import (
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
)
type Filterable[M INotification] interface {
Filter(c client, msg Notification[M]) bool
}
type HeadFilter struct{}
func (f HeadFilter) Filter(c client, msg Notification[*responses.State]) bool {
if msg.Body == nil {
return false
}
fltrs := c.Filters()
if fltrs == nil {
return false
}
return fltrs.head
}
type BlockFilter struct{}
func (f BlockFilter) Filter(c client, msg Notification[*responses.Block]) bool {
if msg.Body == nil {
return false
}
fltrs := c.Filters()
if fltrs == nil {
return false
}
return fltrs.blocks
}
type Filters struct {
head bool
blocks bool
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package websocket
import (
"context"
"net/http"
"sync/atomic"
"github.com/dipdup-io/workerpool"
sdkSync "github.com/dipdup-net/indexer-sdk/pkg/sync"
"github.com/celenium-io/astria-indexer/cmd/api/bus"
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/gorilla/websocket"
"github.com/labstack/echo/v4"
"github.com/rs/zerolog/log"
)
type Manager struct {
upgrader websocket.Upgrader
clientId *atomic.Uint64
clients *sdkSync.Map[uint64, *Client]
observer *bus.Observer
head *Channel[storage.State, *responses.State]
blocks *Channel[storage.Block, *responses.Block]
g workerpool.Group
}
func NewManager(observer *bus.Observer) *Manager {
manager := &Manager{
upgrader: websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool {
return true
},
},
observer: observer,
clientId: new(atomic.Uint64),
clients: sdkSync.NewMap[uint64, *Client](),
g: workerpool.NewGroup(),
}
manager.head = NewChannel[storage.State, *responses.State](
headProcessor,
HeadFilter{},
)
manager.blocks = NewChannel[storage.Block, *responses.Block](
blockProcessor,
BlockFilter{},
)
return manager
}
func (manager *Manager) listen(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
case state := <-manager.observer.Head():
if err := manager.head.processMessage(*state); err != nil {
log.Err(err).Msg("handle state")
}
case block := <-manager.observer.Blocks():
if err := manager.blocks.processMessage(*block); err != nil {
log.Err(err).Msg("handle block")
}
}
}
}
func (manager *Manager) InitRoutes(srvr *echo.Group) {
srvr.GET("/ws", manager.Handle)
}
// Handle godoc
//
// @Summary Websocket API
// @Description.markdown websocket
// @Tags websocket
// @ID websocket
// @Produce json
// @Router /v1/ws [get]
func (manager *Manager) Handle(c echo.Context) error {
ws, err := manager.upgrader.Upgrade(c.Response(), c.Request(), nil)
if err != nil {
return err
}
ws.SetReadLimit(1024 * 10) // 10KB
sId := manager.clientId.Add(1)
sub := newClient(sId, manager)
manager.clients.Set(sId, sub)
ctx, cancel := context.WithCancel(c.Request().Context())
sub.WriteMessages(ctx, ws, c.Logger())
sub.ReadMessages(ctx, ws, sub, c.Logger())
manager.clients.Delete(sId)
cancel()
if err := sub.Close(); err != nil {
return err
}
return ws.Close()
}
func (manager *Manager) Start(ctx context.Context) {
manager.g.GoCtx(ctx, manager.listen)
}
func (manager *Manager) Close() error {
manager.g.Wait()
return manager.clients.Range(func(_ uint64, value *Client) (error, bool) {
if err := value.Close(); err != nil {
return err, false
}
return nil, false
})
}
func (manager *Manager) AddClientToChannel(channel string, client *Client) {
switch channel {
case ChannelHead:
manager.head.AddClient(client)
case ChannelBlocks:
manager.blocks.AddClient(client)
default:
log.Error().Str("channel", channel).Msg("unknown channel name")
}
}
func (manager *Manager) RemoveClientFromChannel(channel string, client *Client) {
switch channel {
case ChannelHead:
manager.head.RemoveClient(client.id)
case ChannelBlocks:
manager.blocks.RemoveClient(client.id)
default:
log.Error().Str("channel", channel).Msg("unknown channel name")
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package websocket
import (
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/goccy/go-json"
)
// methods
const (
MethodSubscribe = "subscribe"
MethodUnsubscribe = "unsubscribe"
)
// channels
const (
ChannelHead = "head"
ChannelBlocks = "blocks"
)
type Message struct {
Method string `json:"method" validate:"required,oneof=subscribe,unsubscribe"`
Body json.RawMessage `json:"body" validate:"required"`
}
type Subscribe struct {
Channel string `json:"channel" validate:"required,oneof=head tx"`
Filters json.RawMessage `json:"filters" validate:"required"`
}
type Unsubscribe struct {
Channel string `json:"channel" validate:"required,oneof=head tx"`
}
type TransactionFilters struct {
Status []string `json:"status,omitempty"`
Actions []string `json:"action_type,omitempty"`
}
type INotification interface {
*responses.Block | *responses.State
}
type Notification[T INotification] struct {
Channel string `json:"channel"`
Body T `json:"body"`
}
func NewBlockNotification(block responses.Block) Notification[*responses.Block] {
return Notification[*responses.Block]{
Channel: ChannelBlocks,
Body: &block,
}
}
func NewStateNotification(state responses.State) Notification[*responses.State] {
return Notification[*responses.State]{
Channel: ChannelHead,
Body: &state,
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package websocket
import (
"github.com/celenium-io/astria-indexer/cmd/api/handler/responses"
"github.com/celenium-io/astria-indexer/internal/storage"
)
func blockProcessor(block storage.Block) Notification[*responses.Block] {
response := responses.NewBlock(block)
return NewBlockNotification(response)
}
func headProcessor(state storage.State) Notification[*responses.State] {
response := responses.NewState(state)
return NewStateNotification(response)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"net/http"
"os"
"strconv"
"time"
"github.com/celenium-io/astria-indexer/cmd/api/bus"
"github.com/celenium-io/astria-indexer/cmd/api/cache"
"github.com/celenium-io/astria-indexer/cmd/api/handler"
"github.com/celenium-io/astria-indexer/cmd/api/handler/websocket"
"github.com/celenium-io/astria-indexer/internal/profiler"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/dipdup-net/go-lib/config"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/getsentry/sentry-go"
"github.com/grafana/pyroscope-go"
"github.com/labstack/echo-contrib/echoprometheus"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
echoSwagger "github.com/swaggo/echo-swagger"
"golang.org/x/time/rate"
)
func init() {
zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
short := file
for i := len(file) - 1; i > 0; i-- {
if file[i] == '/' {
short = file[i+1:]
break
}
}
file = short
return file + ":" + strconv.Itoa(line)
}
log.Logger = log.Logger.
Output(zerolog.ConsoleWriter{
Out: os.Stdout,
TimeFormat: "2006-01-02 15:04:05",
}).
With().Caller().
Logger()
}
func loadConfig() (*Config, error) {
configPath := rootCmd.PersistentFlags().StringP("config", "c", "dipdup.yml", "path to YAML config file")
if err := rootCmd.Execute(); err != nil {
return nil, errors.Wrap(err, "command line execute")
}
if err := rootCmd.MarkFlagRequired("config"); err != nil {
return nil, errors.Wrap(err, "config command line arg is required")
}
var cfg Config
if err := config.Parse(*configPath, &cfg); err != nil {
return nil, errors.Wrap(err, "parsing config file")
}
if cfg.LogLevel == "" {
cfg.LogLevel = zerolog.LevelInfoValue
}
if err := setLoggerLevel(cfg.LogLevel); err != nil {
return nil, errors.Wrap(err, "set log level")
}
return &cfg, nil
}
func setLoggerLevel(level string) error {
logLevel, err := zerolog.ParseLevel(level)
if err != nil {
return errors.Wrap(err, "parsing log level")
}
zerolog.SetGlobalLevel(logLevel)
return nil
}
func newProflier(cfg *Config) (*pyroscope.Profiler, error) {
return profiler.New(cfg.Profiler, "api")
}
func newServer(cfg *Config, wsManager *websocket.Manager, handlers []handler.Handler) (*echo.Echo, error) {
e := echo.New()
e.Validator = handler.NewApiValidator()
e.Server.IdleTimeout = time.Second * 30
e.Pre(middleware.RemoveTrailingSlash())
timeout := 30 * time.Second
if cfg.ApiConfig.RequestTimeout > 0 {
timeout = time.Duration(cfg.ApiConfig.RequestTimeout) * time.Second
}
timeoutConfig := middleware.TimeoutConfig{
Skipper: websocketSkipper,
Timeout: timeout,
}
loggerConfig := middleware.RequestLoggerConfig{
LogURI: true,
LogStatus: true,
LogLatency: true,
LogMethod: true,
LogUserAgent: true,
LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
switch {
case v.Status == http.StatusOK || v.Status == http.StatusNoContent:
log.Info().
Str("uri", v.URI).
Int("status", v.Status).
Dur("latency", v.Latency).
Str("method", v.Method).
Str("user-agent", v.UserAgent).
Str("ip", c.RealIP()).
Msg("request")
case v.Status >= 500:
log.Error().
Str("uri", v.URI).
Int("status", v.Status).
Dur("latency", v.Latency).
Str("method", v.Method).
Str("user-agent", v.UserAgent).
Str("ip", c.RealIP()).
Msg("request")
default:
log.Warn().
Str("uri", v.URI).
Int("status", v.Status).
Dur("latency", v.Latency).
Str("method", v.Method).
Str("user-agent", v.UserAgent).
Str("ip", c.RealIP()).
Msg("request")
}
return nil
},
}
gzipConfig := middleware.GzipConfig{
Skipper: gzipSkipper,
}
decompressConfig := middleware.DecompressConfig{
Skipper: websocketSkipper,
}
csrfConfig := middleware.CSRFConfig{
Skipper: func(c echo.Context) bool {
return websocketSkipper(c) || postSkipper(c)
},
}
middlewares := []echo.MiddlewareFunc{
middleware.TimeoutWithConfig(timeoutConfig),
middleware.RequestLoggerWithConfig(loggerConfig),
middleware.GzipWithConfig(gzipConfig),
middleware.DecompressWithConfig(decompressConfig),
middleware.BodyLimit("2M"),
middleware.CSRFWithConfig(csrfConfig),
middleware.CORS(),
middleware.Recover(),
middleware.Secure(),
}
if cfg.ApiConfig.Prometheus {
middlewares = append(middlewares, echoprometheus.NewMiddlewareWithConfig(echoprometheus.MiddlewareConfig{
Namespace: "astria_api",
Skipper: websocketSkipper,
}))
}
if cfg.ApiConfig.RateLimit > 0 {
middlewares = append(middlewares, middleware.RateLimiterWithConfig(middleware.RateLimiterConfig{
Skipper: websocketSkipper,
Store: middleware.NewRateLimiterMemoryStore(rate.Limit(cfg.ApiConfig.RateLimit)),
}))
}
sentryMiddleware, err := initSentry(cfg.ApiConfig.SentryDsn, cfg.Environment)
if err != nil {
return nil, errors.Wrap(err, "init sentry")
}
if sentryMiddleware != nil {
middlewares = append(middlewares, sentryMiddleware)
}
e.Use(middlewares...)
v1 := e.Group("v1")
for _, handler := range handlers {
handler.InitRoutes(v1)
}
if cfg.ApiConfig.Websocket {
wsManager.InitRoutes(v1)
}
if cfg.ApiConfig.Prometheus {
e.GET("/metrics", echoprometheus.NewHandler())
}
v1.GET("/swagger/*", echoSwagger.WrapHandler)
log.Info().Msg("API routes:")
for _, route := range e.Routes() {
log.Info().Msgf("[%s] %s -> %s", route.Method, route.Path, route.Name)
}
return e, nil
}
func newDatabase(cfg *Config) (*sdk.Storage, error) {
return postgres.Create(context.Background(), cfg.Database, cfg.Indexer.ScriptsDir, false)
}
func newConstantCache(dispatcher *bus.Dispatcher) *cache.ConstantsCache {
constantObserver := dispatcher.Observe(storage.ChannelConstant)
return cache.NewConstantsCache(constantObserver)
}
func initSentry(dsn, environment string) (echo.MiddlewareFunc, error) {
if dsn == "" {
return nil, nil
}
if err := sentry.Init(sentry.ClientOptions{
Dsn: dsn,
AttachStacktrace: true,
Environment: environment,
EnableTracing: true,
TracesSampleRate: 1.0,
Release: os.Getenv("TAG"),
}); err != nil {
return nil, errors.Wrap(err, "initialization")
}
return SentryMiddleware(), nil
}
func newWebsocket(dispatcher *bus.Dispatcher) *websocket.Manager {
observer := dispatcher.Observe(storage.ChannelHead, storage.ChannelBlock)
wsManager := websocket.NewManager(observer)
return wsManager
}
func newEndpointCache(e *echo.Echo, dispatcher *bus.Dispatcher) *cache.Cache {
observer := dispatcher.Observe(storage.ChannelHead)
endpointCache := cache.NewCache(cache.Config{
MaxEntitiesCount: 1000,
}, observer)
e.Use(cache.Middleware(endpointCache, cacheSkipper))
return endpointCache
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"os"
"os/signal"
"syscall"
"time"
"github.com/celenium-io/astria-indexer/cmd/api/bus"
_ "github.com/celenium-io/astria-indexer/cmd/api/docs"
"github.com/celenium-io/astria-indexer/cmd/api/handler"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/ipfans/fxlogger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"go.uber.org/fx"
)
var rootCmd = &cobra.Command{
Use: "api",
Short: "DipDup Verticals | Astria explorer API",
}
// @title Swagger Astria Explorer API
// @version 1.0
// @description This is docs of Astria Explorer API.
// @host api.astrotrek.io
//
// @query.collection.format multi
func main() {
app := fx.New(
fx.WithLogger(fxlogger.WithZerolog(log.Logger)),
fx.StartTimeout(5*time.Minute),
fx.Provide(
loadConfig,
databaseConfig,
indexerName,
newProflier,
fx.Annotate(
newServer,
fx.ParamTags("", "", `group:"handlers"`),
),
bus.NewDispatcher,
newEndpointCache,
newConstantCache,
newWebsocket,
newApp,
newDatabase,
fx.Annotate(
postgres.NewListenerFactory,
fx.As(new(storage.ListenerFactory)),
),
fx.Annotate(
postgres.NewAction,
fx.As(new(storage.IAction)),
),
fx.Annotate(
postgres.NewAddress,
fx.As(new(storage.IAddress)),
),
fx.Annotate(
postgres.NewApp,
fx.As(new(storage.IApp)),
),
fx.Annotate(
postgres.NewAsset,
fx.As(new(storage.IAsset)),
),
fx.Annotate(
postgres.NewBlockSignature,
fx.As(new(storage.IBlockSignature)),
),
fx.Annotate(
postgres.NewBlockStats,
fx.As(new(storage.IBlockStats)),
),
fx.Annotate(
postgres.NewBlocks,
fx.As(new(storage.IBlock)),
),
fx.Annotate(
postgres.NewBridge,
fx.As(new(storage.IBridge)),
),
fx.Annotate(
postgres.NewConstant,
fx.As(new(storage.IConstant)),
),
fx.Annotate(
postgres.NewDeposit,
fx.As(new(storage.IDeposit)),
),
fx.Annotate(
postgres.NewFee,
fx.As(new(storage.IFee)),
),
fx.Annotate(
postgres.NewRollup,
fx.As(new(storage.IRollup)),
),
fx.Annotate(
postgres.NewSearch,
fx.As(new(storage.ISearch)),
),
fx.Annotate(
postgres.NewState,
fx.As(new(storage.IState)),
),
fx.Annotate(
postgres.NewStats,
fx.As(new(storage.IStats)),
),
fx.Annotate(
postgres.NewTransfer,
fx.As(new(storage.ITransfer)),
),
fx.Annotate(
postgres.NewTx,
fx.As(new(storage.ITx)),
),
fx.Annotate(
postgres.NewValidator,
fx.As(new(storage.IValidator)),
),
fx.Annotate(
postgres.NewPrice,
fx.As(new(storage.IPrice)),
),
fx.Annotate(
postgres.NewMarket,
fx.As(new(storage.IMarket)),
),
AsHandler(handler.NewAddressHandler),
AsHandler(handler.NewAppHandler),
AsHandler(handler.NewAssetHandler),
AsHandler(handler.NewBlockHandler),
AsHandler(handler.NewConstantHandler),
AsHandler(handler.NewRollupHandler),
AsHandler(handler.NewSearchHandler),
AsHandler(handler.NewStateHandler),
AsHandler(handler.NewStatsHandler),
AsHandler(handler.NewTxHandler),
AsHandler(handler.NewValidatorHandler),
AsHandler(handler.NewPriceHandler),
),
fx.Invoke(func(*App) {}),
)
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
if err := app.Start(ctx); err != nil {
log.Err(err).Msg("start app")
os.Exit(1)
}
<-ctx.Done()
cancel()
if err := app.Stop(ctx); err != nil {
log.Err(err).Msg("stop app")
os.Exit(1)
}
}
func AsHandler(f any) any {
return fx.Annotate(
f,
fx.As(new(handler.Handler)),
fx.ResultTags(`group:"handlers"`),
)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"fmt"
"net/http"
"time"
"github.com/getsentry/sentry-go"
"github.com/labstack/echo/v4"
)
const sdkIdentifier = "sentry.go.http"
func SentryMiddleware() echo.MiddlewareFunc {
return handleSentry
}
func handleSentry(next echo.HandlerFunc) echo.HandlerFunc {
return func(ctx echo.Context) error {
hub := sentry.GetHubFromContext(ctx.Request().Context())
if hub == nil {
hub = sentry.CurrentHub().Clone()
}
if client := hub.Client(); client != nil {
client.SetSDKIdentifier(sdkIdentifier)
}
ctx.Set("sentry", hub)
req := ctx.Request()
options := []sentry.SpanOption{
sentry.WithOpName("http.server"),
sentry.ContinueFromRequest(req),
sentry.WithTransactionSource(sentry.SourceURL),
}
transaction := sentry.StartTransaction(ctx.Request().Context(),
fmt.Sprintf("%s %s", req.Method, req.URL.Path),
options...,
)
defer func() {
transaction.Status = sentry.HTTPtoSpanStatus(ctx.Response().Status)
transaction.Finish()
}()
req = req.WithContext(transaction.Context())
sentry.ConfigureScope(func(scope *sentry.Scope) {
scope.SetUser(sentry.User{
IPAddress: ctx.RealIP(),
})
scope.SetRequest(req)
})
defer recoverWithSentry(hub, req)
ctx.SetRequest(req)
return next(ctx)
}
}
func recoverWithSentry(hub *sentry.Hub, r *http.Request) {
if err := recover(); err != nil {
eventID := hub.RecoverWithContext(
context.WithValue(r.Context(), sentry.RequestContextKey, r),
err,
)
if eventID != nil {
hub.Flush(time.Second * 10)
}
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"net/http"
"strings"
"github.com/labstack/echo/v4"
)
func websocketSkipper(c echo.Context) bool {
return strings.Contains(c.Request().URL.Path, "ws")
}
func postSkipper(c echo.Context) bool {
if strings.Contains(c.Request().URL.Path, "blob") {
return true
}
if strings.Contains(c.Request().URL.Path, "auth/rollup") {
return true
}
return false
}
func gzipSkipper(c echo.Context) bool {
if strings.Contains(c.Request().URL.Path, "swagger") {
return true
}
if strings.Contains(c.Request().URL.Path, "metrics") {
return true
}
return websocketSkipper(c)
}
func cacheSkipper(c echo.Context) bool {
if c.Request().Method != http.MethodGet {
return true
}
if websocketSkipper(c) {
return true
}
if strings.Contains(c.Request().URL.Path, "metrics") {
return true
}
if strings.Contains(c.Request().URL.Path, "head") {
return true
}
return false
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"github.com/celenium-io/astria-indexer/pkg/indexer"
"github.com/celenium-io/astria-indexer/pkg/indexer/config"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/grafana/pyroscope-go"
"github.com/pkg/errors"
"go.uber.org/fx"
)
type App struct {
prscp *pyroscope.Profiler
stopperModule modules.Module
indexerModule indexer.Indexer
db *postgres.Storage
}
func newApp(
lc fx.Lifecycle,
cfg *config.Config,
db *postgres.Storage,
prscp *pyroscope.Profiler,
stopperModule modules.Module,
indexerModule indexer.Indexer,
) *App {
app := &App{
prscp: prscp,
stopperModule: stopperModule,
indexerModule: indexerModule,
db: db,
}
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
app.stopperModule.Start(ctx)
app.indexerModule.Start(ctx)
return nil
},
OnStop: func(ctx context.Context) error {
if err := app.prscp.Stop(); err != nil {
return errors.Wrap(err, "closing pyroscrope")
}
if err := app.indexerModule.Close(); err != nil {
return errors.Wrap(err, "closing indexer module")
}
if err := app.stopperModule.Close(); err != nil {
return errors.Wrap(err, "closing stopper module")
}
if err := app.db.Close(); err != nil {
return errors.Wrap(err, "closing database")
}
return nil
},
})
return app
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"os"
"strconv"
"github.com/celenium-io/astria-indexer/internal/profiler"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/celenium-io/astria-indexer/pkg/indexer/config"
dipdupCfg "github.com/dipdup-net/go-lib/config"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/grafana/pyroscope-go"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func init() {
zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
short := file
for i := len(file) - 1; i > 0; i-- {
if file[i] == '/' {
short = file[i+1:]
break
}
}
file = short
return file + ":" + strconv.Itoa(line)
}
log.Logger = log.Logger.
Output(zerolog.ConsoleWriter{
Out: os.Stdout,
TimeFormat: "2006-01-02 15:04:05",
}).
With().Caller().
Logger()
}
func loadConfig() (*config.Config, error) {
configPath := rootCmd.PersistentFlags().StringP("config", "c", "dipdup.yml", "path to YAML config file")
if err := rootCmd.Execute(); err != nil {
return nil, errors.Wrap(err, "command line execute")
}
if err := rootCmd.MarkFlagRequired("config"); err != nil {
return nil, errors.Wrap(err, "config command line arg is required")
}
var cfg config.Config
if err := dipdupCfg.Parse(*configPath, &cfg); err != nil {
return nil, errors.Wrap(err, "parsing config file")
}
if cfg.LogLevel == "" {
cfg.LogLevel = zerolog.LevelInfoValue
}
if err := setLoggerLevel(cfg.LogLevel); err != nil {
return nil, errors.Wrap(err, "set log level")
}
return &cfg, nil
}
func setLoggerLevel(level string) error {
logLevel, err := zerolog.ParseLevel(level)
if err != nil {
return errors.Wrap(err, "parsing log level")
}
zerolog.SetGlobalLevel(logLevel)
return nil
}
func newProflier(cfg *config.Config) (*pyroscope.Profiler, error) {
return profiler.New(cfg.Profiler, "api")
}
func newDatabase(cfg *config.Config) (*sdk.Storage, error) {
return postgres.Create(context.Background(), cfg.Database, cfg.Indexer.ScriptsDir, false)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"os"
"os/signal"
"syscall"
"time"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
"github.com/dipdup-net/indexer-sdk/pkg/modules/stopper"
"github.com/ipfans/fxlogger"
"go.uber.org/fx"
"github.com/celenium-io/astria-indexer/pkg/indexer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "indexer",
Short: "DipDup Verticals | Astria Indexer",
}
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
app := fx.New(
fx.WithLogger(fxlogger.WithZerolog(log.Logger)),
fx.Supply(cancel),
fx.StartTimeout(5*time.Minute),
fx.Provide(
loadConfig,
newProflier,
newDatabase,
fx.Annotate(
stopper.NewModule,
fx.As(new(modules.Module)),
),
indexer.New,
newApp,
),
fx.Invoke(func(*App) {}),
)
if err := app.Start(ctx); err != nil {
log.Err(err).Msg("start app")
os.Exit(1)
}
<-ctx.Done()
cancel()
if err := app.Stop(ctx); err != nil {
log.Err(err).Msg("stop app")
os.Exit(1)
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"net/http"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
"go.uber.org/fx"
)
type App struct {
e *echo.Echo
db *postgres.Storage
}
func newApp(
lc fx.Lifecycle,
cfg *Config,
e *echo.Echo,
db *postgres.Storage,
) *App {
app := &App{
e: e,
db: db,
}
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
if err := app.e.Start(cfg.ApiConfig.Bind); err != nil && errors.Is(err, http.ErrServerClosed) {
return errors.Wrap(err, "shutting down the server")
}
return nil
},
OnStop: func(ctx context.Context) error {
if err := app.e.Shutdown(ctx); err != nil {
return errors.Wrap(err, "closing server")
}
if err := app.db.Close(); err != nil {
return errors.Wrap(err, "closing database")
}
return nil
},
})
return app
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"context"
"encoding/base64"
"os"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/celenium-io/astria-indexer/internal/storage/types"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/gosimple/slug"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pkg/errors"
)
type AppHandler struct {
apps storage.IApp
address storage.IAddress
rollup storage.IRollup
tx sdk.Transactable
}
func NewAppHandler(
apps storage.IApp,
address storage.IAddress,
rollup storage.IRollup,
tx sdk.Transactable,
) *AppHandler {
return &AppHandler{
apps: apps,
address: address,
rollup: rollup,
tx: tx,
}
}
var _ Handler = (*AppHandler)(nil)
func (handler *AppHandler) InitRoutes(srvr *echo.Group) {
keyMiddleware := middleware.KeyAuthWithConfig(middleware.KeyAuthConfig{
KeyLookup: "header:Authorization",
Validator: func(key string, c echo.Context) (bool, error) {
return key == os.Getenv("PRIVATE_API_AUTH_KEY"), nil
},
})
app := srvr.Group("/app")
{
app.POST("", handler.Create, keyMiddleware)
app.PATCH("/:id", handler.Update, keyMiddleware)
app.DELETE("/:id", handler.Delete, keyMiddleware)
}
}
type createAppRequest struct {
Group string `json:"group" validate:"omitempty,min=1"`
Name string `json:"name" validate:"required,min=1"`
Description string `json:"description" validate:"required,min=1"`
Website string `json:"website" validate:"omitempty,url"`
GitHub string `json:"github" validate:"omitempty,url"`
Twitter string `json:"twitter" validate:"omitempty,url"`
Logo string `json:"logo" validate:"omitempty,url"`
L2Beat string `json:"l2beat" validate:"omitempty,url"`
Explorer string `json:"explorer" validate:"omitempty,url"`
Stack string `json:"stack" validate:"omitempty"`
Links []string `json:"links" validate:"omitempty,dive,url"`
Category string `json:"category" validate:"omitempty,app_category"`
Type string `json:"type" validate:"omitempty,app_type"`
VM string `json:"vm" validate:"omitempty"`
Provider string `json:"provider" validate:"omitempty"`
Rollup string `json:"rollup" validate:"required,base64"`
NativeBridge string `json:"native_bridge" validate:"omitempty,address"`
}
func (handler *AppHandler) Create(c echo.Context) error {
req, err := bindAndValidate[createAppRequest](c)
if err != nil {
return badRequestError(c, err)
}
if err := handler.createApp(c.Request().Context(), req); err != nil {
return handleError(c, err, handler.apps)
}
return success(c)
}
func (handler *AppHandler) createApp(ctx context.Context, req *createAppRequest) error {
tx, err := postgres.BeginTransaction(ctx, handler.tx)
if err != nil {
return err
}
hash, err := base64.StdEncoding.DecodeString(req.Rollup)
if err != nil {
return err
}
rollup, err := handler.rollup.ByHash(ctx, hash)
if err != nil {
return err
}
app := storage.App{
Group: req.Group,
Name: req.Name,
Description: req.Description,
Website: req.Website,
Github: req.GitHub,
Twitter: req.Twitter,
Logo: req.Logo,
L2Beat: req.L2Beat,
Explorer: req.Explorer,
Stack: req.Stack,
Links: req.Links,
Provider: req.Provider,
VM: req.VM,
Type: types.AppType(req.Type),
Category: types.AppCategory(req.Category),
Slug: slug.Make(req.Name),
RollupId: rollup.Id,
}
if req.NativeBridge != "" {
addr, err := handler.address.ByHash(ctx, req.NativeBridge)
if err != nil {
return err
}
if !addr.IsBridge {
return tx.HandleError(ctx, errors.Errorf("address %s is not a bridge", req.NativeBridge))
}
app.NativeBridgeId = addr.Id
}
if err := tx.SaveApp(ctx, &app); err != nil {
return tx.HandleError(ctx, err)
}
if err := tx.RefreshLeaderboard(ctx); err != nil {
return tx.HandleError(ctx, err)
}
return tx.Flush(ctx)
}
type updateAppRequest struct {
Id uint64 `param:"id" validate:"required,min=1"`
Group string `json:"group" validate:"omitempty,min=1"`
Name string `json:"name" validate:"omitempty,min=1"`
Description string `json:"description" validate:"omitempty,min=1"`
Website string `json:"website" validate:"omitempty,url"`
GitHub string `json:"github" validate:"omitempty,url"`
Twitter string `json:"twitter" validate:"omitempty,url"`
Logo string `json:"logo" validate:"omitempty,url"`
L2Beat string `json:"l2beat" validate:"omitempty,url"`
Explorer string `json:"explorer" validate:"omitempty,url"`
Stack string `json:"stack" validate:"omitempty"`
Links []string `json:"links" validate:"omitempty,dive,url"`
Category string `json:"category" validate:"omitempty,app_category"`
Type string `json:"type" validate:"omitempty,app_type"`
VM string `json:"vm" validate:"omitempty"`
Provider string `json:"provider" validate:"omitempty"`
Rollup string `json:"rollup" validate:"omitempty,base64"`
NativeBridge string `json:"native_bridge" validate:"omitempty,address"`
}
func (handler *AppHandler) Update(c echo.Context) error {
req, err := bindAndValidate[updateAppRequest](c)
if err != nil {
return badRequestError(c, err)
}
if err := handler.updateRollup(c.Request().Context(), req); err != nil {
return handleError(c, err, handler.apps)
}
return success(c)
}
func (handler *AppHandler) updateRollup(ctx context.Context, req *updateAppRequest) error {
tx, err := postgres.BeginTransaction(ctx, handler.tx)
if err != nil {
return err
}
if _, err := handler.apps.GetByID(ctx, req.Id); err != nil {
return err
}
app := storage.App{
Id: req.Id,
Name: req.Name,
Slug: slug.Make(req.Name),
Description: req.Description,
Website: req.Website,
Github: req.GitHub,
Twitter: req.Twitter,
Logo: req.Logo,
L2Beat: req.L2Beat,
Explorer: req.Explorer,
Stack: req.Stack,
Provider: req.Provider,
VM: req.VM,
Type: types.AppType(req.Type),
Category: types.AppCategory(req.Category),
Links: req.Links,
}
if req.Rollup != "" {
hash, err := base64.StdEncoding.DecodeString(req.Rollup)
if err != nil {
return err
}
rollup, err := handler.rollup.ByHash(ctx, hash)
if err != nil {
return err
}
app.RollupId = rollup.Id
}
if req.NativeBridge != "" {
addr, err := handler.address.ByHash(ctx, req.NativeBridge)
if err != nil {
return err
}
if !addr.IsBridge {
return tx.HandleError(ctx, errors.Errorf("address %s is not a bridge", req.NativeBridge))
}
app.NativeBridgeId = addr.Id
}
if err := tx.UpdateApp(ctx, &app); err != nil {
return tx.HandleError(ctx, err)
}
if err := tx.RefreshLeaderboard(ctx); err != nil {
return tx.HandleError(ctx, err)
}
return tx.Flush(ctx)
}
type deleteRollupRequest struct {
Id uint64 `param:"id" validate:"required,min=1"`
}
func (handler *AppHandler) Delete(c echo.Context) error {
req, err := bindAndValidate[deleteRollupRequest](c)
if err != nil {
return badRequestError(c, err)
}
if err := handler.deleteRollup(c.Request().Context(), req.Id); err != nil {
return handleError(c, err, handler.apps)
}
return success(c)
}
func (handler *AppHandler) deleteRollup(ctx context.Context, id uint64) error {
tx, err := postgres.BeginTransaction(ctx, handler.tx)
if err != nil {
return err
}
if err := tx.DeleteApp(ctx, id); err != nil {
return tx.HandleError(ctx, err)
}
return tx.Flush(ctx)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import "github.com/labstack/echo/v4"
func bindAndValidate[T any](c echo.Context) (*T, error) {
req := new(T)
if err := c.Bind(req); err != nil {
return req, err
}
if err := c.Validate(req); err != nil {
return req, err
}
return req, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"context"
"net/http"
sentryecho "github.com/getsentry/sentry-go/echo"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
)
var (
errInvalidAddress = errors.New("invalid address")
errCancelRequest = "pq: canceling statement due to user request"
)
type NoRows interface {
IsNoRows(err error) bool
}
type Error struct {
Message string `json:"message"`
}
func badRequestError(c echo.Context, err error) error {
return c.JSON(http.StatusBadRequest, Error{
Message: err.Error(),
})
}
func internalServerError(c echo.Context, err error) error {
if hub := sentryecho.GetHubFromContext(c); hub != nil {
hub.CaptureMessage(err.Error())
}
return c.JSON(http.StatusInternalServerError, Error{
Message: err.Error(),
})
}
func handleError(c echo.Context, err error, noRows NoRows) error {
if err == nil {
return nil
}
if err.Error() == errCancelRequest {
return nil
}
if errors.Is(err, context.DeadlineExceeded) {
return c.JSON(http.StatusRequestTimeout, Error{
Message: "timeout",
})
}
if errors.Is(err, context.Canceled) {
return c.JSON(http.StatusBadGateway, Error{
Message: err.Error(),
})
}
if noRows.IsNoRows(err) {
return c.NoContent(http.StatusNoContent)
}
if errors.Is(err, errInvalidAddress) {
return badRequestError(c, err)
}
return internalServerError(c, err)
}
func success(c echo.Context) error {
return c.JSON(http.StatusOK, echo.Map{
"message": "success",
})
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/labstack/echo/v4"
)
type StatusHandler struct {
}
func NewStatusHandler() *StatusHandler {
return &StatusHandler{}
}
func (handler *StatusHandler) Status(c echo.Context) error {
return c.String(http.StatusOK, "OK")
}
var _ Handler = (*StatusHandler)(nil)
func (handler *StatusHandler) InitRoutes(srvr *echo.Group) {
srvr.GET("/status", handler.Status)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package handler
import (
"net/http"
"github.com/celenium-io/astria-indexer/internal/astria"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/go-playground/validator/v10"
"github.com/labstack/echo/v4"
)
type ApiValidator struct {
validator *validator.Validate
}
func NewApiValidator() *ApiValidator {
v := validator.New()
if err := v.RegisterValidation("address", addressValidator()); err != nil {
panic(err)
}
if err := v.RegisterValidation("app_category", categoryValidator()); err != nil {
panic(err)
}
if err := v.RegisterValidation("app_type", appTypeValidator()); err != nil {
panic(err)
}
return &ApiValidator{validator: v}
}
func (v *ApiValidator) Validate(i interface{}) error {
if err := v.validator.Struct(i); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
return nil
}
func isAddress(address string) bool {
return astria.IsAddress(address)
}
func addressValidator() validator.Func {
return func(fl validator.FieldLevel) bool {
return isAddress(fl.Field().String())
}
}
func categoryValidator() validator.Func {
return func(fl validator.FieldLevel) bool {
_, err := types.ParseAppCategory(fl.Field().String())
return err == nil
}
}
func appTypeValidator() validator.Func {
return func(fl validator.FieldLevel) bool {
_, err := types.ParseAppType(fl.Field().String())
return err == nil
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"net/http"
"os"
"strconv"
"time"
"cosmossdk.io/errors"
"github.com/celenium-io/astria-indexer/cmd/private_api/handler"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/dipdup-net/go-lib/config"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"golang.org/x/time/rate"
)
func init() {
zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
short := file
for i := len(file) - 1; i > 0; i-- {
if file[i] == '/' {
short = file[i+1:]
break
}
}
file = short
return file + ":" + strconv.Itoa(line)
}
log.Logger = log.Logger.
Output(zerolog.ConsoleWriter{
Out: os.Stdout,
TimeFormat: "2006-01-02 15:04:05",
}).
With().Caller().
Logger()
}
func loadConfig() (*Config, error) {
configPath := rootCmd.PersistentFlags().StringP("config", "c", "dipdup.yml", "path to YAML config file")
if err := rootCmd.Execute(); err != nil {
return nil, errors.Wrap(err, "command line execute")
}
if err := rootCmd.MarkFlagRequired("config"); err != nil {
return nil, errors.Wrap(err, "config command line arg is required")
}
var cfg Config
if err := config.Parse(*configPath, &cfg); err != nil {
return nil, errors.Wrap(err, "parsing config file")
}
if cfg.LogLevel == "" {
cfg.LogLevel = zerolog.LevelInfoValue
}
if err := setLoggerLevel(cfg.LogLevel); err != nil {
return nil, errors.Wrap(err, "set log level")
}
return &cfg, nil
}
func setLoggerLevel(level string) error {
logLevel, err := zerolog.ParseLevel(level)
if err != nil {
return errors.Wrap(err, "parsing log level")
}
zerolog.SetGlobalLevel(logLevel)
return nil
}
func newServer(cfg *Config, handlers []handler.Handler) (*echo.Echo, error) {
e := echo.New()
e.Validator = handler.NewApiValidator()
timeout := 30 * time.Second
if cfg.ApiConfig.RequestTimeout > 0 {
timeout = time.Duration(cfg.ApiConfig.RequestTimeout) * time.Second
}
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
Skipper: middleware.DefaultSkipper,
Timeout: timeout,
}))
e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
LogURI: true,
LogStatus: true,
LogLatency: true,
LogMethod: true,
LogUserAgent: true,
LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
switch {
case v.Status == http.StatusOK || v.Status == http.StatusNoContent:
log.Info().
Str("uri", v.URI).
Int("status", v.Status).
Dur("latency", v.Latency).
Str("method", v.Method).
Str("user-agent", v.UserAgent).
Str("ip", c.RealIP()).
Msg("request")
case v.Status >= 500:
log.Error().
Str("uri", v.URI).
Int("status", v.Status).
Dur("latency", v.Latency).
Str("method", v.Method).
Str("user-agent", v.UserAgent).
Str("ip", c.RealIP()).
Msg("request")
default:
log.Warn().
Str("uri", v.URI).
Int("status", v.Status).
Dur("latency", v.Latency).
Str("method", v.Method).
Str("user-agent", v.UserAgent).
Str("ip", c.RealIP()).
Msg("request")
}
return nil
},
}))
e.Use(middleware.BodyLimit("2M"))
e.Use(middleware.CORS())
e.Use(middleware.Recover())
e.Use(middleware.Secure())
e.Pre(middleware.RemoveTrailingSlash())
if cfg.ApiConfig.RateLimit > 0 {
e.Use(middleware.RateLimiterWithConfig(middleware.RateLimiterConfig{
Skipper: middleware.DefaultSkipper,
Store: middleware.NewRateLimiterMemoryStore(rate.Limit(cfg.ApiConfig.RateLimit)),
}))
}
e.Server.IdleTimeout = time.Second * 30
v1 := e.Group("v1")
for _, handler := range handlers {
handler.InitRoutes(v1)
}
log.Info().Msg("API routes:")
for _, route := range e.Routes() {
log.Info().Msgf("[%s] %s -> %s", route.Method, route.Path, route.Name)
}
return e, nil
}
func newDatabase(cfg *Config) (*sdk.Storage, error) {
return postgres.Create(context.Background(), cfg.Database, cfg.Indexer.ScriptsDir, false)
}
func newTransactable(db *sdk.Storage) storage.Transactable {
return db.Transactable
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"os"
"os/signal"
"syscall"
"time"
"github.com/celenium-io/astria-indexer/cmd/private_api/handler"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/ipfans/fxlogger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"go.uber.org/fx"
)
var rootCmd = &cobra.Command{
Use: "private_api",
}
func main() {
app := fx.New(
fx.WithLogger(fxlogger.WithZerolog(log.Logger)),
fx.StartTimeout(5*time.Minute),
fx.Provide(
loadConfig,
fx.Annotate(
newServer,
fx.ParamTags("", `group:"handlers"`),
),
newApp,
newDatabase,
newTransactable,
fx.Annotate(
postgres.NewAddress,
fx.As(new(storage.IAddress)),
),
fx.Annotate(
postgres.NewApp,
fx.As(new(storage.IApp)),
),
fx.Annotate(
postgres.NewRollup,
fx.As(new(storage.IRollup)),
),
AsHandler(handler.NewAppHandler),
),
fx.Invoke(func(*App) {}),
)
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
if err := app.Start(ctx); err != nil {
log.Err(err).Msg("start app")
os.Exit(1)
}
<-ctx.Done()
cancel()
if err := app.Stop(ctx); err != nil {
log.Err(err).Msg("stop app")
os.Exit(1)
}
}
func AsHandler(f any) any {
return fx.Annotate(
f,
fx.As(new(handler.Handler)),
fx.ResultTags(`group:"handlers"`),
)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package astria
import (
"encoding/hex"
"github.com/cosmos/btcutil/bech32"
"github.com/pactus-project/pactus/util/bech32m"
)
const (
prefix = "astria"
prefixCompat = "astriacompat"
)
func IsAddress(s string) bool {
if len(s) != 45 {
return false
}
p, _, err := bech32m.Decode(s)
if err != nil {
return false
}
return p == prefix
}
func IsCompatAddress(s string) bool {
if len(s) != 51 {
return false
}
p, _, err := bech32.DecodeToBase256(s)
if err != nil {
return false
}
return p == prefixCompat
}
func EncodeAddress(b []byte) (string, error) {
return bech32m.EncodeFromBase256(prefix, b)
}
func DecodeAddress(s string) ([]byte, error) {
_, b, err := bech32m.DecodeToBase256(s)
return b, err
}
func CompatToAstria(s string) (string, error) {
_, b, err := bech32.DecodeToBase256(s)
if err != nil {
return "", err
}
return EncodeAddress(b)
}
func EncodeFromHex(s string) (string, error) {
hash, err := hex.DecodeString(s)
if err != nil {
return "", err
}
return EncodeAddress(hash)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package currency
import "github.com/shopspring/decimal"
type Denom string
const (
Nria Denom = "nria"
Ria Denom = "ria"
)
const (
DefaultCurrency = "nria"
)
func StringRia(val decimal.Decimal) string {
return val.StringFixed(6)
}
func StringNria(val decimal.Decimal) string {
return val.StringFixed(0)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package profiler
import (
"fmt"
"runtime"
"github.com/grafana/pyroscope-go"
)
type Config struct {
Server string `validate:"omitempty,http_url" yaml:"server"`
Project string `validate:"omitempty" yaml:"project"`
}
func New(cfg *Config, service string) (*pyroscope.Profiler, error) {
if cfg == nil || cfg.Server == "" {
return nil, nil
}
runtime.SetMutexProfileFraction(5)
runtime.SetBlockProfileRate(5)
return pyroscope.Start(pyroscope.Config{
ApplicationName: fmt.Sprintf("%s-%s", cfg.Project, service),
ServerAddress: cfg.Server,
Tags: map[string]string{
"project": cfg.Project,
"service": service,
},
ProfileTypes: []pyroscope.ProfileType{
pyroscope.ProfileCPU,
pyroscope.ProfileAllocObjects,
pyroscope.ProfileAllocSpace,
pyroscope.ProfileInuseObjects,
pyroscope.ProfileInuseSpace,
pyroscope.ProfileGoroutines,
pyroscope.ProfileMutexCount,
pyroscope.ProfileMutexDuration,
pyroscope.ProfileBlockCount,
pyroscope.ProfileBlockDuration,
},
})
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IAction interface {
storage.Table[*Action]
ByTxId(ctx context.Context, txId uint64, limit, offset int) ([]Action, error)
ByBlock(ctx context.Context, height pkgTypes.Level, limit, offset int) ([]ActionWithTx, error)
ByAddress(ctx context.Context, addressId uint64, filters AddressActionsFilter) ([]AddressAction, error)
ByRollup(ctx context.Context, rollupId uint64, limit, offset int, sort storage.SortOrder) ([]RollupAction, error)
ByRollupAndBridge(ctx context.Context, rollupId uint64, fltrs RollupAndBridgeActionsFilter) ([]ActionWithTx, error)
}
type AddressActionsFilter struct {
Limit int
Offset int
Sort storage.SortOrder
ActionTypes types.ActionTypeMask
}
type RollupAndBridgeActionsFilter struct {
Limit int
Offset int
Sort storage.SortOrder
RollupActions bool
BridgeActions bool
ActionTypes types.ActionTypeMask
From time.Time
To time.Time
}
type ActionWithTx struct {
bun.BaseModel `bun:"action"`
Action
Tx *Tx `bun:"rel:belongs-to"`
}
// Action -
type Action struct {
bun.BaseModel `bun:"action" comment:"Table with actions"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal id"`
Height pkgTypes.Level `bun:",notnull" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
Position int64 `bun:"position" comment:"Position in transaction"`
Type types.ActionType `bun:",type:action_type" comment:"Action type"`
TxId uint64 `bun:"tx_id" comment:"Parent transaction id"`
Data map[string]any `bun:"data,type:jsonb" comment:"Action data"`
// Rollup *Rollup `bun:"-"`
Addresses []*AddressAction `bun:"-"`
BalanceUpdates []BalanceUpdate `bun:"-"`
RollupAction *RollupAction `bun:"-"`
Fee *Fee `bun:"rel:has-one,join:id=action_id"`
Deposit *Deposit `bun:"rel:has-one,join:id=action_id"`
}
// TableName -
func (Action) TableName() string {
return "action"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
type AddressListFilter struct {
Limit int
Offset int
Sort storage.SortOrder
Asset string
}
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IAddress interface {
storage.Table[*Address]
ByHash(ctx context.Context, hash string) (Address, error)
ListWithBalance(ctx context.Context, fltrs AddressListFilter) ([]Address, error)
}
// Address -
type Address struct {
bun.BaseModel `bun:"address" comment:"Table with addresses."`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Height types.Level `bun:"height" comment:"Block number of the first address occurrence."`
Hash string `bun:"hash,unique:address_hash" comment:"Address hash"`
Nonce uint32 `bun:"nonce" comment:"Nonce"`
ActionsCount int64 `bun:"actions_count" comment:"Count of actions in which the address was involved"`
SignedTxCount int64 `bun:"signed_tx_count" comment:"Count of signed transactions"`
IsBridge bool `bun:"is_bridge" comment:"Indicate whether the account is a bridge or not"`
IsIbcRelayer *bool `bun:"is_ibc_relayer,default:false" comment:"Indicate whether the account is a IBC realyer or not"`
Balance []*Balance `bun:"rel:has-many,join:id=id"`
}
// TableName -
func (Address) TableName() string {
return "address"
}
func (address Address) String() string {
return address.Hash
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"time"
"github.com/celenium-io/astria-indexer/internal/storage/types"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/uptrace/bun"
)
type AddressAction struct {
bun.BaseModel `bun:"address_action" comment:"Table with address actions"`
AddressId uint64 `bun:"address_id,pk" comment:"Address internal id"`
ActionId uint64 `bun:"action_id,pk" comment:"Action internal id"`
TxId uint64 `bun:"tx_id" comment:"Tx internal id"`
ActionType types.ActionType `bun:"action_type,type:action_type" comment:"Action type"`
Time time.Time `bun:"time,notnull,pk" comment:"Action time"`
Height pkgTypes.Level `bun:"height" comment:"Action block height"`
Address *Address `bun:"rel:belongs-to,join:address_id=id"`
Action *Action `bun:"rel:belongs-to,join:action_id=id"`
Tx *Tx `bun:"rel:belongs-to,join:tx_id=id"`
}
func (AddressAction) TableName() string {
return "address_action"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
type LeaderboardFilters struct {
SortField string
Sort storage.SortOrder
Limit int
Offset int
Category []types.AppCategory
}
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IApp interface {
storage.Table[*App]
Leaderboard(ctx context.Context, fltrs LeaderboardFilters) ([]AppWithStats, error)
BySlug(ctx context.Context, slug string) (AppWithStats, error)
ByRollupId(ctx context.Context, rollupId uint64) (AppWithStats, error)
}
type App struct {
bun.BaseModel `bun:"app" comment:"Table with applications."`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Group string `bun:"group" comment:"Application group"`
Name string `bun:"name" comment:"Application name"`
Slug string `bun:"slug,unique:app_slug" comment:"Application slug"`
Github string `bun:"github" comment:"Application github link"`
Twitter string `bun:"twitter" comment:"Application twitter account link"`
Website string `bun:"website" comment:"Application website link"`
Logo string `bun:"logo" comment:"Application logo link"`
Description string `bun:"description" comment:"Application description"`
Explorer string `bun:"explorer" comment:"Application explorer link"`
L2Beat string `bun:"l2beat" comment:"Link to L2Beat"`
Links []string `bun:"links,array" comment:"Additional links"`
Stack string `bun:"stack" comment:"Using stack"`
VM string `bun:"vm" comment:"Virtual machine"`
Provider string `bun:"provider" comment:"RaaS"`
Type types.AppType `bun:"type,type:app_type" comment:"Type of application: settled or sovereign"`
Category types.AppCategory `bun:"category,type:app_category" comment:"Category of applications"`
RollupId uint64 `bun:"rollup_id,notnull,unique:app_rollup_id" comment:"Rollup internal identity"`
NativeBridgeId uint64 `bun:"native_bridge_id" comment:"Native bridge internal id"`
Bridge *Address `bun:"rel:belongs-to"`
Rollup *Rollup `bun:"rel:belongs-to"`
}
func (App) TableName() string {
return "app"
}
func (app App) IsEmpty() bool {
return app.Group == "" &&
app.Name == "" &&
app.Slug == "" &&
app.Github == "" &&
app.Twitter == "" &&
app.Website == "" &&
app.Logo == "" &&
app.Description == "" &&
app.Explorer == "" &&
app.L2Beat == "" &&
app.Links == nil &&
app.Stack == "" &&
app.VM == "" &&
app.Provider == "" &&
app.Type == "" &&
app.Category == "" &&
app.RollupId == 0 &&
app.NativeBridgeId == 0
}
type AppWithStats struct {
App
AppStats
}
type AppStats struct {
Size int64 `bun:"size"`
MinSize int64 `bun:"min_size"`
MaxSize int64 `bun:"max_size"`
AvgSize float64 `bun:"avg_size"`
ActionsCount int64 `bun:"actions_count"`
LastActionTime time.Time `bun:"last_time"`
FirstActionTime time.Time `bun:"first_time"`
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"github.com/celenium-io/astria-indexer/internal/currency"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IBalance interface {
storage.Table[*Balance]
}
type Balance struct {
bun.BaseModel `bun:"balance" comment:"Table with account balances"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Currency string `bun:"currency,pk,notnull" comment:"Balance currency"`
Total decimal.Decimal `bun:"total,type:numeric" comment:"Total account balance"`
}
func (Balance) TableName() string {
return "balance"
}
func (b Balance) IsEmpty() bool {
return b.Currency == "" && b.Total.IsZero()
}
func EmptyBalance() Balance {
return Balance{
Total: decimal.Zero,
Currency: currency.DefaultCurrency,
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IBalanceUpdate interface {
storage.Table[*BalanceUpdate]
}
type BalanceUpdate struct {
bun.BaseModel `bun:"balance_update" comment:"Table with account balance updates"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Height pkgTypes.Level `bun:",notnull" comment:"The number (height) of this block"`
AddressId uint64 `bun:"address_id" comment:"Address internal identity"`
Update decimal.Decimal `bun:"update,type:numeric" comment:"Balance update"`
Currency string `bun:"currency" comment:"Currency"`
Address *Address `bun:"rel:belongs-to"`
}
func (BalanceUpdate) TableName() string {
return "balance_update"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
"github.com/celenium-io/astria-indexer/internal/storage/types"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IBlock interface {
storage.Table[*Block]
Last(ctx context.Context) (Block, error)
ByHeight(ctx context.Context, height pkgTypes.Level, withStats bool) (Block, error)
ByHash(ctx context.Context, hash []byte) (Block, error)
ByProposer(ctx context.Context, proposerId uint64, limit, offset int, order storage.SortOrder) ([]Block, error)
ListWithStats(ctx context.Context, limit, offset uint64, order storage.SortOrder) ([]*Block, error)
ByIdWithRelations(ctx context.Context, id uint64) (Block, error)
}
// Block -
type Block struct {
bun.BaseModel `bun:"table:block" comment:"Table with blocks"`
Id uint64 `bun:",pk,notnull,autoincrement" comment:"Unique internal identity"`
Height pkgTypes.Level `bun:"height" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
VersionBlock uint64 `bun:"version_block" comment:"Block version"`
VersionApp uint64 `bun:"version_app" comment:"App version"`
Hash pkgTypes.Hex `bun:"hash" comment:"Block hash"`
ParentHash pkgTypes.Hex `bun:"parent_hash" comment:"Hash of parent block"`
LastCommitHash pkgTypes.Hex `bun:"last_commit_hash" comment:"Last commit hash"`
DataHash pkgTypes.Hex `bun:"data_hash" comment:"Data hash"`
ValidatorsHash pkgTypes.Hex `bun:"validators_hash" comment:"Validators hash"`
NextValidatorsHash pkgTypes.Hex `bun:"next_validators_hash" comment:"Next validators hash"`
ConsensusHash pkgTypes.Hex `bun:"consensus_hash" comment:"Consensus hash"`
AppHash pkgTypes.Hex `bun:"app_hash" comment:"App hash"`
LastResultsHash pkgTypes.Hex `bun:"last_results_hash" comment:"Last results hash"`
EvidenceHash pkgTypes.Hex `bun:"evidence_hash" comment:"Evidence hash"`
ProposerId uint64 `bun:"proposer_id,nullzero" comment:"Proposer internal id"`
ActionTypes types.Bits `bun:"action_types" comment:"Bit mask for action types contained in block"`
ChainId string `bun:"-"` // internal field for filling state
ProposerAddress string `bun:"-"` // internal field for proposer
Addresses map[string]*Address `bun:"-"` // internal field for saving address
Rollups map[string]*Rollup `bun:"-"` // internal field for saving rollups
RollupAddress map[string]*RollupAddress `bun:"-"` // internal field for saving rollup address
Validators map[string]*Validator `bun:"-"` // internal field for updating validators
BlockSignatures []BlockSignature `bun:"-"` // internal field for saving block signatures
Constants []*Constant `bun:"-"` // internal field for updating constants
Bridges []*Bridge `bun:"-"` // internal field for saving bridges
Transfers []*Transfer `bun:"-"` // internal field for saving transfers
MarketUpdates []MarketUpdate `bun:"-"` // internal field for saving market updates
MarketProviders []MarketProviderUpdate `bun:"-"` // internal field for saving market providers
Txs []*Tx `bun:"rel:has-many"`
Stats *BlockStats `bun:"rel:has-one,join:height=height"`
Proposer *Validator `bun:"rel:belongs-to"`
Prices []Price `bun:"rel:has-many,join:time=time"`
}
// TableName -
func (Block) TableName() string {
return "block"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IBlockSignature interface {
storage.Table[*BlockSignature]
LevelsByValidator(ctx context.Context, validatorId uint64, startHeight pkgTypes.Level) ([]pkgTypes.Level, error)
}
type BlockSignature struct {
bun.BaseModel `bun:"block_signature" comment:"Table with block signatures"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal id"`
Height pkgTypes.Level `bun:",notnull" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
ValidatorId uint64 `bun:"validator_id" comment:"Validator's internal identity"`
Validator *Validator `bun:"rel:belongs-to"`
}
func (BlockSignature) TableName() string {
return "block_signature"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IBlockStats interface {
ByHeight(ctx context.Context, height pkgTypes.Level) (stats BlockStats, err error)
}
type BlockStats struct {
bun.BaseModel `bun:"table:block_stats" comment:"Table with block stats"`
Id uint64 `bun:",pk,notnull,autoincrement" comment:"Unique internal identity"`
Height pkgTypes.Level `bun:"height" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
TxCount int64 `bun:"tx_count" comment:"Count of transactions in block"`
BlockTime uint64 `bun:"block_time" comment:"Time in milliseconds between current and previous block"`
SupplyChange decimal.Decimal `bun:",type:numeric" comment:"Change of total supply in the block"`
Fee decimal.Decimal `bun:"fee,type:numeric" comment:"Summary block fee"`
BytesInBlock int64 `bun:"bytes_in_block" comment:"Size of all transactions in bytes"`
DataSize int64 `bun:"data_size" comment:"Size of all rollup data in block"`
}
func (BlockStats) TableName() string {
return "block_stats"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IBridge interface {
storage.Table[*Bridge]
ByAddress(ctx context.Context, addressId uint64) (Bridge, error)
ByRollup(ctx context.Context, rollupId uint64, limit, offset int) ([]Bridge, error)
ByRoles(ctx context.Context, addressId uint64, limit, offset int) ([]Bridge, error)
ListWithAddress(ctx context.Context, limit, offset int) ([]Bridge, error)
ById(ctx context.Context, id uint64) (Bridge, error)
}
type Bridge struct {
bun.BaseModel `bun:"table:bridge" comment:"Table with bridges"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
RollupId uint64 `bun:"rollup_id" comment:"Rollup id"`
AddressId uint64 `bun:"address_id,unique:bridge_address_id" comment:"Address id"`
Asset string `bun:"asset" comment:"Asset"`
FeeAsset string `bun:"fee_asset" comment:"Fee asset"`
SudoId uint64 `bun:"sudo_id" comment:"Address which is authorized to change the bridge"`
WithdrawerId uint64 `bun:"withdrawer_id" comment:"Address which is used to make withdrawals from the bridge account"`
InitHeight pkgTypes.Level `bun:"init_height" comment:"Height when bridge was initialized"`
Rollup *Rollup `bun:"rel:has-one,join:rollup_id=id"`
Address *Address `bun:"rel:has-one,join:address_id=id"`
Sudo *Address `bun:"rel:has-one,join:sudo_id=id"`
Withdrawer *Address `bun:"rel:has-one,join:withdrawer_id=id"`
}
func (Bridge) TableName() string {
return "bridge"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IConstant interface {
Get(ctx context.Context, module types.ModuleName, name string) (Constant, error)
ByModule(ctx context.Context, module types.ModuleName) ([]Constant, error)
All(ctx context.Context) ([]Constant, error)
IsNoRows(err error) bool
}
type Constant struct {
bun.BaseModel `bun:"table:constant" comment:"Table with constants"`
Module types.ModuleName `bun:"module,pk,type:module_name" comment:"Module name which declares constant" json:"module"`
Name string `bun:"name,pk,type:text" comment:"Constant name" json:"name"`
Value string `bun:"value,type:text" comment:"Constant value" json:"value"`
}
func (Constant) TableName() string {
return "constant"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IDeposit interface {
storage.Table[*Deposit]
ByBridgeId(ctx context.Context, bridgeId uint64, limit, offset int, sort storage.SortOrder) ([]Deposit, error)
ByRollupId(ctx context.Context, rollupId uint64, limit, offset int, sort storage.SortOrder) ([]Deposit, error)
}
type Deposit struct {
bun.BaseModel `bun:"deposit" comment:"Table with deposits"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal id"`
Height pkgTypes.Level `bun:",notnull" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
BridgeId uint64 `bun:"bridge_id" comment:"Bridge id"`
RollupId uint64 `bun:"rollup_id" comment:"Rollup id"`
Asset string `bun:"asset" comment:"Deposit asset"`
Amount decimal.Decimal `bun:"amount,type:numeric" comment:"Deposit amount"`
DestinationChainAddress string `bun:"destination_chain_address" comment:"Destination chain address"`
ActionId uint64 `bun:"action_id" comment:"Internal action id"`
TxId uint64 `bun:"tx_id" comment:"Internal transaction id"`
Bridge *Bridge `bun:"rel:belongs-to"`
Rollup *Rollup `bun:"rel:belongs-to"`
Action *Action `bun:"rel:belongs-to"`
Tx *Tx `bun:"rel:belongs-to"`
}
func (*Deposit) TableName() string {
return "deposit"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IFee interface {
storage.Table[*Fee]
ByTxId(ctx context.Context, id uint64, limit, offset int) ([]Fee, error)
ByPayerId(ctx context.Context, id uint64, limit, offset int, sort storage.SortOrder) ([]Fee, error)
FullTxFee(ctx context.Context, id uint64) ([]Fee, error)
}
type Fee struct {
bun.BaseModel `bun:"table:fee" comment:"Table with fees"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Height pkgTypes.Level `bun:"height,notnull" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
Asset string `bun:"asset" comment:"Fee asset"`
Amount decimal.Decimal `bun:"amount,type:numeric" comment:"Fee amount"`
ActionId uint64 `bun:"action_id" comment:"Connected action id"`
TxId uint64 `bun:"tx_id" comment:"Connected transaction id"`
PayerId uint64 `bun:"payer_id" comment:"Who paid fee"`
ActionType string `bun:"-"`
Payer *Address `bun:"rel:belongs-to"`
Tx *Tx `bun:"rel:belongs-to"`
}
func (Fee) TableName() string {
return "fee"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IMarket interface {
List(ctx context.Context, limit, offset int) ([]Market, error)
Get(ctx context.Context, pair string) (Market, error)
Decimals(ctx context.Context, pair string) (int, error)
}
type Market struct {
bun.BaseModel `bun:"table:market" comment:"Table with markets"`
Pair string `bun:"pair,pk" comment:"Trading pair"`
Decimals int `bun:"decimals" comment:"Decimals"`
Enabled bool `bun:"enabled" comment:"Is market enabled"`
MinProviderCount int `bun:"min_provider_count" comment:"Minimum provider count"`
Base string `bun:"base" comment:"Base asset"`
Quote string `bun:"quote" comment:"Quote asset"`
Price *Price `bun:"rel:has-one,join:pair=currency_pair"`
Providers []*MarketProvider `bun:"rel:has-many,join:pair=pair"`
}
func (Market) TableName() string {
return "market"
}
type MarketUpdate struct {
Market
Type MarketUpdateType
}
type MarketUpdateType string
const (
MarketUpdateTypeCreate MarketUpdateType = "create"
MarketUpdateTypeRemove MarketUpdateType = "remove"
MarketUpdateTypeUpdate MarketUpdateType = "update"
)
package storage
import "github.com/uptrace/bun"
type MarketProvider struct {
bun.BaseModel `bun:"table:market_provider" comment:"Table with market's providers"`
Pair string `bun:"pair,pk" comment:"Trading pair"`
Provider string `bun:"provider,pk" comment:"Provider"`
OffChainTicker string `bun:"off_chain_ticker" comment:"Off chain ticker"`
}
func (MarketProvider) TableName() string {
return "market_provider"
}
type MarketProviderUpdate struct {
MarketProvider
Type MarketUpdateType
}
// Code generated by MockGen. DO NOT EDIT.
// Source: action.go
//
// Generated by this command:
//
// mockgen -source=action.go -destination=mock/action.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
types "github.com/celenium-io/astria-indexer/pkg/types"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIAction is a mock of IAction interface.
type MockIAction struct {
ctrl *gomock.Controller
recorder *MockIActionMockRecorder
}
// MockIActionMockRecorder is the mock recorder for MockIAction.
type MockIActionMockRecorder struct {
mock *MockIAction
}
// NewMockIAction creates a new mock instance.
func NewMockIAction(ctrl *gomock.Controller) *MockIAction {
mock := &MockIAction{ctrl: ctrl}
mock.recorder = &MockIActionMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIAction) EXPECT() *MockIActionMockRecorder {
return m.recorder
}
// ByAddress mocks base method.
func (m *MockIAction) ByAddress(ctx context.Context, addressId uint64, filters storage.AddressActionsFilter) ([]storage.AddressAction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByAddress", ctx, addressId, filters)
ret0, _ := ret[0].([]storage.AddressAction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByAddress indicates an expected call of ByAddress.
func (mr *MockIActionMockRecorder) ByAddress(ctx, addressId, filters any) *MockIActionByAddressCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByAddress", reflect.TypeOf((*MockIAction)(nil).ByAddress), ctx, addressId, filters)
return &MockIActionByAddressCall{Call: call}
}
// MockIActionByAddressCall wrap *gomock.Call
type MockIActionByAddressCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionByAddressCall) Return(arg0 []storage.AddressAction, arg1 error) *MockIActionByAddressCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionByAddressCall) Do(f func(context.Context, uint64, storage.AddressActionsFilter) ([]storage.AddressAction, error)) *MockIActionByAddressCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionByAddressCall) DoAndReturn(f func(context.Context, uint64, storage.AddressActionsFilter) ([]storage.AddressAction, error)) *MockIActionByAddressCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByBlock mocks base method.
func (m *MockIAction) ByBlock(ctx context.Context, height types.Level, limit, offset int) ([]storage.ActionWithTx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByBlock", ctx, height, limit, offset)
ret0, _ := ret[0].([]storage.ActionWithTx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByBlock indicates an expected call of ByBlock.
func (mr *MockIActionMockRecorder) ByBlock(ctx, height, limit, offset any) *MockIActionByBlockCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByBlock", reflect.TypeOf((*MockIAction)(nil).ByBlock), ctx, height, limit, offset)
return &MockIActionByBlockCall{Call: call}
}
// MockIActionByBlockCall wrap *gomock.Call
type MockIActionByBlockCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionByBlockCall) Return(arg0 []storage.ActionWithTx, arg1 error) *MockIActionByBlockCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionByBlockCall) Do(f func(context.Context, types.Level, int, int) ([]storage.ActionWithTx, error)) *MockIActionByBlockCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionByBlockCall) DoAndReturn(f func(context.Context, types.Level, int, int) ([]storage.ActionWithTx, error)) *MockIActionByBlockCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByRollup mocks base method.
func (m *MockIAction) ByRollup(ctx context.Context, rollupId uint64, limit, offset int, sort storage0.SortOrder) ([]storage.RollupAction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByRollup", ctx, rollupId, limit, offset, sort)
ret0, _ := ret[0].([]storage.RollupAction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByRollup indicates an expected call of ByRollup.
func (mr *MockIActionMockRecorder) ByRollup(ctx, rollupId, limit, offset, sort any) *MockIActionByRollupCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByRollup", reflect.TypeOf((*MockIAction)(nil).ByRollup), ctx, rollupId, limit, offset, sort)
return &MockIActionByRollupCall{Call: call}
}
// MockIActionByRollupCall wrap *gomock.Call
type MockIActionByRollupCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionByRollupCall) Return(arg0 []storage.RollupAction, arg1 error) *MockIActionByRollupCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionByRollupCall) Do(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.RollupAction, error)) *MockIActionByRollupCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionByRollupCall) DoAndReturn(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.RollupAction, error)) *MockIActionByRollupCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByRollupAndBridge mocks base method.
func (m *MockIAction) ByRollupAndBridge(ctx context.Context, rollupId uint64, fltrs storage.RollupAndBridgeActionsFilter) ([]storage.ActionWithTx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByRollupAndBridge", ctx, rollupId, fltrs)
ret0, _ := ret[0].([]storage.ActionWithTx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByRollupAndBridge indicates an expected call of ByRollupAndBridge.
func (mr *MockIActionMockRecorder) ByRollupAndBridge(ctx, rollupId, fltrs any) *MockIActionByRollupAndBridgeCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByRollupAndBridge", reflect.TypeOf((*MockIAction)(nil).ByRollupAndBridge), ctx, rollupId, fltrs)
return &MockIActionByRollupAndBridgeCall{Call: call}
}
// MockIActionByRollupAndBridgeCall wrap *gomock.Call
type MockIActionByRollupAndBridgeCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionByRollupAndBridgeCall) Return(arg0 []storage.ActionWithTx, arg1 error) *MockIActionByRollupAndBridgeCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionByRollupAndBridgeCall) Do(f func(context.Context, uint64, storage.RollupAndBridgeActionsFilter) ([]storage.ActionWithTx, error)) *MockIActionByRollupAndBridgeCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionByRollupAndBridgeCall) DoAndReturn(f func(context.Context, uint64, storage.RollupAndBridgeActionsFilter) ([]storage.ActionWithTx, error)) *MockIActionByRollupAndBridgeCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByTxId mocks base method.
func (m *MockIAction) ByTxId(ctx context.Context, txId uint64, limit, offset int) ([]storage.Action, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByTxId", ctx, txId, limit, offset)
ret0, _ := ret[0].([]storage.Action)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByTxId indicates an expected call of ByTxId.
func (mr *MockIActionMockRecorder) ByTxId(ctx, txId, limit, offset any) *MockIActionByTxIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByTxId", reflect.TypeOf((*MockIAction)(nil).ByTxId), ctx, txId, limit, offset)
return &MockIActionByTxIdCall{Call: call}
}
// MockIActionByTxIdCall wrap *gomock.Call
type MockIActionByTxIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionByTxIdCall) Return(arg0 []storage.Action, arg1 error) *MockIActionByTxIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionByTxIdCall) Do(f func(context.Context, uint64, int, int) ([]storage.Action, error)) *MockIActionByTxIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionByTxIdCall) DoAndReturn(f func(context.Context, uint64, int, int) ([]storage.Action, error)) *MockIActionByTxIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIAction) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Action, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Action)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIActionMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIActionCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIAction)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIActionCursorListCall{Call: call}
}
// MockIActionCursorListCall wrap *gomock.Call
type MockIActionCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionCursorListCall) Return(arg0 []*storage.Action, arg1 error) *MockIActionCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Action, error)) *MockIActionCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Action, error)) *MockIActionCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIAction) GetByID(ctx context.Context, id uint64) (*storage.Action, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Action)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIActionMockRecorder) GetByID(ctx, id any) *MockIActionGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIAction)(nil).GetByID), ctx, id)
return &MockIActionGetByIDCall{Call: call}
}
// MockIActionGetByIDCall wrap *gomock.Call
type MockIActionGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionGetByIDCall) Return(arg0 *storage.Action, arg1 error) *MockIActionGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionGetByIDCall) Do(f func(context.Context, uint64) (*storage.Action, error)) *MockIActionGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Action, error)) *MockIActionGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIAction) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIActionMockRecorder) IsNoRows(err any) *MockIActionIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIAction)(nil).IsNoRows), err)
return &MockIActionIsNoRowsCall{Call: call}
}
// MockIActionIsNoRowsCall wrap *gomock.Call
type MockIActionIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionIsNoRowsCall) Return(arg0 bool) *MockIActionIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionIsNoRowsCall) Do(f func(error) bool) *MockIActionIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIActionIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIAction) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIActionMockRecorder) LastID(ctx any) *MockIActionLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIAction)(nil).LastID), ctx)
return &MockIActionLastIDCall{Call: call}
}
// MockIActionLastIDCall wrap *gomock.Call
type MockIActionLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionLastIDCall) Return(arg0 uint64, arg1 error) *MockIActionLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIActionLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIActionLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIAction) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Action, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Action)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIActionMockRecorder) List(ctx, limit, offset, order any) *MockIActionListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIAction)(nil).List), ctx, limit, offset, order)
return &MockIActionListCall{Call: call}
}
// MockIActionListCall wrap *gomock.Call
type MockIActionListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionListCall) Return(arg0 []*storage.Action, arg1 error) *MockIActionListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Action, error)) *MockIActionListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Action, error)) *MockIActionListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIAction) Save(ctx context.Context, m *storage.Action) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIActionMockRecorder) Save(ctx, m any) *MockIActionSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIAction)(nil).Save), ctx, m)
return &MockIActionSaveCall{Call: call}
}
// MockIActionSaveCall wrap *gomock.Call
type MockIActionSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionSaveCall) Return(arg0 error) *MockIActionSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionSaveCall) Do(f func(context.Context, *storage.Action) error) *MockIActionSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionSaveCall) DoAndReturn(f func(context.Context, *storage.Action) error) *MockIActionSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIAction) Update(ctx context.Context, m *storage.Action) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIActionMockRecorder) Update(ctx, m any) *MockIActionUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIAction)(nil).Update), ctx, m)
return &MockIActionUpdateCall{Call: call}
}
// MockIActionUpdateCall wrap *gomock.Call
type MockIActionUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIActionUpdateCall) Return(arg0 error) *MockIActionUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIActionUpdateCall) Do(f func(context.Context, *storage.Action) error) *MockIActionUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIActionUpdateCall) DoAndReturn(f func(context.Context, *storage.Action) error) *MockIActionUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: address.go
//
// Generated by this command:
//
// mockgen -source=address.go -destination=mock/address.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIAddress is a mock of IAddress interface.
type MockIAddress struct {
ctrl *gomock.Controller
recorder *MockIAddressMockRecorder
}
// MockIAddressMockRecorder is the mock recorder for MockIAddress.
type MockIAddressMockRecorder struct {
mock *MockIAddress
}
// NewMockIAddress creates a new mock instance.
func NewMockIAddress(ctrl *gomock.Controller) *MockIAddress {
mock := &MockIAddress{ctrl: ctrl}
mock.recorder = &MockIAddressMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIAddress) EXPECT() *MockIAddressMockRecorder {
return m.recorder
}
// ByHash mocks base method.
func (m *MockIAddress) ByHash(ctx context.Context, hash string) (storage.Address, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByHash", ctx, hash)
ret0, _ := ret[0].(storage.Address)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByHash indicates an expected call of ByHash.
func (mr *MockIAddressMockRecorder) ByHash(ctx, hash any) *MockIAddressByHashCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByHash", reflect.TypeOf((*MockIAddress)(nil).ByHash), ctx, hash)
return &MockIAddressByHashCall{Call: call}
}
// MockIAddressByHashCall wrap *gomock.Call
type MockIAddressByHashCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressByHashCall) Return(arg0 storage.Address, arg1 error) *MockIAddressByHashCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressByHashCall) Do(f func(context.Context, string) (storage.Address, error)) *MockIAddressByHashCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressByHashCall) DoAndReturn(f func(context.Context, string) (storage.Address, error)) *MockIAddressByHashCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIAddress) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Address, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Address)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIAddressMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIAddressCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIAddress)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIAddressCursorListCall{Call: call}
}
// MockIAddressCursorListCall wrap *gomock.Call
type MockIAddressCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressCursorListCall) Return(arg0 []*storage.Address, arg1 error) *MockIAddressCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Address, error)) *MockIAddressCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Address, error)) *MockIAddressCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIAddress) GetByID(ctx context.Context, id uint64) (*storage.Address, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Address)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIAddressMockRecorder) GetByID(ctx, id any) *MockIAddressGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIAddress)(nil).GetByID), ctx, id)
return &MockIAddressGetByIDCall{Call: call}
}
// MockIAddressGetByIDCall wrap *gomock.Call
type MockIAddressGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressGetByIDCall) Return(arg0 *storage.Address, arg1 error) *MockIAddressGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressGetByIDCall) Do(f func(context.Context, uint64) (*storage.Address, error)) *MockIAddressGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Address, error)) *MockIAddressGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIAddress) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIAddressMockRecorder) IsNoRows(err any) *MockIAddressIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIAddress)(nil).IsNoRows), err)
return &MockIAddressIsNoRowsCall{Call: call}
}
// MockIAddressIsNoRowsCall wrap *gomock.Call
type MockIAddressIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressIsNoRowsCall) Return(arg0 bool) *MockIAddressIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressIsNoRowsCall) Do(f func(error) bool) *MockIAddressIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIAddressIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIAddress) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIAddressMockRecorder) LastID(ctx any) *MockIAddressLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIAddress)(nil).LastID), ctx)
return &MockIAddressLastIDCall{Call: call}
}
// MockIAddressLastIDCall wrap *gomock.Call
type MockIAddressLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressLastIDCall) Return(arg0 uint64, arg1 error) *MockIAddressLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIAddressLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIAddressLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIAddress) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Address, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Address)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIAddressMockRecorder) List(ctx, limit, offset, order any) *MockIAddressListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIAddress)(nil).List), ctx, limit, offset, order)
return &MockIAddressListCall{Call: call}
}
// MockIAddressListCall wrap *gomock.Call
type MockIAddressListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressListCall) Return(arg0 []*storage.Address, arg1 error) *MockIAddressListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Address, error)) *MockIAddressListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Address, error)) *MockIAddressListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ListWithBalance mocks base method.
func (m *MockIAddress) ListWithBalance(ctx context.Context, fltrs storage.AddressListFilter) ([]storage.Address, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListWithBalance", ctx, fltrs)
ret0, _ := ret[0].([]storage.Address)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListWithBalance indicates an expected call of ListWithBalance.
func (mr *MockIAddressMockRecorder) ListWithBalance(ctx, fltrs any) *MockIAddressListWithBalanceCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWithBalance", reflect.TypeOf((*MockIAddress)(nil).ListWithBalance), ctx, fltrs)
return &MockIAddressListWithBalanceCall{Call: call}
}
// MockIAddressListWithBalanceCall wrap *gomock.Call
type MockIAddressListWithBalanceCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressListWithBalanceCall) Return(arg0 []storage.Address, arg1 error) *MockIAddressListWithBalanceCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressListWithBalanceCall) Do(f func(context.Context, storage.AddressListFilter) ([]storage.Address, error)) *MockIAddressListWithBalanceCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressListWithBalanceCall) DoAndReturn(f func(context.Context, storage.AddressListFilter) ([]storage.Address, error)) *MockIAddressListWithBalanceCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIAddress) Save(ctx context.Context, m *storage.Address) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIAddressMockRecorder) Save(ctx, m any) *MockIAddressSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIAddress)(nil).Save), ctx, m)
return &MockIAddressSaveCall{Call: call}
}
// MockIAddressSaveCall wrap *gomock.Call
type MockIAddressSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressSaveCall) Return(arg0 error) *MockIAddressSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressSaveCall) Do(f func(context.Context, *storage.Address) error) *MockIAddressSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressSaveCall) DoAndReturn(f func(context.Context, *storage.Address) error) *MockIAddressSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIAddress) Update(ctx context.Context, m *storage.Address) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIAddressMockRecorder) Update(ctx, m any) *MockIAddressUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIAddress)(nil).Update), ctx, m)
return &MockIAddressUpdateCall{Call: call}
}
// MockIAddressUpdateCall wrap *gomock.Call
type MockIAddressUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAddressUpdateCall) Return(arg0 error) *MockIAddressUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAddressUpdateCall) Do(f func(context.Context, *storage.Address) error) *MockIAddressUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAddressUpdateCall) DoAndReturn(f func(context.Context, *storage.Address) error) *MockIAddressUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: app.go
//
// Generated by this command:
//
// mockgen -source=app.go -destination=mock/app.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIApp is a mock of IApp interface.
type MockIApp struct {
ctrl *gomock.Controller
recorder *MockIAppMockRecorder
}
// MockIAppMockRecorder is the mock recorder for MockIApp.
type MockIAppMockRecorder struct {
mock *MockIApp
}
// NewMockIApp creates a new mock instance.
func NewMockIApp(ctrl *gomock.Controller) *MockIApp {
mock := &MockIApp{ctrl: ctrl}
mock.recorder = &MockIAppMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIApp) EXPECT() *MockIAppMockRecorder {
return m.recorder
}
// ByRollupId mocks base method.
func (m *MockIApp) ByRollupId(ctx context.Context, rollupId uint64) (storage.AppWithStats, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByRollupId", ctx, rollupId)
ret0, _ := ret[0].(storage.AppWithStats)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByRollupId indicates an expected call of ByRollupId.
func (mr *MockIAppMockRecorder) ByRollupId(ctx, rollupId any) *MockIAppByRollupIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByRollupId", reflect.TypeOf((*MockIApp)(nil).ByRollupId), ctx, rollupId)
return &MockIAppByRollupIdCall{Call: call}
}
// MockIAppByRollupIdCall wrap *gomock.Call
type MockIAppByRollupIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppByRollupIdCall) Return(arg0 storage.AppWithStats, arg1 error) *MockIAppByRollupIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppByRollupIdCall) Do(f func(context.Context, uint64) (storage.AppWithStats, error)) *MockIAppByRollupIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppByRollupIdCall) DoAndReturn(f func(context.Context, uint64) (storage.AppWithStats, error)) *MockIAppByRollupIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// BySlug mocks base method.
func (m *MockIApp) BySlug(ctx context.Context, slug string) (storage.AppWithStats, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BySlug", ctx, slug)
ret0, _ := ret[0].(storage.AppWithStats)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// BySlug indicates an expected call of BySlug.
func (mr *MockIAppMockRecorder) BySlug(ctx, slug any) *MockIAppBySlugCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BySlug", reflect.TypeOf((*MockIApp)(nil).BySlug), ctx, slug)
return &MockIAppBySlugCall{Call: call}
}
// MockIAppBySlugCall wrap *gomock.Call
type MockIAppBySlugCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppBySlugCall) Return(arg0 storage.AppWithStats, arg1 error) *MockIAppBySlugCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppBySlugCall) Do(f func(context.Context, string) (storage.AppWithStats, error)) *MockIAppBySlugCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppBySlugCall) DoAndReturn(f func(context.Context, string) (storage.AppWithStats, error)) *MockIAppBySlugCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIApp) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.App, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.App)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIAppMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIAppCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIApp)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIAppCursorListCall{Call: call}
}
// MockIAppCursorListCall wrap *gomock.Call
type MockIAppCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppCursorListCall) Return(arg0 []*storage.App, arg1 error) *MockIAppCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.App, error)) *MockIAppCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.App, error)) *MockIAppCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIApp) GetByID(ctx context.Context, id uint64) (*storage.App, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.App)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIAppMockRecorder) GetByID(ctx, id any) *MockIAppGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIApp)(nil).GetByID), ctx, id)
return &MockIAppGetByIDCall{Call: call}
}
// MockIAppGetByIDCall wrap *gomock.Call
type MockIAppGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppGetByIDCall) Return(arg0 *storage.App, arg1 error) *MockIAppGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppGetByIDCall) Do(f func(context.Context, uint64) (*storage.App, error)) *MockIAppGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.App, error)) *MockIAppGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIApp) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIAppMockRecorder) IsNoRows(err any) *MockIAppIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIApp)(nil).IsNoRows), err)
return &MockIAppIsNoRowsCall{Call: call}
}
// MockIAppIsNoRowsCall wrap *gomock.Call
type MockIAppIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppIsNoRowsCall) Return(arg0 bool) *MockIAppIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppIsNoRowsCall) Do(f func(error) bool) *MockIAppIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIAppIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIApp) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIAppMockRecorder) LastID(ctx any) *MockIAppLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIApp)(nil).LastID), ctx)
return &MockIAppLastIDCall{Call: call}
}
// MockIAppLastIDCall wrap *gomock.Call
type MockIAppLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppLastIDCall) Return(arg0 uint64, arg1 error) *MockIAppLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIAppLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIAppLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Leaderboard mocks base method.
func (m *MockIApp) Leaderboard(ctx context.Context, fltrs storage.LeaderboardFilters) ([]storage.AppWithStats, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Leaderboard", ctx, fltrs)
ret0, _ := ret[0].([]storage.AppWithStats)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Leaderboard indicates an expected call of Leaderboard.
func (mr *MockIAppMockRecorder) Leaderboard(ctx, fltrs any) *MockIAppLeaderboardCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Leaderboard", reflect.TypeOf((*MockIApp)(nil).Leaderboard), ctx, fltrs)
return &MockIAppLeaderboardCall{Call: call}
}
// MockIAppLeaderboardCall wrap *gomock.Call
type MockIAppLeaderboardCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppLeaderboardCall) Return(arg0 []storage.AppWithStats, arg1 error) *MockIAppLeaderboardCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppLeaderboardCall) Do(f func(context.Context, storage.LeaderboardFilters) ([]storage.AppWithStats, error)) *MockIAppLeaderboardCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppLeaderboardCall) DoAndReturn(f func(context.Context, storage.LeaderboardFilters) ([]storage.AppWithStats, error)) *MockIAppLeaderboardCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIApp) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.App, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.App)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIAppMockRecorder) List(ctx, limit, offset, order any) *MockIAppListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIApp)(nil).List), ctx, limit, offset, order)
return &MockIAppListCall{Call: call}
}
// MockIAppListCall wrap *gomock.Call
type MockIAppListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppListCall) Return(arg0 []*storage.App, arg1 error) *MockIAppListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.App, error)) *MockIAppListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.App, error)) *MockIAppListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIApp) Save(ctx context.Context, m *storage.App) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIAppMockRecorder) Save(ctx, m any) *MockIAppSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIApp)(nil).Save), ctx, m)
return &MockIAppSaveCall{Call: call}
}
// MockIAppSaveCall wrap *gomock.Call
type MockIAppSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppSaveCall) Return(arg0 error) *MockIAppSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppSaveCall) Do(f func(context.Context, *storage.App) error) *MockIAppSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppSaveCall) DoAndReturn(f func(context.Context, *storage.App) error) *MockIAppSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIApp) Update(ctx context.Context, m *storage.App) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIAppMockRecorder) Update(ctx, m any) *MockIAppUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIApp)(nil).Update), ctx, m)
return &MockIAppUpdateCall{Call: call}
}
// MockIAppUpdateCall wrap *gomock.Call
type MockIAppUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAppUpdateCall) Return(arg0 error) *MockIAppUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAppUpdateCall) Do(f func(context.Context, *storage.App) error) *MockIAppUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAppUpdateCall) DoAndReturn(f func(context.Context, *storage.App) error) *MockIAppUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: asset.go
//
// Generated by this command:
//
// mockgen -source=asset.go -destination=mock/asset.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIAsset is a mock of IAsset interface.
type MockIAsset struct {
ctrl *gomock.Controller
recorder *MockIAssetMockRecorder
}
// MockIAssetMockRecorder is the mock recorder for MockIAsset.
type MockIAssetMockRecorder struct {
mock *MockIAsset
}
// NewMockIAsset creates a new mock instance.
func NewMockIAsset(ctrl *gomock.Controller) *MockIAsset {
mock := &MockIAsset{ctrl: ctrl}
mock.recorder = &MockIAssetMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIAsset) EXPECT() *MockIAssetMockRecorder {
return m.recorder
}
// List mocks base method.
func (m *MockIAsset) List(ctx context.Context, limit, offset int, sortBy string, order storage0.SortOrder) ([]storage.Asset, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, sortBy, order)
ret0, _ := ret[0].([]storage.Asset)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIAssetMockRecorder) List(ctx, limit, offset, sortBy, order any) *MockIAssetListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIAsset)(nil).List), ctx, limit, offset, sortBy, order)
return &MockIAssetListCall{Call: call}
}
// MockIAssetListCall wrap *gomock.Call
type MockIAssetListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIAssetListCall) Return(arg0 []storage.Asset, arg1 error) *MockIAssetListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIAssetListCall) Do(f func(context.Context, int, int, string, storage0.SortOrder) ([]storage.Asset, error)) *MockIAssetListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIAssetListCall) DoAndReturn(f func(context.Context, int, int, string, storage0.SortOrder) ([]storage.Asset, error)) *MockIAssetListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: balance.go
//
// Generated by this command:
//
// mockgen -source=balance.go -destination=mock/balance.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIBalance is a mock of IBalance interface.
type MockIBalance struct {
ctrl *gomock.Controller
recorder *MockIBalanceMockRecorder
}
// MockIBalanceMockRecorder is the mock recorder for MockIBalance.
type MockIBalanceMockRecorder struct {
mock *MockIBalance
}
// NewMockIBalance creates a new mock instance.
func NewMockIBalance(ctrl *gomock.Controller) *MockIBalance {
mock := &MockIBalance{ctrl: ctrl}
mock.recorder = &MockIBalanceMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIBalance) EXPECT() *MockIBalanceMockRecorder {
return m.recorder
}
// CursorList mocks base method.
func (m *MockIBalance) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Balance, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Balance)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIBalanceMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIBalanceCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIBalance)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIBalanceCursorListCall{Call: call}
}
// MockIBalanceCursorListCall wrap *gomock.Call
type MockIBalanceCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceCursorListCall) Return(arg0 []*storage.Balance, arg1 error) *MockIBalanceCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Balance, error)) *MockIBalanceCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Balance, error)) *MockIBalanceCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIBalance) GetByID(ctx context.Context, id uint64) (*storage.Balance, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Balance)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIBalanceMockRecorder) GetByID(ctx, id any) *MockIBalanceGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIBalance)(nil).GetByID), ctx, id)
return &MockIBalanceGetByIDCall{Call: call}
}
// MockIBalanceGetByIDCall wrap *gomock.Call
type MockIBalanceGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceGetByIDCall) Return(arg0 *storage.Balance, arg1 error) *MockIBalanceGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceGetByIDCall) Do(f func(context.Context, uint64) (*storage.Balance, error)) *MockIBalanceGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Balance, error)) *MockIBalanceGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIBalance) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIBalanceMockRecorder) IsNoRows(err any) *MockIBalanceIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIBalance)(nil).IsNoRows), err)
return &MockIBalanceIsNoRowsCall{Call: call}
}
// MockIBalanceIsNoRowsCall wrap *gomock.Call
type MockIBalanceIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceIsNoRowsCall) Return(arg0 bool) *MockIBalanceIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceIsNoRowsCall) Do(f func(error) bool) *MockIBalanceIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIBalanceIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIBalance) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIBalanceMockRecorder) LastID(ctx any) *MockIBalanceLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIBalance)(nil).LastID), ctx)
return &MockIBalanceLastIDCall{Call: call}
}
// MockIBalanceLastIDCall wrap *gomock.Call
type MockIBalanceLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceLastIDCall) Return(arg0 uint64, arg1 error) *MockIBalanceLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIBalanceLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIBalanceLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIBalance) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Balance, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Balance)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIBalanceMockRecorder) List(ctx, limit, offset, order any) *MockIBalanceListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIBalance)(nil).List), ctx, limit, offset, order)
return &MockIBalanceListCall{Call: call}
}
// MockIBalanceListCall wrap *gomock.Call
type MockIBalanceListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceListCall) Return(arg0 []*storage.Balance, arg1 error) *MockIBalanceListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Balance, error)) *MockIBalanceListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Balance, error)) *MockIBalanceListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIBalance) Save(ctx context.Context, m *storage.Balance) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIBalanceMockRecorder) Save(ctx, m any) *MockIBalanceSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIBalance)(nil).Save), ctx, m)
return &MockIBalanceSaveCall{Call: call}
}
// MockIBalanceSaveCall wrap *gomock.Call
type MockIBalanceSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceSaveCall) Return(arg0 error) *MockIBalanceSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceSaveCall) Do(f func(context.Context, *storage.Balance) error) *MockIBalanceSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceSaveCall) DoAndReturn(f func(context.Context, *storage.Balance) error) *MockIBalanceSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIBalance) Update(ctx context.Context, m *storage.Balance) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIBalanceMockRecorder) Update(ctx, m any) *MockIBalanceUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIBalance)(nil).Update), ctx, m)
return &MockIBalanceUpdateCall{Call: call}
}
// MockIBalanceUpdateCall wrap *gomock.Call
type MockIBalanceUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceUpdateCall) Return(arg0 error) *MockIBalanceUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceUpdateCall) Do(f func(context.Context, *storage.Balance) error) *MockIBalanceUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceUpdateCall) DoAndReturn(f func(context.Context, *storage.Balance) error) *MockIBalanceUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: balance_update.go
//
// Generated by this command:
//
// mockgen -source=balance_update.go -destination=mock/balance_update.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIBalanceUpdate is a mock of IBalanceUpdate interface.
type MockIBalanceUpdate struct {
ctrl *gomock.Controller
recorder *MockIBalanceUpdateMockRecorder
}
// MockIBalanceUpdateMockRecorder is the mock recorder for MockIBalanceUpdate.
type MockIBalanceUpdateMockRecorder struct {
mock *MockIBalanceUpdate
}
// NewMockIBalanceUpdate creates a new mock instance.
func NewMockIBalanceUpdate(ctrl *gomock.Controller) *MockIBalanceUpdate {
mock := &MockIBalanceUpdate{ctrl: ctrl}
mock.recorder = &MockIBalanceUpdateMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIBalanceUpdate) EXPECT() *MockIBalanceUpdateMockRecorder {
return m.recorder
}
// CursorList mocks base method.
func (m *MockIBalanceUpdate) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.BalanceUpdate, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.BalanceUpdate)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIBalanceUpdateMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIBalanceUpdateCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIBalanceUpdate)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIBalanceUpdateCursorListCall{Call: call}
}
// MockIBalanceUpdateCursorListCall wrap *gomock.Call
type MockIBalanceUpdateCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceUpdateCursorListCall) Return(arg0 []*storage.BalanceUpdate, arg1 error) *MockIBalanceUpdateCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceUpdateCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.BalanceUpdate, error)) *MockIBalanceUpdateCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceUpdateCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.BalanceUpdate, error)) *MockIBalanceUpdateCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIBalanceUpdate) GetByID(ctx context.Context, id uint64) (*storage.BalanceUpdate, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.BalanceUpdate)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIBalanceUpdateMockRecorder) GetByID(ctx, id any) *MockIBalanceUpdateGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIBalanceUpdate)(nil).GetByID), ctx, id)
return &MockIBalanceUpdateGetByIDCall{Call: call}
}
// MockIBalanceUpdateGetByIDCall wrap *gomock.Call
type MockIBalanceUpdateGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceUpdateGetByIDCall) Return(arg0 *storage.BalanceUpdate, arg1 error) *MockIBalanceUpdateGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceUpdateGetByIDCall) Do(f func(context.Context, uint64) (*storage.BalanceUpdate, error)) *MockIBalanceUpdateGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceUpdateGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.BalanceUpdate, error)) *MockIBalanceUpdateGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIBalanceUpdate) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIBalanceUpdateMockRecorder) IsNoRows(err any) *MockIBalanceUpdateIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIBalanceUpdate)(nil).IsNoRows), err)
return &MockIBalanceUpdateIsNoRowsCall{Call: call}
}
// MockIBalanceUpdateIsNoRowsCall wrap *gomock.Call
type MockIBalanceUpdateIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceUpdateIsNoRowsCall) Return(arg0 bool) *MockIBalanceUpdateIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceUpdateIsNoRowsCall) Do(f func(error) bool) *MockIBalanceUpdateIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceUpdateIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIBalanceUpdateIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIBalanceUpdate) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIBalanceUpdateMockRecorder) LastID(ctx any) *MockIBalanceUpdateLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIBalanceUpdate)(nil).LastID), ctx)
return &MockIBalanceUpdateLastIDCall{Call: call}
}
// MockIBalanceUpdateLastIDCall wrap *gomock.Call
type MockIBalanceUpdateLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceUpdateLastIDCall) Return(arg0 uint64, arg1 error) *MockIBalanceUpdateLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceUpdateLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIBalanceUpdateLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceUpdateLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIBalanceUpdateLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIBalanceUpdate) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.BalanceUpdate, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.BalanceUpdate)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIBalanceUpdateMockRecorder) List(ctx, limit, offset, order any) *MockIBalanceUpdateListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIBalanceUpdate)(nil).List), ctx, limit, offset, order)
return &MockIBalanceUpdateListCall{Call: call}
}
// MockIBalanceUpdateListCall wrap *gomock.Call
type MockIBalanceUpdateListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceUpdateListCall) Return(arg0 []*storage.BalanceUpdate, arg1 error) *MockIBalanceUpdateListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceUpdateListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.BalanceUpdate, error)) *MockIBalanceUpdateListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceUpdateListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.BalanceUpdate, error)) *MockIBalanceUpdateListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIBalanceUpdate) Save(ctx context.Context, m *storage.BalanceUpdate) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIBalanceUpdateMockRecorder) Save(ctx, m any) *MockIBalanceUpdateSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIBalanceUpdate)(nil).Save), ctx, m)
return &MockIBalanceUpdateSaveCall{Call: call}
}
// MockIBalanceUpdateSaveCall wrap *gomock.Call
type MockIBalanceUpdateSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceUpdateSaveCall) Return(arg0 error) *MockIBalanceUpdateSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceUpdateSaveCall) Do(f func(context.Context, *storage.BalanceUpdate) error) *MockIBalanceUpdateSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceUpdateSaveCall) DoAndReturn(f func(context.Context, *storage.BalanceUpdate) error) *MockIBalanceUpdateSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIBalanceUpdate) Update(ctx context.Context, m *storage.BalanceUpdate) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIBalanceUpdateMockRecorder) Update(ctx, m any) *MockIBalanceUpdateUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIBalanceUpdate)(nil).Update), ctx, m)
return &MockIBalanceUpdateUpdateCall{Call: call}
}
// MockIBalanceUpdateUpdateCall wrap *gomock.Call
type MockIBalanceUpdateUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBalanceUpdateUpdateCall) Return(arg0 error) *MockIBalanceUpdateUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBalanceUpdateUpdateCall) Do(f func(context.Context, *storage.BalanceUpdate) error) *MockIBalanceUpdateUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBalanceUpdateUpdateCall) DoAndReturn(f func(context.Context, *storage.BalanceUpdate) error) *MockIBalanceUpdateUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: block.go
//
// Generated by this command:
//
// mockgen -source=block.go -destination=mock/block.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
types "github.com/celenium-io/astria-indexer/pkg/types"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIBlock is a mock of IBlock interface.
type MockIBlock struct {
ctrl *gomock.Controller
recorder *MockIBlockMockRecorder
}
// MockIBlockMockRecorder is the mock recorder for MockIBlock.
type MockIBlockMockRecorder struct {
mock *MockIBlock
}
// NewMockIBlock creates a new mock instance.
func NewMockIBlock(ctrl *gomock.Controller) *MockIBlock {
mock := &MockIBlock{ctrl: ctrl}
mock.recorder = &MockIBlockMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIBlock) EXPECT() *MockIBlockMockRecorder {
return m.recorder
}
// ByHash mocks base method.
func (m *MockIBlock) ByHash(ctx context.Context, hash []byte) (storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByHash", ctx, hash)
ret0, _ := ret[0].(storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByHash indicates an expected call of ByHash.
func (mr *MockIBlockMockRecorder) ByHash(ctx, hash any) *MockIBlockByHashCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByHash", reflect.TypeOf((*MockIBlock)(nil).ByHash), ctx, hash)
return &MockIBlockByHashCall{Call: call}
}
// MockIBlockByHashCall wrap *gomock.Call
type MockIBlockByHashCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockByHashCall) Return(arg0 storage.Block, arg1 error) *MockIBlockByHashCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockByHashCall) Do(f func(context.Context, []byte) (storage.Block, error)) *MockIBlockByHashCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockByHashCall) DoAndReturn(f func(context.Context, []byte) (storage.Block, error)) *MockIBlockByHashCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByHeight mocks base method.
func (m *MockIBlock) ByHeight(ctx context.Context, height types.Level, withStats bool) (storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByHeight", ctx, height, withStats)
ret0, _ := ret[0].(storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByHeight indicates an expected call of ByHeight.
func (mr *MockIBlockMockRecorder) ByHeight(ctx, height, withStats any) *MockIBlockByHeightCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByHeight", reflect.TypeOf((*MockIBlock)(nil).ByHeight), ctx, height, withStats)
return &MockIBlockByHeightCall{Call: call}
}
// MockIBlockByHeightCall wrap *gomock.Call
type MockIBlockByHeightCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockByHeightCall) Return(arg0 storage.Block, arg1 error) *MockIBlockByHeightCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockByHeightCall) Do(f func(context.Context, types.Level, bool) (storage.Block, error)) *MockIBlockByHeightCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockByHeightCall) DoAndReturn(f func(context.Context, types.Level, bool) (storage.Block, error)) *MockIBlockByHeightCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByIdWithRelations mocks base method.
func (m *MockIBlock) ByIdWithRelations(ctx context.Context, id uint64) (storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByIdWithRelations", ctx, id)
ret0, _ := ret[0].(storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByIdWithRelations indicates an expected call of ByIdWithRelations.
func (mr *MockIBlockMockRecorder) ByIdWithRelations(ctx, id any) *MockIBlockByIdWithRelationsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByIdWithRelations", reflect.TypeOf((*MockIBlock)(nil).ByIdWithRelations), ctx, id)
return &MockIBlockByIdWithRelationsCall{Call: call}
}
// MockIBlockByIdWithRelationsCall wrap *gomock.Call
type MockIBlockByIdWithRelationsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockByIdWithRelationsCall) Return(arg0 storage.Block, arg1 error) *MockIBlockByIdWithRelationsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockByIdWithRelationsCall) Do(f func(context.Context, uint64) (storage.Block, error)) *MockIBlockByIdWithRelationsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockByIdWithRelationsCall) DoAndReturn(f func(context.Context, uint64) (storage.Block, error)) *MockIBlockByIdWithRelationsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByProposer mocks base method.
func (m *MockIBlock) ByProposer(ctx context.Context, proposerId uint64, limit, offset int, order storage0.SortOrder) ([]storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByProposer", ctx, proposerId, limit, offset, order)
ret0, _ := ret[0].([]storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByProposer indicates an expected call of ByProposer.
func (mr *MockIBlockMockRecorder) ByProposer(ctx, proposerId, limit, offset, order any) *MockIBlockByProposerCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByProposer", reflect.TypeOf((*MockIBlock)(nil).ByProposer), ctx, proposerId, limit, offset, order)
return &MockIBlockByProposerCall{Call: call}
}
// MockIBlockByProposerCall wrap *gomock.Call
type MockIBlockByProposerCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockByProposerCall) Return(arg0 []storage.Block, arg1 error) *MockIBlockByProposerCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockByProposerCall) Do(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.Block, error)) *MockIBlockByProposerCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockByProposerCall) DoAndReturn(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.Block, error)) *MockIBlockByProposerCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIBlock) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIBlockMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIBlockCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIBlock)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIBlockCursorListCall{Call: call}
}
// MockIBlockCursorListCall wrap *gomock.Call
type MockIBlockCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockCursorListCall) Return(arg0 []*storage.Block, arg1 error) *MockIBlockCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Block, error)) *MockIBlockCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Block, error)) *MockIBlockCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIBlock) GetByID(ctx context.Context, id uint64) (*storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIBlockMockRecorder) GetByID(ctx, id any) *MockIBlockGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIBlock)(nil).GetByID), ctx, id)
return &MockIBlockGetByIDCall{Call: call}
}
// MockIBlockGetByIDCall wrap *gomock.Call
type MockIBlockGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockGetByIDCall) Return(arg0 *storage.Block, arg1 error) *MockIBlockGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockGetByIDCall) Do(f func(context.Context, uint64) (*storage.Block, error)) *MockIBlockGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Block, error)) *MockIBlockGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIBlock) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIBlockMockRecorder) IsNoRows(err any) *MockIBlockIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIBlock)(nil).IsNoRows), err)
return &MockIBlockIsNoRowsCall{Call: call}
}
// MockIBlockIsNoRowsCall wrap *gomock.Call
type MockIBlockIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockIsNoRowsCall) Return(arg0 bool) *MockIBlockIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockIsNoRowsCall) Do(f func(error) bool) *MockIBlockIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIBlockIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Last mocks base method.
func (m *MockIBlock) Last(ctx context.Context) (storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Last", ctx)
ret0, _ := ret[0].(storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Last indicates an expected call of Last.
func (mr *MockIBlockMockRecorder) Last(ctx any) *MockIBlockLastCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Last", reflect.TypeOf((*MockIBlock)(nil).Last), ctx)
return &MockIBlockLastCall{Call: call}
}
// MockIBlockLastCall wrap *gomock.Call
type MockIBlockLastCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockLastCall) Return(arg0 storage.Block, arg1 error) *MockIBlockLastCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockLastCall) Do(f func(context.Context) (storage.Block, error)) *MockIBlockLastCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockLastCall) DoAndReturn(f func(context.Context) (storage.Block, error)) *MockIBlockLastCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIBlock) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIBlockMockRecorder) LastID(ctx any) *MockIBlockLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIBlock)(nil).LastID), ctx)
return &MockIBlockLastIDCall{Call: call}
}
// MockIBlockLastIDCall wrap *gomock.Call
type MockIBlockLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockLastIDCall) Return(arg0 uint64, arg1 error) *MockIBlockLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIBlockLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIBlockLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIBlock) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIBlockMockRecorder) List(ctx, limit, offset, order any) *MockIBlockListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIBlock)(nil).List), ctx, limit, offset, order)
return &MockIBlockListCall{Call: call}
}
// MockIBlockListCall wrap *gomock.Call
type MockIBlockListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockListCall) Return(arg0 []*storage.Block, arg1 error) *MockIBlockListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Block, error)) *MockIBlockListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Block, error)) *MockIBlockListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ListWithStats mocks base method.
func (m *MockIBlock) ListWithStats(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListWithStats", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListWithStats indicates an expected call of ListWithStats.
func (mr *MockIBlockMockRecorder) ListWithStats(ctx, limit, offset, order any) *MockIBlockListWithStatsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWithStats", reflect.TypeOf((*MockIBlock)(nil).ListWithStats), ctx, limit, offset, order)
return &MockIBlockListWithStatsCall{Call: call}
}
// MockIBlockListWithStatsCall wrap *gomock.Call
type MockIBlockListWithStatsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockListWithStatsCall) Return(arg0 []*storage.Block, arg1 error) *MockIBlockListWithStatsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockListWithStatsCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Block, error)) *MockIBlockListWithStatsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockListWithStatsCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Block, error)) *MockIBlockListWithStatsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIBlock) Save(ctx context.Context, m *storage.Block) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIBlockMockRecorder) Save(ctx, m any) *MockIBlockSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIBlock)(nil).Save), ctx, m)
return &MockIBlockSaveCall{Call: call}
}
// MockIBlockSaveCall wrap *gomock.Call
type MockIBlockSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSaveCall) Return(arg0 error) *MockIBlockSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSaveCall) Do(f func(context.Context, *storage.Block) error) *MockIBlockSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSaveCall) DoAndReturn(f func(context.Context, *storage.Block) error) *MockIBlockSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIBlock) Update(ctx context.Context, m *storage.Block) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIBlockMockRecorder) Update(ctx, m any) *MockIBlockUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIBlock)(nil).Update), ctx, m)
return &MockIBlockUpdateCall{Call: call}
}
// MockIBlockUpdateCall wrap *gomock.Call
type MockIBlockUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockUpdateCall) Return(arg0 error) *MockIBlockUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockUpdateCall) Do(f func(context.Context, *storage.Block) error) *MockIBlockUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockUpdateCall) DoAndReturn(f func(context.Context, *storage.Block) error) *MockIBlockUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: block_signature.go
//
// Generated by this command:
//
// mockgen -source=block_signature.go -destination=mock/block_signature.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
types "github.com/celenium-io/astria-indexer/pkg/types"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIBlockSignature is a mock of IBlockSignature interface.
type MockIBlockSignature struct {
ctrl *gomock.Controller
recorder *MockIBlockSignatureMockRecorder
}
// MockIBlockSignatureMockRecorder is the mock recorder for MockIBlockSignature.
type MockIBlockSignatureMockRecorder struct {
mock *MockIBlockSignature
}
// NewMockIBlockSignature creates a new mock instance.
func NewMockIBlockSignature(ctrl *gomock.Controller) *MockIBlockSignature {
mock := &MockIBlockSignature{ctrl: ctrl}
mock.recorder = &MockIBlockSignatureMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIBlockSignature) EXPECT() *MockIBlockSignatureMockRecorder {
return m.recorder
}
// CursorList mocks base method.
func (m *MockIBlockSignature) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.BlockSignature, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.BlockSignature)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIBlockSignatureMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIBlockSignatureCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIBlockSignature)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIBlockSignatureCursorListCall{Call: call}
}
// MockIBlockSignatureCursorListCall wrap *gomock.Call
type MockIBlockSignatureCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSignatureCursorListCall) Return(arg0 []*storage.BlockSignature, arg1 error) *MockIBlockSignatureCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSignatureCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.BlockSignature, error)) *MockIBlockSignatureCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSignatureCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.BlockSignature, error)) *MockIBlockSignatureCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIBlockSignature) GetByID(ctx context.Context, id uint64) (*storage.BlockSignature, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.BlockSignature)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIBlockSignatureMockRecorder) GetByID(ctx, id any) *MockIBlockSignatureGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIBlockSignature)(nil).GetByID), ctx, id)
return &MockIBlockSignatureGetByIDCall{Call: call}
}
// MockIBlockSignatureGetByIDCall wrap *gomock.Call
type MockIBlockSignatureGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSignatureGetByIDCall) Return(arg0 *storage.BlockSignature, arg1 error) *MockIBlockSignatureGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSignatureGetByIDCall) Do(f func(context.Context, uint64) (*storage.BlockSignature, error)) *MockIBlockSignatureGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSignatureGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.BlockSignature, error)) *MockIBlockSignatureGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIBlockSignature) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIBlockSignatureMockRecorder) IsNoRows(err any) *MockIBlockSignatureIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIBlockSignature)(nil).IsNoRows), err)
return &MockIBlockSignatureIsNoRowsCall{Call: call}
}
// MockIBlockSignatureIsNoRowsCall wrap *gomock.Call
type MockIBlockSignatureIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSignatureIsNoRowsCall) Return(arg0 bool) *MockIBlockSignatureIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSignatureIsNoRowsCall) Do(f func(error) bool) *MockIBlockSignatureIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSignatureIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIBlockSignatureIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIBlockSignature) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIBlockSignatureMockRecorder) LastID(ctx any) *MockIBlockSignatureLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIBlockSignature)(nil).LastID), ctx)
return &MockIBlockSignatureLastIDCall{Call: call}
}
// MockIBlockSignatureLastIDCall wrap *gomock.Call
type MockIBlockSignatureLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSignatureLastIDCall) Return(arg0 uint64, arg1 error) *MockIBlockSignatureLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSignatureLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIBlockSignatureLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSignatureLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIBlockSignatureLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LevelsByValidator mocks base method.
func (m *MockIBlockSignature) LevelsByValidator(ctx context.Context, validatorId uint64, startHeight types.Level) ([]types.Level, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LevelsByValidator", ctx, validatorId, startHeight)
ret0, _ := ret[0].([]types.Level)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LevelsByValidator indicates an expected call of LevelsByValidator.
func (mr *MockIBlockSignatureMockRecorder) LevelsByValidator(ctx, validatorId, startHeight any) *MockIBlockSignatureLevelsByValidatorCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LevelsByValidator", reflect.TypeOf((*MockIBlockSignature)(nil).LevelsByValidator), ctx, validatorId, startHeight)
return &MockIBlockSignatureLevelsByValidatorCall{Call: call}
}
// MockIBlockSignatureLevelsByValidatorCall wrap *gomock.Call
type MockIBlockSignatureLevelsByValidatorCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSignatureLevelsByValidatorCall) Return(arg0 []types.Level, arg1 error) *MockIBlockSignatureLevelsByValidatorCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSignatureLevelsByValidatorCall) Do(f func(context.Context, uint64, types.Level) ([]types.Level, error)) *MockIBlockSignatureLevelsByValidatorCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSignatureLevelsByValidatorCall) DoAndReturn(f func(context.Context, uint64, types.Level) ([]types.Level, error)) *MockIBlockSignatureLevelsByValidatorCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIBlockSignature) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.BlockSignature, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.BlockSignature)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIBlockSignatureMockRecorder) List(ctx, limit, offset, order any) *MockIBlockSignatureListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIBlockSignature)(nil).List), ctx, limit, offset, order)
return &MockIBlockSignatureListCall{Call: call}
}
// MockIBlockSignatureListCall wrap *gomock.Call
type MockIBlockSignatureListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSignatureListCall) Return(arg0 []*storage.BlockSignature, arg1 error) *MockIBlockSignatureListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSignatureListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.BlockSignature, error)) *MockIBlockSignatureListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSignatureListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.BlockSignature, error)) *MockIBlockSignatureListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIBlockSignature) Save(ctx context.Context, m *storage.BlockSignature) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIBlockSignatureMockRecorder) Save(ctx, m any) *MockIBlockSignatureSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIBlockSignature)(nil).Save), ctx, m)
return &MockIBlockSignatureSaveCall{Call: call}
}
// MockIBlockSignatureSaveCall wrap *gomock.Call
type MockIBlockSignatureSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSignatureSaveCall) Return(arg0 error) *MockIBlockSignatureSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSignatureSaveCall) Do(f func(context.Context, *storage.BlockSignature) error) *MockIBlockSignatureSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSignatureSaveCall) DoAndReturn(f func(context.Context, *storage.BlockSignature) error) *MockIBlockSignatureSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIBlockSignature) Update(ctx context.Context, m *storage.BlockSignature) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIBlockSignatureMockRecorder) Update(ctx, m any) *MockIBlockSignatureUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIBlockSignature)(nil).Update), ctx, m)
return &MockIBlockSignatureUpdateCall{Call: call}
}
// MockIBlockSignatureUpdateCall wrap *gomock.Call
type MockIBlockSignatureUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockSignatureUpdateCall) Return(arg0 error) *MockIBlockSignatureUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockSignatureUpdateCall) Do(f func(context.Context, *storage.BlockSignature) error) *MockIBlockSignatureUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockSignatureUpdateCall) DoAndReturn(f func(context.Context, *storage.BlockSignature) error) *MockIBlockSignatureUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: block_stats.go
//
// Generated by this command:
//
// mockgen -source=block_stats.go -destination=mock/block_stats.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
types "github.com/celenium-io/astria-indexer/pkg/types"
gomock "go.uber.org/mock/gomock"
)
// MockIBlockStats is a mock of IBlockStats interface.
type MockIBlockStats struct {
ctrl *gomock.Controller
recorder *MockIBlockStatsMockRecorder
}
// MockIBlockStatsMockRecorder is the mock recorder for MockIBlockStats.
type MockIBlockStatsMockRecorder struct {
mock *MockIBlockStats
}
// NewMockIBlockStats creates a new mock instance.
func NewMockIBlockStats(ctrl *gomock.Controller) *MockIBlockStats {
mock := &MockIBlockStats{ctrl: ctrl}
mock.recorder = &MockIBlockStatsMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIBlockStats) EXPECT() *MockIBlockStatsMockRecorder {
return m.recorder
}
// ByHeight mocks base method.
func (m *MockIBlockStats) ByHeight(ctx context.Context, height types.Level) (storage.BlockStats, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByHeight", ctx, height)
ret0, _ := ret[0].(storage.BlockStats)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByHeight indicates an expected call of ByHeight.
func (mr *MockIBlockStatsMockRecorder) ByHeight(ctx, height any) *MockIBlockStatsByHeightCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByHeight", reflect.TypeOf((*MockIBlockStats)(nil).ByHeight), ctx, height)
return &MockIBlockStatsByHeightCall{Call: call}
}
// MockIBlockStatsByHeightCall wrap *gomock.Call
type MockIBlockStatsByHeightCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBlockStatsByHeightCall) Return(stats storage.BlockStats, err error) *MockIBlockStatsByHeightCall {
c.Call = c.Call.Return(stats, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBlockStatsByHeightCall) Do(f func(context.Context, types.Level) (storage.BlockStats, error)) *MockIBlockStatsByHeightCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBlockStatsByHeightCall) DoAndReturn(f func(context.Context, types.Level) (storage.BlockStats, error)) *MockIBlockStatsByHeightCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: bridge.go
//
// Generated by this command:
//
// mockgen -source=bridge.go -destination=mock/bridge.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIBridge is a mock of IBridge interface.
type MockIBridge struct {
ctrl *gomock.Controller
recorder *MockIBridgeMockRecorder
}
// MockIBridgeMockRecorder is the mock recorder for MockIBridge.
type MockIBridgeMockRecorder struct {
mock *MockIBridge
}
// NewMockIBridge creates a new mock instance.
func NewMockIBridge(ctrl *gomock.Controller) *MockIBridge {
mock := &MockIBridge{ctrl: ctrl}
mock.recorder = &MockIBridgeMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIBridge) EXPECT() *MockIBridgeMockRecorder {
return m.recorder
}
// ByAddress mocks base method.
func (m *MockIBridge) ByAddress(ctx context.Context, addressId uint64) (storage.Bridge, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByAddress", ctx, addressId)
ret0, _ := ret[0].(storage.Bridge)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByAddress indicates an expected call of ByAddress.
func (mr *MockIBridgeMockRecorder) ByAddress(ctx, addressId any) *MockIBridgeByAddressCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByAddress", reflect.TypeOf((*MockIBridge)(nil).ByAddress), ctx, addressId)
return &MockIBridgeByAddressCall{Call: call}
}
// MockIBridgeByAddressCall wrap *gomock.Call
type MockIBridgeByAddressCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeByAddressCall) Return(arg0 storage.Bridge, arg1 error) *MockIBridgeByAddressCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeByAddressCall) Do(f func(context.Context, uint64) (storage.Bridge, error)) *MockIBridgeByAddressCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeByAddressCall) DoAndReturn(f func(context.Context, uint64) (storage.Bridge, error)) *MockIBridgeByAddressCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ById mocks base method.
func (m *MockIBridge) ById(ctx context.Context, id uint64) (storage.Bridge, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ById", ctx, id)
ret0, _ := ret[0].(storage.Bridge)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ById indicates an expected call of ById.
func (mr *MockIBridgeMockRecorder) ById(ctx, id any) *MockIBridgeByIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ById", reflect.TypeOf((*MockIBridge)(nil).ById), ctx, id)
return &MockIBridgeByIdCall{Call: call}
}
// MockIBridgeByIdCall wrap *gomock.Call
type MockIBridgeByIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeByIdCall) Return(arg0 storage.Bridge, arg1 error) *MockIBridgeByIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeByIdCall) Do(f func(context.Context, uint64) (storage.Bridge, error)) *MockIBridgeByIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeByIdCall) DoAndReturn(f func(context.Context, uint64) (storage.Bridge, error)) *MockIBridgeByIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByRoles mocks base method.
func (m *MockIBridge) ByRoles(ctx context.Context, addressId uint64, limit, offset int) ([]storage.Bridge, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByRoles", ctx, addressId, limit, offset)
ret0, _ := ret[0].([]storage.Bridge)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByRoles indicates an expected call of ByRoles.
func (mr *MockIBridgeMockRecorder) ByRoles(ctx, addressId, limit, offset any) *MockIBridgeByRolesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByRoles", reflect.TypeOf((*MockIBridge)(nil).ByRoles), ctx, addressId, limit, offset)
return &MockIBridgeByRolesCall{Call: call}
}
// MockIBridgeByRolesCall wrap *gomock.Call
type MockIBridgeByRolesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeByRolesCall) Return(arg0 []storage.Bridge, arg1 error) *MockIBridgeByRolesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeByRolesCall) Do(f func(context.Context, uint64, int, int) ([]storage.Bridge, error)) *MockIBridgeByRolesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeByRolesCall) DoAndReturn(f func(context.Context, uint64, int, int) ([]storage.Bridge, error)) *MockIBridgeByRolesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByRollup mocks base method.
func (m *MockIBridge) ByRollup(ctx context.Context, rollupId uint64, limit, offset int) ([]storage.Bridge, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByRollup", ctx, rollupId, limit, offset)
ret0, _ := ret[0].([]storage.Bridge)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByRollup indicates an expected call of ByRollup.
func (mr *MockIBridgeMockRecorder) ByRollup(ctx, rollupId, limit, offset any) *MockIBridgeByRollupCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByRollup", reflect.TypeOf((*MockIBridge)(nil).ByRollup), ctx, rollupId, limit, offset)
return &MockIBridgeByRollupCall{Call: call}
}
// MockIBridgeByRollupCall wrap *gomock.Call
type MockIBridgeByRollupCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeByRollupCall) Return(arg0 []storage.Bridge, arg1 error) *MockIBridgeByRollupCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeByRollupCall) Do(f func(context.Context, uint64, int, int) ([]storage.Bridge, error)) *MockIBridgeByRollupCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeByRollupCall) DoAndReturn(f func(context.Context, uint64, int, int) ([]storage.Bridge, error)) *MockIBridgeByRollupCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIBridge) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Bridge, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Bridge)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIBridgeMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIBridgeCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIBridge)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIBridgeCursorListCall{Call: call}
}
// MockIBridgeCursorListCall wrap *gomock.Call
type MockIBridgeCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeCursorListCall) Return(arg0 []*storage.Bridge, arg1 error) *MockIBridgeCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Bridge, error)) *MockIBridgeCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Bridge, error)) *MockIBridgeCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIBridge) GetByID(ctx context.Context, id uint64) (*storage.Bridge, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Bridge)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIBridgeMockRecorder) GetByID(ctx, id any) *MockIBridgeGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIBridge)(nil).GetByID), ctx, id)
return &MockIBridgeGetByIDCall{Call: call}
}
// MockIBridgeGetByIDCall wrap *gomock.Call
type MockIBridgeGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeGetByIDCall) Return(arg0 *storage.Bridge, arg1 error) *MockIBridgeGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeGetByIDCall) Do(f func(context.Context, uint64) (*storage.Bridge, error)) *MockIBridgeGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Bridge, error)) *MockIBridgeGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIBridge) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIBridgeMockRecorder) IsNoRows(err any) *MockIBridgeIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIBridge)(nil).IsNoRows), err)
return &MockIBridgeIsNoRowsCall{Call: call}
}
// MockIBridgeIsNoRowsCall wrap *gomock.Call
type MockIBridgeIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeIsNoRowsCall) Return(arg0 bool) *MockIBridgeIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeIsNoRowsCall) Do(f func(error) bool) *MockIBridgeIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIBridgeIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIBridge) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIBridgeMockRecorder) LastID(ctx any) *MockIBridgeLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIBridge)(nil).LastID), ctx)
return &MockIBridgeLastIDCall{Call: call}
}
// MockIBridgeLastIDCall wrap *gomock.Call
type MockIBridgeLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeLastIDCall) Return(arg0 uint64, arg1 error) *MockIBridgeLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIBridgeLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIBridgeLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIBridge) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Bridge, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Bridge)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIBridgeMockRecorder) List(ctx, limit, offset, order any) *MockIBridgeListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIBridge)(nil).List), ctx, limit, offset, order)
return &MockIBridgeListCall{Call: call}
}
// MockIBridgeListCall wrap *gomock.Call
type MockIBridgeListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeListCall) Return(arg0 []*storage.Bridge, arg1 error) *MockIBridgeListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Bridge, error)) *MockIBridgeListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Bridge, error)) *MockIBridgeListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ListWithAddress mocks base method.
func (m *MockIBridge) ListWithAddress(ctx context.Context, limit, offset int) ([]storage.Bridge, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListWithAddress", ctx, limit, offset)
ret0, _ := ret[0].([]storage.Bridge)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListWithAddress indicates an expected call of ListWithAddress.
func (mr *MockIBridgeMockRecorder) ListWithAddress(ctx, limit, offset any) *MockIBridgeListWithAddressCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWithAddress", reflect.TypeOf((*MockIBridge)(nil).ListWithAddress), ctx, limit, offset)
return &MockIBridgeListWithAddressCall{Call: call}
}
// MockIBridgeListWithAddressCall wrap *gomock.Call
type MockIBridgeListWithAddressCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeListWithAddressCall) Return(arg0 []storage.Bridge, arg1 error) *MockIBridgeListWithAddressCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeListWithAddressCall) Do(f func(context.Context, int, int) ([]storage.Bridge, error)) *MockIBridgeListWithAddressCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeListWithAddressCall) DoAndReturn(f func(context.Context, int, int) ([]storage.Bridge, error)) *MockIBridgeListWithAddressCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIBridge) Save(ctx context.Context, m *storage.Bridge) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIBridgeMockRecorder) Save(ctx, m any) *MockIBridgeSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIBridge)(nil).Save), ctx, m)
return &MockIBridgeSaveCall{Call: call}
}
// MockIBridgeSaveCall wrap *gomock.Call
type MockIBridgeSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeSaveCall) Return(arg0 error) *MockIBridgeSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeSaveCall) Do(f func(context.Context, *storage.Bridge) error) *MockIBridgeSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeSaveCall) DoAndReturn(f func(context.Context, *storage.Bridge) error) *MockIBridgeSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIBridge) Update(ctx context.Context, m *storage.Bridge) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIBridgeMockRecorder) Update(ctx, m any) *MockIBridgeUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIBridge)(nil).Update), ctx, m)
return &MockIBridgeUpdateCall{Call: call}
}
// MockIBridgeUpdateCall wrap *gomock.Call
type MockIBridgeUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIBridgeUpdateCall) Return(arg0 error) *MockIBridgeUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIBridgeUpdateCall) Do(f func(context.Context, *storage.Bridge) error) *MockIBridgeUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIBridgeUpdateCall) DoAndReturn(f func(context.Context, *storage.Bridge) error) *MockIBridgeUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: constant.go
//
// Generated by this command:
//
// mockgen -source=constant.go -destination=mock/constant.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
types "github.com/celenium-io/astria-indexer/internal/storage/types"
gomock "go.uber.org/mock/gomock"
)
// MockIConstant is a mock of IConstant interface.
type MockIConstant struct {
ctrl *gomock.Controller
recorder *MockIConstantMockRecorder
}
// MockIConstantMockRecorder is the mock recorder for MockIConstant.
type MockIConstantMockRecorder struct {
mock *MockIConstant
}
// NewMockIConstant creates a new mock instance.
func NewMockIConstant(ctrl *gomock.Controller) *MockIConstant {
mock := &MockIConstant{ctrl: ctrl}
mock.recorder = &MockIConstantMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIConstant) EXPECT() *MockIConstantMockRecorder {
return m.recorder
}
// All mocks base method.
func (m *MockIConstant) All(ctx context.Context) ([]storage.Constant, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "All", ctx)
ret0, _ := ret[0].([]storage.Constant)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// All indicates an expected call of All.
func (mr *MockIConstantMockRecorder) All(ctx any) *MockIConstantAllCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "All", reflect.TypeOf((*MockIConstant)(nil).All), ctx)
return &MockIConstantAllCall{Call: call}
}
// MockIConstantAllCall wrap *gomock.Call
type MockIConstantAllCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIConstantAllCall) Return(arg0 []storage.Constant, arg1 error) *MockIConstantAllCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIConstantAllCall) Do(f func(context.Context) ([]storage.Constant, error)) *MockIConstantAllCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIConstantAllCall) DoAndReturn(f func(context.Context) ([]storage.Constant, error)) *MockIConstantAllCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByModule mocks base method.
func (m *MockIConstant) ByModule(ctx context.Context, module types.ModuleName) ([]storage.Constant, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByModule", ctx, module)
ret0, _ := ret[0].([]storage.Constant)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByModule indicates an expected call of ByModule.
func (mr *MockIConstantMockRecorder) ByModule(ctx, module any) *MockIConstantByModuleCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByModule", reflect.TypeOf((*MockIConstant)(nil).ByModule), ctx, module)
return &MockIConstantByModuleCall{Call: call}
}
// MockIConstantByModuleCall wrap *gomock.Call
type MockIConstantByModuleCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIConstantByModuleCall) Return(arg0 []storage.Constant, arg1 error) *MockIConstantByModuleCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIConstantByModuleCall) Do(f func(context.Context, types.ModuleName) ([]storage.Constant, error)) *MockIConstantByModuleCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIConstantByModuleCall) DoAndReturn(f func(context.Context, types.ModuleName) ([]storage.Constant, error)) *MockIConstantByModuleCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Get mocks base method.
func (m *MockIConstant) Get(ctx context.Context, module types.ModuleName, name string) (storage.Constant, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Get", ctx, module, name)
ret0, _ := ret[0].(storage.Constant)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Get indicates an expected call of Get.
func (mr *MockIConstantMockRecorder) Get(ctx, module, name any) *MockIConstantGetCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockIConstant)(nil).Get), ctx, module, name)
return &MockIConstantGetCall{Call: call}
}
// MockIConstantGetCall wrap *gomock.Call
type MockIConstantGetCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIConstantGetCall) Return(arg0 storage.Constant, arg1 error) *MockIConstantGetCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIConstantGetCall) Do(f func(context.Context, types.ModuleName, string) (storage.Constant, error)) *MockIConstantGetCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIConstantGetCall) DoAndReturn(f func(context.Context, types.ModuleName, string) (storage.Constant, error)) *MockIConstantGetCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIConstant) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIConstantMockRecorder) IsNoRows(err any) *MockIConstantIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIConstant)(nil).IsNoRows), err)
return &MockIConstantIsNoRowsCall{Call: call}
}
// MockIConstantIsNoRowsCall wrap *gomock.Call
type MockIConstantIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIConstantIsNoRowsCall) Return(arg0 bool) *MockIConstantIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIConstantIsNoRowsCall) Do(f func(error) bool) *MockIConstantIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIConstantIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIConstantIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: deposit.go
//
// Generated by this command:
//
// mockgen -source=deposit.go -destination=mock/deposit.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIDeposit is a mock of IDeposit interface.
type MockIDeposit struct {
ctrl *gomock.Controller
recorder *MockIDepositMockRecorder
}
// MockIDepositMockRecorder is the mock recorder for MockIDeposit.
type MockIDepositMockRecorder struct {
mock *MockIDeposit
}
// NewMockIDeposit creates a new mock instance.
func NewMockIDeposit(ctrl *gomock.Controller) *MockIDeposit {
mock := &MockIDeposit{ctrl: ctrl}
mock.recorder = &MockIDepositMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIDeposit) EXPECT() *MockIDepositMockRecorder {
return m.recorder
}
// ByBridgeId mocks base method.
func (m *MockIDeposit) ByBridgeId(ctx context.Context, bridgeId uint64, limit, offset int, sort storage0.SortOrder) ([]storage.Deposit, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByBridgeId", ctx, bridgeId, limit, offset, sort)
ret0, _ := ret[0].([]storage.Deposit)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByBridgeId indicates an expected call of ByBridgeId.
func (mr *MockIDepositMockRecorder) ByBridgeId(ctx, bridgeId, limit, offset, sort any) *MockIDepositByBridgeIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByBridgeId", reflect.TypeOf((*MockIDeposit)(nil).ByBridgeId), ctx, bridgeId, limit, offset, sort)
return &MockIDepositByBridgeIdCall{Call: call}
}
// MockIDepositByBridgeIdCall wrap *gomock.Call
type MockIDepositByBridgeIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositByBridgeIdCall) Return(arg0 []storage.Deposit, arg1 error) *MockIDepositByBridgeIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositByBridgeIdCall) Do(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.Deposit, error)) *MockIDepositByBridgeIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositByBridgeIdCall) DoAndReturn(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.Deposit, error)) *MockIDepositByBridgeIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByRollupId mocks base method.
func (m *MockIDeposit) ByRollupId(ctx context.Context, rollupId uint64, limit, offset int, sort storage0.SortOrder) ([]storage.Deposit, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByRollupId", ctx, rollupId, limit, offset, sort)
ret0, _ := ret[0].([]storage.Deposit)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByRollupId indicates an expected call of ByRollupId.
func (mr *MockIDepositMockRecorder) ByRollupId(ctx, rollupId, limit, offset, sort any) *MockIDepositByRollupIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByRollupId", reflect.TypeOf((*MockIDeposit)(nil).ByRollupId), ctx, rollupId, limit, offset, sort)
return &MockIDepositByRollupIdCall{Call: call}
}
// MockIDepositByRollupIdCall wrap *gomock.Call
type MockIDepositByRollupIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositByRollupIdCall) Return(arg0 []storage.Deposit, arg1 error) *MockIDepositByRollupIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositByRollupIdCall) Do(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.Deposit, error)) *MockIDepositByRollupIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositByRollupIdCall) DoAndReturn(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.Deposit, error)) *MockIDepositByRollupIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIDeposit) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Deposit, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Deposit)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIDepositMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIDepositCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIDeposit)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIDepositCursorListCall{Call: call}
}
// MockIDepositCursorListCall wrap *gomock.Call
type MockIDepositCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositCursorListCall) Return(arg0 []*storage.Deposit, arg1 error) *MockIDepositCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Deposit, error)) *MockIDepositCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Deposit, error)) *MockIDepositCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIDeposit) GetByID(ctx context.Context, id uint64) (*storage.Deposit, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Deposit)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIDepositMockRecorder) GetByID(ctx, id any) *MockIDepositGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIDeposit)(nil).GetByID), ctx, id)
return &MockIDepositGetByIDCall{Call: call}
}
// MockIDepositGetByIDCall wrap *gomock.Call
type MockIDepositGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositGetByIDCall) Return(arg0 *storage.Deposit, arg1 error) *MockIDepositGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositGetByIDCall) Do(f func(context.Context, uint64) (*storage.Deposit, error)) *MockIDepositGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Deposit, error)) *MockIDepositGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIDeposit) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIDepositMockRecorder) IsNoRows(err any) *MockIDepositIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIDeposit)(nil).IsNoRows), err)
return &MockIDepositIsNoRowsCall{Call: call}
}
// MockIDepositIsNoRowsCall wrap *gomock.Call
type MockIDepositIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositIsNoRowsCall) Return(arg0 bool) *MockIDepositIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositIsNoRowsCall) Do(f func(error) bool) *MockIDepositIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIDepositIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIDeposit) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIDepositMockRecorder) LastID(ctx any) *MockIDepositLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIDeposit)(nil).LastID), ctx)
return &MockIDepositLastIDCall{Call: call}
}
// MockIDepositLastIDCall wrap *gomock.Call
type MockIDepositLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositLastIDCall) Return(arg0 uint64, arg1 error) *MockIDepositLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIDepositLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIDepositLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIDeposit) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Deposit, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Deposit)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIDepositMockRecorder) List(ctx, limit, offset, order any) *MockIDepositListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIDeposit)(nil).List), ctx, limit, offset, order)
return &MockIDepositListCall{Call: call}
}
// MockIDepositListCall wrap *gomock.Call
type MockIDepositListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositListCall) Return(arg0 []*storage.Deposit, arg1 error) *MockIDepositListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Deposit, error)) *MockIDepositListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Deposit, error)) *MockIDepositListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIDeposit) Save(ctx context.Context, m *storage.Deposit) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIDepositMockRecorder) Save(ctx, m any) *MockIDepositSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIDeposit)(nil).Save), ctx, m)
return &MockIDepositSaveCall{Call: call}
}
// MockIDepositSaveCall wrap *gomock.Call
type MockIDepositSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositSaveCall) Return(arg0 error) *MockIDepositSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositSaveCall) Do(f func(context.Context, *storage.Deposit) error) *MockIDepositSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositSaveCall) DoAndReturn(f func(context.Context, *storage.Deposit) error) *MockIDepositSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIDeposit) Update(ctx context.Context, m *storage.Deposit) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIDepositMockRecorder) Update(ctx, m any) *MockIDepositUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIDeposit)(nil).Update), ctx, m)
return &MockIDepositUpdateCall{Call: call}
}
// MockIDepositUpdateCall wrap *gomock.Call
type MockIDepositUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIDepositUpdateCall) Return(arg0 error) *MockIDepositUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIDepositUpdateCall) Do(f func(context.Context, *storage.Deposit) error) *MockIDepositUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIDepositUpdateCall) DoAndReturn(f func(context.Context, *storage.Deposit) error) *MockIDepositUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: fee.go
//
// Generated by this command:
//
// mockgen -source=fee.go -destination=mock/fee.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIFee is a mock of IFee interface.
type MockIFee struct {
ctrl *gomock.Controller
recorder *MockIFeeMockRecorder
}
// MockIFeeMockRecorder is the mock recorder for MockIFee.
type MockIFeeMockRecorder struct {
mock *MockIFee
}
// NewMockIFee creates a new mock instance.
func NewMockIFee(ctrl *gomock.Controller) *MockIFee {
mock := &MockIFee{ctrl: ctrl}
mock.recorder = &MockIFeeMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIFee) EXPECT() *MockIFeeMockRecorder {
return m.recorder
}
// ByPayerId mocks base method.
func (m *MockIFee) ByPayerId(ctx context.Context, id uint64, limit, offset int, sort storage0.SortOrder) ([]storage.Fee, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByPayerId", ctx, id, limit, offset, sort)
ret0, _ := ret[0].([]storage.Fee)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByPayerId indicates an expected call of ByPayerId.
func (mr *MockIFeeMockRecorder) ByPayerId(ctx, id, limit, offset, sort any) *MockIFeeByPayerIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByPayerId", reflect.TypeOf((*MockIFee)(nil).ByPayerId), ctx, id, limit, offset, sort)
return &MockIFeeByPayerIdCall{Call: call}
}
// MockIFeeByPayerIdCall wrap *gomock.Call
type MockIFeeByPayerIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeByPayerIdCall) Return(arg0 []storage.Fee, arg1 error) *MockIFeeByPayerIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeByPayerIdCall) Do(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.Fee, error)) *MockIFeeByPayerIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeByPayerIdCall) DoAndReturn(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.Fee, error)) *MockIFeeByPayerIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByTxId mocks base method.
func (m *MockIFee) ByTxId(ctx context.Context, id uint64, limit, offset int) ([]storage.Fee, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByTxId", ctx, id, limit, offset)
ret0, _ := ret[0].([]storage.Fee)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByTxId indicates an expected call of ByTxId.
func (mr *MockIFeeMockRecorder) ByTxId(ctx, id, limit, offset any) *MockIFeeByTxIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByTxId", reflect.TypeOf((*MockIFee)(nil).ByTxId), ctx, id, limit, offset)
return &MockIFeeByTxIdCall{Call: call}
}
// MockIFeeByTxIdCall wrap *gomock.Call
type MockIFeeByTxIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeByTxIdCall) Return(arg0 []storage.Fee, arg1 error) *MockIFeeByTxIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeByTxIdCall) Do(f func(context.Context, uint64, int, int) ([]storage.Fee, error)) *MockIFeeByTxIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeByTxIdCall) DoAndReturn(f func(context.Context, uint64, int, int) ([]storage.Fee, error)) *MockIFeeByTxIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIFee) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Fee, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Fee)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIFeeMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIFeeCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIFee)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIFeeCursorListCall{Call: call}
}
// MockIFeeCursorListCall wrap *gomock.Call
type MockIFeeCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeCursorListCall) Return(arg0 []*storage.Fee, arg1 error) *MockIFeeCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Fee, error)) *MockIFeeCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Fee, error)) *MockIFeeCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FullTxFee mocks base method.
func (m *MockIFee) FullTxFee(ctx context.Context, id uint64) ([]storage.Fee, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FullTxFee", ctx, id)
ret0, _ := ret[0].([]storage.Fee)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FullTxFee indicates an expected call of FullTxFee.
func (mr *MockIFeeMockRecorder) FullTxFee(ctx, id any) *MockIFeeFullTxFeeCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FullTxFee", reflect.TypeOf((*MockIFee)(nil).FullTxFee), ctx, id)
return &MockIFeeFullTxFeeCall{Call: call}
}
// MockIFeeFullTxFeeCall wrap *gomock.Call
type MockIFeeFullTxFeeCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeFullTxFeeCall) Return(arg0 []storage.Fee, arg1 error) *MockIFeeFullTxFeeCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeFullTxFeeCall) Do(f func(context.Context, uint64) ([]storage.Fee, error)) *MockIFeeFullTxFeeCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeFullTxFeeCall) DoAndReturn(f func(context.Context, uint64) ([]storage.Fee, error)) *MockIFeeFullTxFeeCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIFee) GetByID(ctx context.Context, id uint64) (*storage.Fee, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Fee)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIFeeMockRecorder) GetByID(ctx, id any) *MockIFeeGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIFee)(nil).GetByID), ctx, id)
return &MockIFeeGetByIDCall{Call: call}
}
// MockIFeeGetByIDCall wrap *gomock.Call
type MockIFeeGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeGetByIDCall) Return(arg0 *storage.Fee, arg1 error) *MockIFeeGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeGetByIDCall) Do(f func(context.Context, uint64) (*storage.Fee, error)) *MockIFeeGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Fee, error)) *MockIFeeGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIFee) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIFeeMockRecorder) IsNoRows(err any) *MockIFeeIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIFee)(nil).IsNoRows), err)
return &MockIFeeIsNoRowsCall{Call: call}
}
// MockIFeeIsNoRowsCall wrap *gomock.Call
type MockIFeeIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeIsNoRowsCall) Return(arg0 bool) *MockIFeeIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeIsNoRowsCall) Do(f func(error) bool) *MockIFeeIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIFeeIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIFee) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIFeeMockRecorder) LastID(ctx any) *MockIFeeLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIFee)(nil).LastID), ctx)
return &MockIFeeLastIDCall{Call: call}
}
// MockIFeeLastIDCall wrap *gomock.Call
type MockIFeeLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeLastIDCall) Return(arg0 uint64, arg1 error) *MockIFeeLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIFeeLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIFeeLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIFee) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Fee, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Fee)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIFeeMockRecorder) List(ctx, limit, offset, order any) *MockIFeeListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIFee)(nil).List), ctx, limit, offset, order)
return &MockIFeeListCall{Call: call}
}
// MockIFeeListCall wrap *gomock.Call
type MockIFeeListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeListCall) Return(arg0 []*storage.Fee, arg1 error) *MockIFeeListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Fee, error)) *MockIFeeListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Fee, error)) *MockIFeeListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIFee) Save(ctx context.Context, m *storage.Fee) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIFeeMockRecorder) Save(ctx, m any) *MockIFeeSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIFee)(nil).Save), ctx, m)
return &MockIFeeSaveCall{Call: call}
}
// MockIFeeSaveCall wrap *gomock.Call
type MockIFeeSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeSaveCall) Return(arg0 error) *MockIFeeSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeSaveCall) Do(f func(context.Context, *storage.Fee) error) *MockIFeeSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeSaveCall) DoAndReturn(f func(context.Context, *storage.Fee) error) *MockIFeeSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIFee) Update(ctx context.Context, m *storage.Fee) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIFeeMockRecorder) Update(ctx, m any) *MockIFeeUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIFee)(nil).Update), ctx, m)
return &MockIFeeUpdateCall{Call: call}
}
// MockIFeeUpdateCall wrap *gomock.Call
type MockIFeeUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIFeeUpdateCall) Return(arg0 error) *MockIFeeUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIFeeUpdateCall) Do(f func(context.Context, *storage.Fee) error) *MockIFeeUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIFeeUpdateCall) DoAndReturn(f func(context.Context, *storage.Fee) error) *MockIFeeUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: generic.go
//
// Generated by this command:
//
// mockgen -source=generic.go -destination=mock/generic.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
types "github.com/celenium-io/astria-indexer/pkg/types"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
pq "github.com/lib/pq"
bun "github.com/uptrace/bun"
gomock "go.uber.org/mock/gomock"
)
// MockTransaction is a mock of Transaction interface.
type MockTransaction struct {
ctrl *gomock.Controller
recorder *MockTransactionMockRecorder
}
// MockTransactionMockRecorder is the mock recorder for MockTransaction.
type MockTransactionMockRecorder struct {
mock *MockTransaction
}
// NewMockTransaction creates a new mock instance.
func NewMockTransaction(ctrl *gomock.Controller) *MockTransaction {
mock := &MockTransaction{ctrl: ctrl}
mock.recorder = &MockTransactionMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockTransaction) EXPECT() *MockTransactionMockRecorder {
return m.recorder
}
// Add mocks base method.
func (m *MockTransaction) Add(ctx context.Context, model any) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Add", ctx, model)
ret0, _ := ret[0].(error)
return ret0
}
// Add indicates an expected call of Add.
func (mr *MockTransactionMockRecorder) Add(ctx, model any) *MockTransactionAddCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockTransaction)(nil).Add), ctx, model)
return &MockTransactionAddCall{Call: call}
}
// MockTransactionAddCall wrap *gomock.Call
type MockTransactionAddCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionAddCall) Return(arg0 error) *MockTransactionAddCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionAddCall) Do(f func(context.Context, any) error) *MockTransactionAddCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionAddCall) DoAndReturn(f func(context.Context, any) error) *MockTransactionAddCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// BulkSave mocks base method.
func (m *MockTransaction) BulkSave(ctx context.Context, models []any) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BulkSave", ctx, models)
ret0, _ := ret[0].(error)
return ret0
}
// BulkSave indicates an expected call of BulkSave.
func (mr *MockTransactionMockRecorder) BulkSave(ctx, models any) *MockTransactionBulkSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BulkSave", reflect.TypeOf((*MockTransaction)(nil).BulkSave), ctx, models)
return &MockTransactionBulkSaveCall{Call: call}
}
// MockTransactionBulkSaveCall wrap *gomock.Call
type MockTransactionBulkSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionBulkSaveCall) Return(arg0 error) *MockTransactionBulkSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionBulkSaveCall) Do(f func(context.Context, []any) error) *MockTransactionBulkSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionBulkSaveCall) DoAndReturn(f func(context.Context, []any) error) *MockTransactionBulkSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Close mocks base method.
func (m *MockTransaction) Close(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Close", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Close indicates an expected call of Close.
func (mr *MockTransactionMockRecorder) Close(ctx any) *MockTransactionCloseCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockTransaction)(nil).Close), ctx)
return &MockTransactionCloseCall{Call: call}
}
// MockTransactionCloseCall wrap *gomock.Call
type MockTransactionCloseCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionCloseCall) Return(arg0 error) *MockTransactionCloseCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionCloseCall) Do(f func(context.Context) error) *MockTransactionCloseCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionCloseCall) DoAndReturn(f func(context.Context) error) *MockTransactionCloseCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CopyFrom mocks base method.
func (m *MockTransaction) CopyFrom(ctx context.Context, tableName string, data []storage0.Copiable) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CopyFrom", ctx, tableName, data)
ret0, _ := ret[0].(error)
return ret0
}
// CopyFrom indicates an expected call of CopyFrom.
func (mr *MockTransactionMockRecorder) CopyFrom(ctx, tableName, data any) *MockTransactionCopyFromCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CopyFrom", reflect.TypeOf((*MockTransaction)(nil).CopyFrom), ctx, tableName, data)
return &MockTransactionCopyFromCall{Call: call}
}
// MockTransactionCopyFromCall wrap *gomock.Call
type MockTransactionCopyFromCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionCopyFromCall) Return(arg0 error) *MockTransactionCopyFromCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionCopyFromCall) Do(f func(context.Context, string, []storage0.Copiable) error) *MockTransactionCopyFromCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionCopyFromCall) DoAndReturn(f func(context.Context, string, []storage0.Copiable) error) *MockTransactionCopyFromCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// DeleteApp mocks base method.
func (m *MockTransaction) DeleteApp(ctx context.Context, appId uint64) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteApp", ctx, appId)
ret0, _ := ret[0].(error)
return ret0
}
// DeleteApp indicates an expected call of DeleteApp.
func (mr *MockTransactionMockRecorder) DeleteApp(ctx, appId any) *MockTransactionDeleteAppCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteApp", reflect.TypeOf((*MockTransaction)(nil).DeleteApp), ctx, appId)
return &MockTransactionDeleteAppCall{Call: call}
}
// MockTransactionDeleteAppCall wrap *gomock.Call
type MockTransactionDeleteAppCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionDeleteAppCall) Return(arg0 error) *MockTransactionDeleteAppCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionDeleteAppCall) Do(f func(context.Context, uint64) error) *MockTransactionDeleteAppCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionDeleteAppCall) DoAndReturn(f func(context.Context, uint64) error) *MockTransactionDeleteAppCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Exec mocks base method.
func (m *MockTransaction) Exec(ctx context.Context, query string, params ...any) (int64, error) {
m.ctrl.T.Helper()
varargs := []any{ctx, query}
for _, a := range params {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Exec", varargs...)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Exec indicates an expected call of Exec.
func (mr *MockTransactionMockRecorder) Exec(ctx, query any, params ...any) *MockTransactionExecCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx, query}, params...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exec", reflect.TypeOf((*MockTransaction)(nil).Exec), varargs...)
return &MockTransactionExecCall{Call: call}
}
// MockTransactionExecCall wrap *gomock.Call
type MockTransactionExecCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionExecCall) Return(arg0 int64, arg1 error) *MockTransactionExecCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionExecCall) Do(f func(context.Context, string, ...any) (int64, error)) *MockTransactionExecCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionExecCall) DoAndReturn(f func(context.Context, string, ...any) (int64, error)) *MockTransactionExecCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Flush mocks base method.
func (m *MockTransaction) Flush(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Flush", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Flush indicates an expected call of Flush.
func (mr *MockTransactionMockRecorder) Flush(ctx any) *MockTransactionFlushCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Flush", reflect.TypeOf((*MockTransaction)(nil).Flush), ctx)
return &MockTransactionFlushCall{Call: call}
}
// MockTransactionFlushCall wrap *gomock.Call
type MockTransactionFlushCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionFlushCall) Return(arg0 error) *MockTransactionFlushCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionFlushCall) Do(f func(context.Context) error) *MockTransactionFlushCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionFlushCall) DoAndReturn(f func(context.Context) error) *MockTransactionFlushCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetAddressId mocks base method.
func (m *MockTransaction) GetAddressId(ctx context.Context, hash string) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAddressId", ctx, hash)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetAddressId indicates an expected call of GetAddressId.
func (mr *MockTransactionMockRecorder) GetAddressId(ctx, hash any) *MockTransactionGetAddressIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAddressId", reflect.TypeOf((*MockTransaction)(nil).GetAddressId), ctx, hash)
return &MockTransactionGetAddressIdCall{Call: call}
}
// MockTransactionGetAddressIdCall wrap *gomock.Call
type MockTransactionGetAddressIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionGetAddressIdCall) Return(arg0 uint64, arg1 error) *MockTransactionGetAddressIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionGetAddressIdCall) Do(f func(context.Context, string) (uint64, error)) *MockTransactionGetAddressIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionGetAddressIdCall) DoAndReturn(f func(context.Context, string) (uint64, error)) *MockTransactionGetAddressIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetBridgeIdByAddressId mocks base method.
func (m *MockTransaction) GetBridgeIdByAddressId(ctx context.Context, id uint64) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetBridgeIdByAddressId", ctx, id)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetBridgeIdByAddressId indicates an expected call of GetBridgeIdByAddressId.
func (mr *MockTransactionMockRecorder) GetBridgeIdByAddressId(ctx, id any) *MockTransactionGetBridgeIdByAddressIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBridgeIdByAddressId", reflect.TypeOf((*MockTransaction)(nil).GetBridgeIdByAddressId), ctx, id)
return &MockTransactionGetBridgeIdByAddressIdCall{Call: call}
}
// MockTransactionGetBridgeIdByAddressIdCall wrap *gomock.Call
type MockTransactionGetBridgeIdByAddressIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionGetBridgeIdByAddressIdCall) Return(arg0 uint64, arg1 error) *MockTransactionGetBridgeIdByAddressIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionGetBridgeIdByAddressIdCall) Do(f func(context.Context, uint64) (uint64, error)) *MockTransactionGetBridgeIdByAddressIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionGetBridgeIdByAddressIdCall) DoAndReturn(f func(context.Context, uint64) (uint64, error)) *MockTransactionGetBridgeIdByAddressIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetProposerId mocks base method.
func (m *MockTransaction) GetProposerId(ctx context.Context, address string) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetProposerId", ctx, address)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetProposerId indicates an expected call of GetProposerId.
func (mr *MockTransactionMockRecorder) GetProposerId(ctx, address any) *MockTransactionGetProposerIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProposerId", reflect.TypeOf((*MockTransaction)(nil).GetProposerId), ctx, address)
return &MockTransactionGetProposerIdCall{Call: call}
}
// MockTransactionGetProposerIdCall wrap *gomock.Call
type MockTransactionGetProposerIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionGetProposerIdCall) Return(arg0 uint64, arg1 error) *MockTransactionGetProposerIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionGetProposerIdCall) Do(f func(context.Context, string) (uint64, error)) *MockTransactionGetProposerIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionGetProposerIdCall) DoAndReturn(f func(context.Context, string) (uint64, error)) *MockTransactionGetProposerIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetRollup mocks base method.
func (m *MockTransaction) GetRollup(ctx context.Context, rollupId []byte) (storage.Rollup, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetRollup", ctx, rollupId)
ret0, _ := ret[0].(storage.Rollup)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetRollup indicates an expected call of GetRollup.
func (mr *MockTransactionMockRecorder) GetRollup(ctx, rollupId any) *MockTransactionGetRollupCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRollup", reflect.TypeOf((*MockTransaction)(nil).GetRollup), ctx, rollupId)
return &MockTransactionGetRollupCall{Call: call}
}
// MockTransactionGetRollupCall wrap *gomock.Call
type MockTransactionGetRollupCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionGetRollupCall) Return(arg0 storage.Rollup, arg1 error) *MockTransactionGetRollupCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionGetRollupCall) Do(f func(context.Context, []byte) (storage.Rollup, error)) *MockTransactionGetRollupCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionGetRollupCall) DoAndReturn(f func(context.Context, []byte) (storage.Rollup, error)) *MockTransactionGetRollupCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// HandleError mocks base method.
func (m *MockTransaction) HandleError(ctx context.Context, err error) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HandleError", ctx, err)
ret0, _ := ret[0].(error)
return ret0
}
// HandleError indicates an expected call of HandleError.
func (mr *MockTransactionMockRecorder) HandleError(ctx, err any) *MockTransactionHandleErrorCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleError", reflect.TypeOf((*MockTransaction)(nil).HandleError), ctx, err)
return &MockTransactionHandleErrorCall{Call: call}
}
// MockTransactionHandleErrorCall wrap *gomock.Call
type MockTransactionHandleErrorCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionHandleErrorCall) Return(arg0 error) *MockTransactionHandleErrorCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionHandleErrorCall) Do(f func(context.Context, error) error) *MockTransactionHandleErrorCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionHandleErrorCall) DoAndReturn(f func(context.Context, error) error) *MockTransactionHandleErrorCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastBlock mocks base method.
func (m *MockTransaction) LastBlock(ctx context.Context) (storage.Block, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastBlock", ctx)
ret0, _ := ret[0].(storage.Block)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastBlock indicates an expected call of LastBlock.
func (mr *MockTransactionMockRecorder) LastBlock(ctx any) *MockTransactionLastBlockCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastBlock", reflect.TypeOf((*MockTransaction)(nil).LastBlock), ctx)
return &MockTransactionLastBlockCall{Call: call}
}
// MockTransactionLastBlockCall wrap *gomock.Call
type MockTransactionLastBlockCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionLastBlockCall) Return(block storage.Block, err error) *MockTransactionLastBlockCall {
c.Call = c.Call.Return(block, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionLastBlockCall) Do(f func(context.Context) (storage.Block, error)) *MockTransactionLastBlockCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionLastBlockCall) DoAndReturn(f func(context.Context) (storage.Block, error)) *MockTransactionLastBlockCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastNonce mocks base method.
func (m *MockTransaction) LastNonce(ctx context.Context, id uint64) (uint32, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastNonce", ctx, id)
ret0, _ := ret[0].(uint32)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastNonce indicates an expected call of LastNonce.
func (mr *MockTransactionMockRecorder) LastNonce(ctx, id any) *MockTransactionLastNonceCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastNonce", reflect.TypeOf((*MockTransaction)(nil).LastNonce), ctx, id)
return &MockTransactionLastNonceCall{Call: call}
}
// MockTransactionLastNonceCall wrap *gomock.Call
type MockTransactionLastNonceCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionLastNonceCall) Return(arg0 uint32, arg1 error) *MockTransactionLastNonceCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionLastNonceCall) Do(f func(context.Context, uint64) (uint32, error)) *MockTransactionLastNonceCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionLastNonceCall) DoAndReturn(f func(context.Context, uint64) (uint32, error)) *MockTransactionLastNonceCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RefreshLeaderboard mocks base method.
func (m *MockTransaction) RefreshLeaderboard(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RefreshLeaderboard", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// RefreshLeaderboard indicates an expected call of RefreshLeaderboard.
func (mr *MockTransactionMockRecorder) RefreshLeaderboard(ctx any) *MockTransactionRefreshLeaderboardCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefreshLeaderboard", reflect.TypeOf((*MockTransaction)(nil).RefreshLeaderboard), ctx)
return &MockTransactionRefreshLeaderboardCall{Call: call}
}
// MockTransactionRefreshLeaderboardCall wrap *gomock.Call
type MockTransactionRefreshLeaderboardCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRefreshLeaderboardCall) Return(arg0 error) *MockTransactionRefreshLeaderboardCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRefreshLeaderboardCall) Do(f func(context.Context) error) *MockTransactionRefreshLeaderboardCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRefreshLeaderboardCall) DoAndReturn(f func(context.Context) error) *MockTransactionRefreshLeaderboardCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RetentionBlockSignatures mocks base method.
func (m *MockTransaction) RetentionBlockSignatures(ctx context.Context, height types.Level) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RetentionBlockSignatures", ctx, height)
ret0, _ := ret[0].(error)
return ret0
}
// RetentionBlockSignatures indicates an expected call of RetentionBlockSignatures.
func (mr *MockTransactionMockRecorder) RetentionBlockSignatures(ctx, height any) *MockTransactionRetentionBlockSignaturesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RetentionBlockSignatures", reflect.TypeOf((*MockTransaction)(nil).RetentionBlockSignatures), ctx, height)
return &MockTransactionRetentionBlockSignaturesCall{Call: call}
}
// MockTransactionRetentionBlockSignaturesCall wrap *gomock.Call
type MockTransactionRetentionBlockSignaturesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRetentionBlockSignaturesCall) Return(arg0 error) *MockTransactionRetentionBlockSignaturesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRetentionBlockSignaturesCall) Do(f func(context.Context, types.Level) error) *MockTransactionRetentionBlockSignaturesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRetentionBlockSignaturesCall) DoAndReturn(f func(context.Context, types.Level) error) *MockTransactionRetentionBlockSignaturesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Rollback mocks base method.
func (m *MockTransaction) Rollback(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Rollback", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Rollback indicates an expected call of Rollback.
func (mr *MockTransactionMockRecorder) Rollback(ctx any) *MockTransactionRollbackCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Rollback", reflect.TypeOf((*MockTransaction)(nil).Rollback), ctx)
return &MockTransactionRollbackCall{Call: call}
}
// MockTransactionRollbackCall wrap *gomock.Call
type MockTransactionRollbackCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackCall) Return(arg0 error) *MockTransactionRollbackCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackCall) Do(f func(context.Context) error) *MockTransactionRollbackCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackCall) DoAndReturn(f func(context.Context) error) *MockTransactionRollbackCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackActions mocks base method.
func (m *MockTransaction) RollbackActions(ctx context.Context, height types.Level) ([]storage.Action, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackActions", ctx, height)
ret0, _ := ret[0].([]storage.Action)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackActions indicates an expected call of RollbackActions.
func (mr *MockTransactionMockRecorder) RollbackActions(ctx, height any) *MockTransactionRollbackActionsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackActions", reflect.TypeOf((*MockTransaction)(nil).RollbackActions), ctx, height)
return &MockTransactionRollbackActionsCall{Call: call}
}
// MockTransactionRollbackActionsCall wrap *gomock.Call
type MockTransactionRollbackActionsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackActionsCall) Return(actions []storage.Action, err error) *MockTransactionRollbackActionsCall {
c.Call = c.Call.Return(actions, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackActionsCall) Do(f func(context.Context, types.Level) ([]storage.Action, error)) *MockTransactionRollbackActionsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackActionsCall) DoAndReturn(f func(context.Context, types.Level) ([]storage.Action, error)) *MockTransactionRollbackActionsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackAddressActions mocks base method.
func (m *MockTransaction) RollbackAddressActions(ctx context.Context, height types.Level) ([]storage.AddressAction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackAddressActions", ctx, height)
ret0, _ := ret[0].([]storage.AddressAction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackAddressActions indicates an expected call of RollbackAddressActions.
func (mr *MockTransactionMockRecorder) RollbackAddressActions(ctx, height any) *MockTransactionRollbackAddressActionsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackAddressActions", reflect.TypeOf((*MockTransaction)(nil).RollbackAddressActions), ctx, height)
return &MockTransactionRollbackAddressActionsCall{Call: call}
}
// MockTransactionRollbackAddressActionsCall wrap *gomock.Call
type MockTransactionRollbackAddressActionsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackAddressActionsCall) Return(addrActions []storage.AddressAction, err error) *MockTransactionRollbackAddressActionsCall {
c.Call = c.Call.Return(addrActions, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackAddressActionsCall) Do(f func(context.Context, types.Level) ([]storage.AddressAction, error)) *MockTransactionRollbackAddressActionsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackAddressActionsCall) DoAndReturn(f func(context.Context, types.Level) ([]storage.AddressAction, error)) *MockTransactionRollbackAddressActionsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackAddresses mocks base method.
func (m *MockTransaction) RollbackAddresses(ctx context.Context, height types.Level) ([]storage.Address, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackAddresses", ctx, height)
ret0, _ := ret[0].([]storage.Address)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackAddresses indicates an expected call of RollbackAddresses.
func (mr *MockTransactionMockRecorder) RollbackAddresses(ctx, height any) *MockTransactionRollbackAddressesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackAddresses", reflect.TypeOf((*MockTransaction)(nil).RollbackAddresses), ctx, height)
return &MockTransactionRollbackAddressesCall{Call: call}
}
// MockTransactionRollbackAddressesCall wrap *gomock.Call
type MockTransactionRollbackAddressesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackAddressesCall) Return(address []storage.Address, err error) *MockTransactionRollbackAddressesCall {
c.Call = c.Call.Return(address, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackAddressesCall) Do(f func(context.Context, types.Level) ([]storage.Address, error)) *MockTransactionRollbackAddressesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackAddressesCall) DoAndReturn(f func(context.Context, types.Level) ([]storage.Address, error)) *MockTransactionRollbackAddressesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackBalanceUpdates mocks base method.
func (m *MockTransaction) RollbackBalanceUpdates(ctx context.Context, height types.Level) ([]storage.BalanceUpdate, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackBalanceUpdates", ctx, height)
ret0, _ := ret[0].([]storage.BalanceUpdate)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackBalanceUpdates indicates an expected call of RollbackBalanceUpdates.
func (mr *MockTransactionMockRecorder) RollbackBalanceUpdates(ctx, height any) *MockTransactionRollbackBalanceUpdatesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackBalanceUpdates", reflect.TypeOf((*MockTransaction)(nil).RollbackBalanceUpdates), ctx, height)
return &MockTransactionRollbackBalanceUpdatesCall{Call: call}
}
// MockTransactionRollbackBalanceUpdatesCall wrap *gomock.Call
type MockTransactionRollbackBalanceUpdatesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackBalanceUpdatesCall) Return(arg0 []storage.BalanceUpdate, arg1 error) *MockTransactionRollbackBalanceUpdatesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackBalanceUpdatesCall) Do(f func(context.Context, types.Level) ([]storage.BalanceUpdate, error)) *MockTransactionRollbackBalanceUpdatesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackBalanceUpdatesCall) DoAndReturn(f func(context.Context, types.Level) ([]storage.BalanceUpdate, error)) *MockTransactionRollbackBalanceUpdatesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackBalances mocks base method.
func (m *MockTransaction) RollbackBalances(ctx context.Context, ids []uint64) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackBalances", ctx, ids)
ret0, _ := ret[0].(error)
return ret0
}
// RollbackBalances indicates an expected call of RollbackBalances.
func (mr *MockTransactionMockRecorder) RollbackBalances(ctx, ids any) *MockTransactionRollbackBalancesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackBalances", reflect.TypeOf((*MockTransaction)(nil).RollbackBalances), ctx, ids)
return &MockTransactionRollbackBalancesCall{Call: call}
}
// MockTransactionRollbackBalancesCall wrap *gomock.Call
type MockTransactionRollbackBalancesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackBalancesCall) Return(arg0 error) *MockTransactionRollbackBalancesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackBalancesCall) Do(f func(context.Context, []uint64) error) *MockTransactionRollbackBalancesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackBalancesCall) DoAndReturn(f func(context.Context, []uint64) error) *MockTransactionRollbackBalancesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackBlock mocks base method.
func (m *MockTransaction) RollbackBlock(ctx context.Context, height types.Level) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackBlock", ctx, height)
ret0, _ := ret[0].(error)
return ret0
}
// RollbackBlock indicates an expected call of RollbackBlock.
func (mr *MockTransactionMockRecorder) RollbackBlock(ctx, height any) *MockTransactionRollbackBlockCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackBlock", reflect.TypeOf((*MockTransaction)(nil).RollbackBlock), ctx, height)
return &MockTransactionRollbackBlockCall{Call: call}
}
// MockTransactionRollbackBlockCall wrap *gomock.Call
type MockTransactionRollbackBlockCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackBlockCall) Return(arg0 error) *MockTransactionRollbackBlockCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackBlockCall) Do(f func(context.Context, types.Level) error) *MockTransactionRollbackBlockCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackBlockCall) DoAndReturn(f func(context.Context, types.Level) error) *MockTransactionRollbackBlockCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackBlockSignatures mocks base method.
func (m *MockTransaction) RollbackBlockSignatures(ctx context.Context, height types.Level) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackBlockSignatures", ctx, height)
ret0, _ := ret[0].(error)
return ret0
}
// RollbackBlockSignatures indicates an expected call of RollbackBlockSignatures.
func (mr *MockTransactionMockRecorder) RollbackBlockSignatures(ctx, height any) *MockTransactionRollbackBlockSignaturesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackBlockSignatures", reflect.TypeOf((*MockTransaction)(nil).RollbackBlockSignatures), ctx, height)
return &MockTransactionRollbackBlockSignaturesCall{Call: call}
}
// MockTransactionRollbackBlockSignaturesCall wrap *gomock.Call
type MockTransactionRollbackBlockSignaturesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackBlockSignaturesCall) Return(err error) *MockTransactionRollbackBlockSignaturesCall {
c.Call = c.Call.Return(err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackBlockSignaturesCall) Do(f func(context.Context, types.Level) error) *MockTransactionRollbackBlockSignaturesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackBlockSignaturesCall) DoAndReturn(f func(context.Context, types.Level) error) *MockTransactionRollbackBlockSignaturesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackBlockStats mocks base method.
func (m *MockTransaction) RollbackBlockStats(ctx context.Context, height types.Level) (storage.BlockStats, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackBlockStats", ctx, height)
ret0, _ := ret[0].(storage.BlockStats)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackBlockStats indicates an expected call of RollbackBlockStats.
func (mr *MockTransactionMockRecorder) RollbackBlockStats(ctx, height any) *MockTransactionRollbackBlockStatsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackBlockStats", reflect.TypeOf((*MockTransaction)(nil).RollbackBlockStats), ctx, height)
return &MockTransactionRollbackBlockStatsCall{Call: call}
}
// MockTransactionRollbackBlockStatsCall wrap *gomock.Call
type MockTransactionRollbackBlockStatsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackBlockStatsCall) Return(stats storage.BlockStats, err error) *MockTransactionRollbackBlockStatsCall {
c.Call = c.Call.Return(stats, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackBlockStatsCall) Do(f func(context.Context, types.Level) (storage.BlockStats, error)) *MockTransactionRollbackBlockStatsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackBlockStatsCall) DoAndReturn(f func(context.Context, types.Level) (storage.BlockStats, error)) *MockTransactionRollbackBlockStatsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackBridges mocks base method.
func (m *MockTransaction) RollbackBridges(ctx context.Context, height types.Level) (int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackBridges", ctx, height)
ret0, _ := ret[0].(int)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackBridges indicates an expected call of RollbackBridges.
func (mr *MockTransactionMockRecorder) RollbackBridges(ctx, height any) *MockTransactionRollbackBridgesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackBridges", reflect.TypeOf((*MockTransaction)(nil).RollbackBridges), ctx, height)
return &MockTransactionRollbackBridgesCall{Call: call}
}
// MockTransactionRollbackBridgesCall wrap *gomock.Call
type MockTransactionRollbackBridgesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackBridgesCall) Return(arg0 int, arg1 error) *MockTransactionRollbackBridgesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackBridgesCall) Do(f func(context.Context, types.Level) (int, error)) *MockTransactionRollbackBridgesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackBridgesCall) DoAndReturn(f func(context.Context, types.Level) (int, error)) *MockTransactionRollbackBridgesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackDeposits mocks base method.
func (m *MockTransaction) RollbackDeposits(ctx context.Context, height types.Level) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackDeposits", ctx, height)
ret0, _ := ret[0].(error)
return ret0
}
// RollbackDeposits indicates an expected call of RollbackDeposits.
func (mr *MockTransactionMockRecorder) RollbackDeposits(ctx, height any) *MockTransactionRollbackDepositsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackDeposits", reflect.TypeOf((*MockTransaction)(nil).RollbackDeposits), ctx, height)
return &MockTransactionRollbackDepositsCall{Call: call}
}
// MockTransactionRollbackDepositsCall wrap *gomock.Call
type MockTransactionRollbackDepositsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackDepositsCall) Return(err error) *MockTransactionRollbackDepositsCall {
c.Call = c.Call.Return(err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackDepositsCall) Do(f func(context.Context, types.Level) error) *MockTransactionRollbackDepositsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackDepositsCall) DoAndReturn(f func(context.Context, types.Level) error) *MockTransactionRollbackDepositsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackFees mocks base method.
func (m *MockTransaction) RollbackFees(ctx context.Context, height types.Level) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackFees", ctx, height)
ret0, _ := ret[0].(error)
return ret0
}
// RollbackFees indicates an expected call of RollbackFees.
func (mr *MockTransactionMockRecorder) RollbackFees(ctx, height any) *MockTransactionRollbackFeesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackFees", reflect.TypeOf((*MockTransaction)(nil).RollbackFees), ctx, height)
return &MockTransactionRollbackFeesCall{Call: call}
}
// MockTransactionRollbackFeesCall wrap *gomock.Call
type MockTransactionRollbackFeesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackFeesCall) Return(err error) *MockTransactionRollbackFeesCall {
c.Call = c.Call.Return(err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackFeesCall) Do(f func(context.Context, types.Level) error) *MockTransactionRollbackFeesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackFeesCall) DoAndReturn(f func(context.Context, types.Level) error) *MockTransactionRollbackFeesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackRollupActions mocks base method.
func (m *MockTransaction) RollbackRollupActions(ctx context.Context, height types.Level) ([]storage.RollupAction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackRollupActions", ctx, height)
ret0, _ := ret[0].([]storage.RollupAction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackRollupActions indicates an expected call of RollbackRollupActions.
func (mr *MockTransactionMockRecorder) RollbackRollupActions(ctx, height any) *MockTransactionRollbackRollupActionsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackRollupActions", reflect.TypeOf((*MockTransaction)(nil).RollbackRollupActions), ctx, height)
return &MockTransactionRollbackRollupActionsCall{Call: call}
}
// MockTransactionRollbackRollupActionsCall wrap *gomock.Call
type MockTransactionRollbackRollupActionsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackRollupActionsCall) Return(rollupActions []storage.RollupAction, err error) *MockTransactionRollbackRollupActionsCall {
c.Call = c.Call.Return(rollupActions, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackRollupActionsCall) Do(f func(context.Context, types.Level) ([]storage.RollupAction, error)) *MockTransactionRollbackRollupActionsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackRollupActionsCall) DoAndReturn(f func(context.Context, types.Level) ([]storage.RollupAction, error)) *MockTransactionRollbackRollupActionsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackRollupAddresses mocks base method.
func (m *MockTransaction) RollbackRollupAddresses(ctx context.Context, height types.Level) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackRollupAddresses", ctx, height)
ret0, _ := ret[0].(error)
return ret0
}
// RollbackRollupAddresses indicates an expected call of RollbackRollupAddresses.
func (mr *MockTransactionMockRecorder) RollbackRollupAddresses(ctx, height any) *MockTransactionRollbackRollupAddressesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackRollupAddresses", reflect.TypeOf((*MockTransaction)(nil).RollbackRollupAddresses), ctx, height)
return &MockTransactionRollbackRollupAddressesCall{Call: call}
}
// MockTransactionRollbackRollupAddressesCall wrap *gomock.Call
type MockTransactionRollbackRollupAddressesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackRollupAddressesCall) Return(err error) *MockTransactionRollbackRollupAddressesCall {
c.Call = c.Call.Return(err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackRollupAddressesCall) Do(f func(context.Context, types.Level) error) *MockTransactionRollbackRollupAddressesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackRollupAddressesCall) DoAndReturn(f func(context.Context, types.Level) error) *MockTransactionRollbackRollupAddressesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackRollups mocks base method.
func (m *MockTransaction) RollbackRollups(ctx context.Context, height types.Level) ([]storage.Rollup, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackRollups", ctx, height)
ret0, _ := ret[0].([]storage.Rollup)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackRollups indicates an expected call of RollbackRollups.
func (mr *MockTransactionMockRecorder) RollbackRollups(ctx, height any) *MockTransactionRollbackRollupsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackRollups", reflect.TypeOf((*MockTransaction)(nil).RollbackRollups), ctx, height)
return &MockTransactionRollbackRollupsCall{Call: call}
}
// MockTransactionRollbackRollupsCall wrap *gomock.Call
type MockTransactionRollbackRollupsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackRollupsCall) Return(arg0 []storage.Rollup, arg1 error) *MockTransactionRollbackRollupsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackRollupsCall) Do(f func(context.Context, types.Level) ([]storage.Rollup, error)) *MockTransactionRollbackRollupsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackRollupsCall) DoAndReturn(f func(context.Context, types.Level) ([]storage.Rollup, error)) *MockTransactionRollbackRollupsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackTransfers mocks base method.
func (m *MockTransaction) RollbackTransfers(ctx context.Context, height types.Level) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackTransfers", ctx, height)
ret0, _ := ret[0].(error)
return ret0
}
// RollbackTransfers indicates an expected call of RollbackTransfers.
func (mr *MockTransactionMockRecorder) RollbackTransfers(ctx, height any) *MockTransactionRollbackTransfersCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackTransfers", reflect.TypeOf((*MockTransaction)(nil).RollbackTransfers), ctx, height)
return &MockTransactionRollbackTransfersCall{Call: call}
}
// MockTransactionRollbackTransfersCall wrap *gomock.Call
type MockTransactionRollbackTransfersCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackTransfersCall) Return(err error) *MockTransactionRollbackTransfersCall {
c.Call = c.Call.Return(err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackTransfersCall) Do(f func(context.Context, types.Level) error) *MockTransactionRollbackTransfersCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackTransfersCall) DoAndReturn(f func(context.Context, types.Level) error) *MockTransactionRollbackTransfersCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackTxs mocks base method.
func (m *MockTransaction) RollbackTxs(ctx context.Context, height types.Level) ([]storage.Tx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackTxs", ctx, height)
ret0, _ := ret[0].([]storage.Tx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollbackTxs indicates an expected call of RollbackTxs.
func (mr *MockTransactionMockRecorder) RollbackTxs(ctx, height any) *MockTransactionRollbackTxsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackTxs", reflect.TypeOf((*MockTransaction)(nil).RollbackTxs), ctx, height)
return &MockTransactionRollbackTxsCall{Call: call}
}
// MockTransactionRollbackTxsCall wrap *gomock.Call
type MockTransactionRollbackTxsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackTxsCall) Return(txs []storage.Tx, err error) *MockTransactionRollbackTxsCall {
c.Call = c.Call.Return(txs, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackTxsCall) Do(f func(context.Context, types.Level) ([]storage.Tx, error)) *MockTransactionRollbackTxsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackTxsCall) DoAndReturn(f func(context.Context, types.Level) ([]storage.Tx, error)) *MockTransactionRollbackTxsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollbackValidators mocks base method.
func (m *MockTransaction) RollbackValidators(ctx context.Context, height types.Level) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollbackValidators", ctx, height)
ret0, _ := ret[0].(error)
return ret0
}
// RollbackValidators indicates an expected call of RollbackValidators.
func (mr *MockTransactionMockRecorder) RollbackValidators(ctx, height any) *MockTransactionRollbackValidatorsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackValidators", reflect.TypeOf((*MockTransaction)(nil).RollbackValidators), ctx, height)
return &MockTransactionRollbackValidatorsCall{Call: call}
}
// MockTransactionRollbackValidatorsCall wrap *gomock.Call
type MockTransactionRollbackValidatorsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionRollbackValidatorsCall) Return(err error) *MockTransactionRollbackValidatorsCall {
c.Call = c.Call.Return(err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionRollbackValidatorsCall) Do(f func(context.Context, types.Level) error) *MockTransactionRollbackValidatorsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionRollbackValidatorsCall) DoAndReturn(f func(context.Context, types.Level) error) *MockTransactionRollbackValidatorsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveActions mocks base method.
func (m *MockTransaction) SaveActions(ctx context.Context, actions ...*storage.Action) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range actions {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveActions", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveActions indicates an expected call of SaveActions.
func (mr *MockTransactionMockRecorder) SaveActions(ctx any, actions ...any) *MockTransactionSaveActionsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, actions...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveActions", reflect.TypeOf((*MockTransaction)(nil).SaveActions), varargs...)
return &MockTransactionSaveActionsCall{Call: call}
}
// MockTransactionSaveActionsCall wrap *gomock.Call
type MockTransactionSaveActionsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveActionsCall) Return(arg0 error) *MockTransactionSaveActionsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveActionsCall) Do(f func(context.Context, ...*storage.Action) error) *MockTransactionSaveActionsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveActionsCall) DoAndReturn(f func(context.Context, ...*storage.Action) error) *MockTransactionSaveActionsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveAddressActions mocks base method.
func (m *MockTransaction) SaveAddressActions(ctx context.Context, actions ...*storage.AddressAction) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range actions {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveAddressActions", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveAddressActions indicates an expected call of SaveAddressActions.
func (mr *MockTransactionMockRecorder) SaveAddressActions(ctx any, actions ...any) *MockTransactionSaveAddressActionsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, actions...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveAddressActions", reflect.TypeOf((*MockTransaction)(nil).SaveAddressActions), varargs...)
return &MockTransactionSaveAddressActionsCall{Call: call}
}
// MockTransactionSaveAddressActionsCall wrap *gomock.Call
type MockTransactionSaveAddressActionsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveAddressActionsCall) Return(arg0 error) *MockTransactionSaveAddressActionsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveAddressActionsCall) Do(f func(context.Context, ...*storage.AddressAction) error) *MockTransactionSaveAddressActionsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveAddressActionsCall) DoAndReturn(f func(context.Context, ...*storage.AddressAction) error) *MockTransactionSaveAddressActionsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveAddresses mocks base method.
func (m *MockTransaction) SaveAddresses(ctx context.Context, addresses ...*storage.Address) (int64, error) {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range addresses {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveAddresses", varargs...)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SaveAddresses indicates an expected call of SaveAddresses.
func (mr *MockTransactionMockRecorder) SaveAddresses(ctx any, addresses ...any) *MockTransactionSaveAddressesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, addresses...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveAddresses", reflect.TypeOf((*MockTransaction)(nil).SaveAddresses), varargs...)
return &MockTransactionSaveAddressesCall{Call: call}
}
// MockTransactionSaveAddressesCall wrap *gomock.Call
type MockTransactionSaveAddressesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveAddressesCall) Return(arg0 int64, arg1 error) *MockTransactionSaveAddressesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveAddressesCall) Do(f func(context.Context, ...*storage.Address) (int64, error)) *MockTransactionSaveAddressesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveAddressesCall) DoAndReturn(f func(context.Context, ...*storage.Address) (int64, error)) *MockTransactionSaveAddressesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveApp mocks base method.
func (m *MockTransaction) SaveApp(ctx context.Context, app *storage.App) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SaveApp", ctx, app)
ret0, _ := ret[0].(error)
return ret0
}
// SaveApp indicates an expected call of SaveApp.
func (mr *MockTransactionMockRecorder) SaveApp(ctx, app any) *MockTransactionSaveAppCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveApp", reflect.TypeOf((*MockTransaction)(nil).SaveApp), ctx, app)
return &MockTransactionSaveAppCall{Call: call}
}
// MockTransactionSaveAppCall wrap *gomock.Call
type MockTransactionSaveAppCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveAppCall) Return(arg0 error) *MockTransactionSaveAppCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveAppCall) Do(f func(context.Context, *storage.App) error) *MockTransactionSaveAppCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveAppCall) DoAndReturn(f func(context.Context, *storage.App) error) *MockTransactionSaveAppCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveBalanceUpdates mocks base method.
func (m *MockTransaction) SaveBalanceUpdates(ctx context.Context, updates ...storage.BalanceUpdate) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range updates {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveBalanceUpdates", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveBalanceUpdates indicates an expected call of SaveBalanceUpdates.
func (mr *MockTransactionMockRecorder) SaveBalanceUpdates(ctx any, updates ...any) *MockTransactionSaveBalanceUpdatesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, updates...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveBalanceUpdates", reflect.TypeOf((*MockTransaction)(nil).SaveBalanceUpdates), varargs...)
return &MockTransactionSaveBalanceUpdatesCall{Call: call}
}
// MockTransactionSaveBalanceUpdatesCall wrap *gomock.Call
type MockTransactionSaveBalanceUpdatesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveBalanceUpdatesCall) Return(arg0 error) *MockTransactionSaveBalanceUpdatesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveBalanceUpdatesCall) Do(f func(context.Context, ...storage.BalanceUpdate) error) *MockTransactionSaveBalanceUpdatesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveBalanceUpdatesCall) DoAndReturn(f func(context.Context, ...storage.BalanceUpdate) error) *MockTransactionSaveBalanceUpdatesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveBalances mocks base method.
func (m *MockTransaction) SaveBalances(ctx context.Context, balances ...storage.Balance) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range balances {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveBalances", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveBalances indicates an expected call of SaveBalances.
func (mr *MockTransactionMockRecorder) SaveBalances(ctx any, balances ...any) *MockTransactionSaveBalancesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, balances...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveBalances", reflect.TypeOf((*MockTransaction)(nil).SaveBalances), varargs...)
return &MockTransactionSaveBalancesCall{Call: call}
}
// MockTransactionSaveBalancesCall wrap *gomock.Call
type MockTransactionSaveBalancesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveBalancesCall) Return(arg0 error) *MockTransactionSaveBalancesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveBalancesCall) Do(f func(context.Context, ...storage.Balance) error) *MockTransactionSaveBalancesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveBalancesCall) DoAndReturn(f func(context.Context, ...storage.Balance) error) *MockTransactionSaveBalancesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveBlockSignatures mocks base method.
func (m *MockTransaction) SaveBlockSignatures(ctx context.Context, signs ...storage.BlockSignature) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range signs {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveBlockSignatures", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveBlockSignatures indicates an expected call of SaveBlockSignatures.
func (mr *MockTransactionMockRecorder) SaveBlockSignatures(ctx any, signs ...any) *MockTransactionSaveBlockSignaturesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, signs...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveBlockSignatures", reflect.TypeOf((*MockTransaction)(nil).SaveBlockSignatures), varargs...)
return &MockTransactionSaveBlockSignaturesCall{Call: call}
}
// MockTransactionSaveBlockSignaturesCall wrap *gomock.Call
type MockTransactionSaveBlockSignaturesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveBlockSignaturesCall) Return(arg0 error) *MockTransactionSaveBlockSignaturesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveBlockSignaturesCall) Do(f func(context.Context, ...storage.BlockSignature) error) *MockTransactionSaveBlockSignaturesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveBlockSignaturesCall) DoAndReturn(f func(context.Context, ...storage.BlockSignature) error) *MockTransactionSaveBlockSignaturesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveBridges mocks base method.
func (m *MockTransaction) SaveBridges(ctx context.Context, bridges ...*storage.Bridge) (int64, error) {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range bridges {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveBridges", varargs...)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SaveBridges indicates an expected call of SaveBridges.
func (mr *MockTransactionMockRecorder) SaveBridges(ctx any, bridges ...any) *MockTransactionSaveBridgesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, bridges...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveBridges", reflect.TypeOf((*MockTransaction)(nil).SaveBridges), varargs...)
return &MockTransactionSaveBridgesCall{Call: call}
}
// MockTransactionSaveBridgesCall wrap *gomock.Call
type MockTransactionSaveBridgesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveBridgesCall) Return(arg0 int64, arg1 error) *MockTransactionSaveBridgesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveBridgesCall) Do(f func(context.Context, ...*storage.Bridge) (int64, error)) *MockTransactionSaveBridgesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveBridgesCall) DoAndReturn(f func(context.Context, ...*storage.Bridge) (int64, error)) *MockTransactionSaveBridgesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveConstants mocks base method.
func (m *MockTransaction) SaveConstants(ctx context.Context, constants ...storage.Constant) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range constants {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveConstants", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveConstants indicates an expected call of SaveConstants.
func (mr *MockTransactionMockRecorder) SaveConstants(ctx any, constants ...any) *MockTransactionSaveConstantsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, constants...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveConstants", reflect.TypeOf((*MockTransaction)(nil).SaveConstants), varargs...)
return &MockTransactionSaveConstantsCall{Call: call}
}
// MockTransactionSaveConstantsCall wrap *gomock.Call
type MockTransactionSaveConstantsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveConstantsCall) Return(arg0 error) *MockTransactionSaveConstantsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveConstantsCall) Do(f func(context.Context, ...storage.Constant) error) *MockTransactionSaveConstantsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveConstantsCall) DoAndReturn(f func(context.Context, ...storage.Constant) error) *MockTransactionSaveConstantsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveDeposits mocks base method.
func (m *MockTransaction) SaveDeposits(ctx context.Context, deposits ...*storage.Deposit) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range deposits {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveDeposits", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveDeposits indicates an expected call of SaveDeposits.
func (mr *MockTransactionMockRecorder) SaveDeposits(ctx any, deposits ...any) *MockTransactionSaveDepositsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, deposits...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveDeposits", reflect.TypeOf((*MockTransaction)(nil).SaveDeposits), varargs...)
return &MockTransactionSaveDepositsCall{Call: call}
}
// MockTransactionSaveDepositsCall wrap *gomock.Call
type MockTransactionSaveDepositsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveDepositsCall) Return(arg0 error) *MockTransactionSaveDepositsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveDepositsCall) Do(f func(context.Context, ...*storage.Deposit) error) *MockTransactionSaveDepositsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveDepositsCall) DoAndReturn(f func(context.Context, ...*storage.Deposit) error) *MockTransactionSaveDepositsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveFees mocks base method.
func (m *MockTransaction) SaveFees(ctx context.Context, fees ...*storage.Fee) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range fees {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveFees", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveFees indicates an expected call of SaveFees.
func (mr *MockTransactionMockRecorder) SaveFees(ctx any, fees ...any) *MockTransactionSaveFeesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, fees...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveFees", reflect.TypeOf((*MockTransaction)(nil).SaveFees), varargs...)
return &MockTransactionSaveFeesCall{Call: call}
}
// MockTransactionSaveFeesCall wrap *gomock.Call
type MockTransactionSaveFeesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveFeesCall) Return(arg0 error) *MockTransactionSaveFeesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveFeesCall) Do(f func(context.Context, ...*storage.Fee) error) *MockTransactionSaveFeesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveFeesCall) DoAndReturn(f func(context.Context, ...*storage.Fee) error) *MockTransactionSaveFeesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveMarketProviders mocks base method.
func (m *MockTransaction) SaveMarketProviders(ctx context.Context, providers ...storage.MarketProviderUpdate) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range providers {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveMarketProviders", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveMarketProviders indicates an expected call of SaveMarketProviders.
func (mr *MockTransactionMockRecorder) SaveMarketProviders(ctx any, providers ...any) *MockTransactionSaveMarketProvidersCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, providers...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveMarketProviders", reflect.TypeOf((*MockTransaction)(nil).SaveMarketProviders), varargs...)
return &MockTransactionSaveMarketProvidersCall{Call: call}
}
// MockTransactionSaveMarketProvidersCall wrap *gomock.Call
type MockTransactionSaveMarketProvidersCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveMarketProvidersCall) Return(arg0 error) *MockTransactionSaveMarketProvidersCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveMarketProvidersCall) Do(f func(context.Context, ...storage.MarketProviderUpdate) error) *MockTransactionSaveMarketProvidersCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveMarketProvidersCall) DoAndReturn(f func(context.Context, ...storage.MarketProviderUpdate) error) *MockTransactionSaveMarketProvidersCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveMarkets mocks base method.
func (m *MockTransaction) SaveMarkets(ctx context.Context, markets ...storage.MarketUpdate) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range markets {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveMarkets", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveMarkets indicates an expected call of SaveMarkets.
func (mr *MockTransactionMockRecorder) SaveMarkets(ctx any, markets ...any) *MockTransactionSaveMarketsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, markets...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveMarkets", reflect.TypeOf((*MockTransaction)(nil).SaveMarkets), varargs...)
return &MockTransactionSaveMarketsCall{Call: call}
}
// MockTransactionSaveMarketsCall wrap *gomock.Call
type MockTransactionSaveMarketsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveMarketsCall) Return(arg0 error) *MockTransactionSaveMarketsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveMarketsCall) Do(f func(context.Context, ...storage.MarketUpdate) error) *MockTransactionSaveMarketsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveMarketsCall) DoAndReturn(f func(context.Context, ...storage.MarketUpdate) error) *MockTransactionSaveMarketsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SavePrices mocks base method.
func (m *MockTransaction) SavePrices(ctx context.Context, prices ...storage.Price) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range prices {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SavePrices", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SavePrices indicates an expected call of SavePrices.
func (mr *MockTransactionMockRecorder) SavePrices(ctx any, prices ...any) *MockTransactionSavePricesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, prices...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePrices", reflect.TypeOf((*MockTransaction)(nil).SavePrices), varargs...)
return &MockTransactionSavePricesCall{Call: call}
}
// MockTransactionSavePricesCall wrap *gomock.Call
type MockTransactionSavePricesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSavePricesCall) Return(arg0 error) *MockTransactionSavePricesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSavePricesCall) Do(f func(context.Context, ...storage.Price) error) *MockTransactionSavePricesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSavePricesCall) DoAndReturn(f func(context.Context, ...storage.Price) error) *MockTransactionSavePricesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveRollupActions mocks base method.
func (m *MockTransaction) SaveRollupActions(ctx context.Context, actions ...*storage.RollupAction) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range actions {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveRollupActions", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveRollupActions indicates an expected call of SaveRollupActions.
func (mr *MockTransactionMockRecorder) SaveRollupActions(ctx any, actions ...any) *MockTransactionSaveRollupActionsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, actions...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveRollupActions", reflect.TypeOf((*MockTransaction)(nil).SaveRollupActions), varargs...)
return &MockTransactionSaveRollupActionsCall{Call: call}
}
// MockTransactionSaveRollupActionsCall wrap *gomock.Call
type MockTransactionSaveRollupActionsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveRollupActionsCall) Return(arg0 error) *MockTransactionSaveRollupActionsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveRollupActionsCall) Do(f func(context.Context, ...*storage.RollupAction) error) *MockTransactionSaveRollupActionsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveRollupActionsCall) DoAndReturn(f func(context.Context, ...*storage.RollupAction) error) *MockTransactionSaveRollupActionsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveRollupAddresses mocks base method.
func (m *MockTransaction) SaveRollupAddresses(ctx context.Context, addresses ...*storage.RollupAddress) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range addresses {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveRollupAddresses", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveRollupAddresses indicates an expected call of SaveRollupAddresses.
func (mr *MockTransactionMockRecorder) SaveRollupAddresses(ctx any, addresses ...any) *MockTransactionSaveRollupAddressesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, addresses...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveRollupAddresses", reflect.TypeOf((*MockTransaction)(nil).SaveRollupAddresses), varargs...)
return &MockTransactionSaveRollupAddressesCall{Call: call}
}
// MockTransactionSaveRollupAddressesCall wrap *gomock.Call
type MockTransactionSaveRollupAddressesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveRollupAddressesCall) Return(arg0 error) *MockTransactionSaveRollupAddressesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveRollupAddressesCall) Do(f func(context.Context, ...*storage.RollupAddress) error) *MockTransactionSaveRollupAddressesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveRollupAddressesCall) DoAndReturn(f func(context.Context, ...*storage.RollupAddress) error) *MockTransactionSaveRollupAddressesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveRollups mocks base method.
func (m *MockTransaction) SaveRollups(ctx context.Context, rollups ...*storage.Rollup) (int64, error) {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range rollups {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveRollups", varargs...)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SaveRollups indicates an expected call of SaveRollups.
func (mr *MockTransactionMockRecorder) SaveRollups(ctx any, rollups ...any) *MockTransactionSaveRollupsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, rollups...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveRollups", reflect.TypeOf((*MockTransaction)(nil).SaveRollups), varargs...)
return &MockTransactionSaveRollupsCall{Call: call}
}
// MockTransactionSaveRollupsCall wrap *gomock.Call
type MockTransactionSaveRollupsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveRollupsCall) Return(arg0 int64, arg1 error) *MockTransactionSaveRollupsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveRollupsCall) Do(f func(context.Context, ...*storage.Rollup) (int64, error)) *MockTransactionSaveRollupsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveRollupsCall) DoAndReturn(f func(context.Context, ...*storage.Rollup) (int64, error)) *MockTransactionSaveRollupsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveTransactions mocks base method.
func (m *MockTransaction) SaveTransactions(ctx context.Context, txs ...*storage.Tx) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range txs {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveTransactions", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveTransactions indicates an expected call of SaveTransactions.
func (mr *MockTransactionMockRecorder) SaveTransactions(ctx any, txs ...any) *MockTransactionSaveTransactionsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, txs...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveTransactions", reflect.TypeOf((*MockTransaction)(nil).SaveTransactions), varargs...)
return &MockTransactionSaveTransactionsCall{Call: call}
}
// MockTransactionSaveTransactionsCall wrap *gomock.Call
type MockTransactionSaveTransactionsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveTransactionsCall) Return(arg0 error) *MockTransactionSaveTransactionsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveTransactionsCall) Do(f func(context.Context, ...*storage.Tx) error) *MockTransactionSaveTransactionsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveTransactionsCall) DoAndReturn(f func(context.Context, ...*storage.Tx) error) *MockTransactionSaveTransactionsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveTransfers mocks base method.
func (m *MockTransaction) SaveTransfers(ctx context.Context, transfers ...*storage.Transfer) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range transfers {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveTransfers", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveTransfers indicates an expected call of SaveTransfers.
func (mr *MockTransactionMockRecorder) SaveTransfers(ctx any, transfers ...any) *MockTransactionSaveTransfersCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, transfers...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveTransfers", reflect.TypeOf((*MockTransaction)(nil).SaveTransfers), varargs...)
return &MockTransactionSaveTransfersCall{Call: call}
}
// MockTransactionSaveTransfersCall wrap *gomock.Call
type MockTransactionSaveTransfersCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveTransfersCall) Return(arg0 error) *MockTransactionSaveTransfersCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveTransfersCall) Do(f func(context.Context, ...*storage.Transfer) error) *MockTransactionSaveTransfersCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveTransfersCall) DoAndReturn(f func(context.Context, ...*storage.Transfer) error) *MockTransactionSaveTransfersCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SaveValidators mocks base method.
func (m *MockTransaction) SaveValidators(ctx context.Context, validators ...*storage.Validator) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range validators {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SaveValidators", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// SaveValidators indicates an expected call of SaveValidators.
func (mr *MockTransactionMockRecorder) SaveValidators(ctx any, validators ...any) *MockTransactionSaveValidatorsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, validators...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveValidators", reflect.TypeOf((*MockTransaction)(nil).SaveValidators), varargs...)
return &MockTransactionSaveValidatorsCall{Call: call}
}
// MockTransactionSaveValidatorsCall wrap *gomock.Call
type MockTransactionSaveValidatorsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionSaveValidatorsCall) Return(arg0 error) *MockTransactionSaveValidatorsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionSaveValidatorsCall) Do(f func(context.Context, ...*storage.Validator) error) *MockTransactionSaveValidatorsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionSaveValidatorsCall) DoAndReturn(f func(context.Context, ...*storage.Validator) error) *MockTransactionSaveValidatorsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// State mocks base method.
func (m *MockTransaction) State(ctx context.Context, name string) (storage.State, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "State", ctx, name)
ret0, _ := ret[0].(storage.State)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// State indicates an expected call of State.
func (mr *MockTransactionMockRecorder) State(ctx, name any) *MockTransactionStateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "State", reflect.TypeOf((*MockTransaction)(nil).State), ctx, name)
return &MockTransactionStateCall{Call: call}
}
// MockTransactionStateCall wrap *gomock.Call
type MockTransactionStateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionStateCall) Return(state storage.State, err error) *MockTransactionStateCall {
c.Call = c.Call.Return(state, err)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionStateCall) Do(f func(context.Context, string) (storage.State, error)) *MockTransactionStateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionStateCall) DoAndReturn(f func(context.Context, string) (storage.State, error)) *MockTransactionStateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Tx mocks base method.
func (m *MockTransaction) Tx() *bun.Tx {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Tx")
ret0, _ := ret[0].(*bun.Tx)
return ret0
}
// Tx indicates an expected call of Tx.
func (mr *MockTransactionMockRecorder) Tx() *MockTransactionTxCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Tx", reflect.TypeOf((*MockTransaction)(nil).Tx))
return &MockTransactionTxCall{Call: call}
}
// MockTransactionTxCall wrap *gomock.Call
type MockTransactionTxCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionTxCall) Return(arg0 *bun.Tx) *MockTransactionTxCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionTxCall) Do(f func() *bun.Tx) *MockTransactionTxCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionTxCall) DoAndReturn(f func() *bun.Tx) *MockTransactionTxCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m *MockTransaction) Update(ctx context.Context, model any) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Update", ctx, model)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockTransactionMockRecorder) Update(ctx, model any) *MockTransactionUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockTransaction)(nil).Update), ctx, model)
return &MockTransactionUpdateCall{Call: call}
}
// MockTransactionUpdateCall wrap *gomock.Call
type MockTransactionUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionUpdateCall) Return(arg0 error) *MockTransactionUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionUpdateCall) Do(f func(context.Context, any) error) *MockTransactionUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionUpdateCall) DoAndReturn(f func(context.Context, any) error) *MockTransactionUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// UpdateAddresses mocks base method.
func (m *MockTransaction) UpdateAddresses(ctx context.Context, address ...*storage.Address) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range address {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "UpdateAddresses", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateAddresses indicates an expected call of UpdateAddresses.
func (mr *MockTransactionMockRecorder) UpdateAddresses(ctx any, address ...any) *MockTransactionUpdateAddressesCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, address...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAddresses", reflect.TypeOf((*MockTransaction)(nil).UpdateAddresses), varargs...)
return &MockTransactionUpdateAddressesCall{Call: call}
}
// MockTransactionUpdateAddressesCall wrap *gomock.Call
type MockTransactionUpdateAddressesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionUpdateAddressesCall) Return(arg0 error) *MockTransactionUpdateAddressesCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionUpdateAddressesCall) Do(f func(context.Context, ...*storage.Address) error) *MockTransactionUpdateAddressesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionUpdateAddressesCall) DoAndReturn(f func(context.Context, ...*storage.Address) error) *MockTransactionUpdateAddressesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// UpdateApp mocks base method.
func (m *MockTransaction) UpdateApp(ctx context.Context, app *storage.App) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateApp", ctx, app)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateApp indicates an expected call of UpdateApp.
func (mr *MockTransactionMockRecorder) UpdateApp(ctx, app any) *MockTransactionUpdateAppCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateApp", reflect.TypeOf((*MockTransaction)(nil).UpdateApp), ctx, app)
return &MockTransactionUpdateAppCall{Call: call}
}
// MockTransactionUpdateAppCall wrap *gomock.Call
type MockTransactionUpdateAppCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionUpdateAppCall) Return(arg0 error) *MockTransactionUpdateAppCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionUpdateAppCall) Do(f func(context.Context, *storage.App) error) *MockTransactionUpdateAppCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionUpdateAppCall) DoAndReturn(f func(context.Context, *storage.App) error) *MockTransactionUpdateAppCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// UpdateConstants mocks base method.
func (m *MockTransaction) UpdateConstants(ctx context.Context, constants ...*storage.Constant) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range constants {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "UpdateConstants", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateConstants indicates an expected call of UpdateConstants.
func (mr *MockTransactionMockRecorder) UpdateConstants(ctx any, constants ...any) *MockTransactionUpdateConstantsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, constants...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateConstants", reflect.TypeOf((*MockTransaction)(nil).UpdateConstants), varargs...)
return &MockTransactionUpdateConstantsCall{Call: call}
}
// MockTransactionUpdateConstantsCall wrap *gomock.Call
type MockTransactionUpdateConstantsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionUpdateConstantsCall) Return(arg0 error) *MockTransactionUpdateConstantsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionUpdateConstantsCall) Do(f func(context.Context, ...*storage.Constant) error) *MockTransactionUpdateConstantsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionUpdateConstantsCall) DoAndReturn(f func(context.Context, ...*storage.Constant) error) *MockTransactionUpdateConstantsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// UpdateRollups mocks base method.
func (m *MockTransaction) UpdateRollups(ctx context.Context, rollups ...*storage.Rollup) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range rollups {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "UpdateRollups", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateRollups indicates an expected call of UpdateRollups.
func (mr *MockTransactionMockRecorder) UpdateRollups(ctx any, rollups ...any) *MockTransactionUpdateRollupsCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, rollups...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRollups", reflect.TypeOf((*MockTransaction)(nil).UpdateRollups), varargs...)
return &MockTransactionUpdateRollupsCall{Call: call}
}
// MockTransactionUpdateRollupsCall wrap *gomock.Call
type MockTransactionUpdateRollupsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionUpdateRollupsCall) Return(arg0 error) *MockTransactionUpdateRollupsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionUpdateRollupsCall) Do(f func(context.Context, ...*storage.Rollup) error) *MockTransactionUpdateRollupsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionUpdateRollupsCall) DoAndReturn(f func(context.Context, ...*storage.Rollup) error) *MockTransactionUpdateRollupsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Validators mocks base method.
func (m *MockTransaction) Validators(ctx context.Context) ([]storage.Validator, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Validators", ctx)
ret0, _ := ret[0].([]storage.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Validators indicates an expected call of Validators.
func (mr *MockTransactionMockRecorder) Validators(ctx any) *MockTransactionValidatorsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Validators", reflect.TypeOf((*MockTransaction)(nil).Validators), ctx)
return &MockTransactionValidatorsCall{Call: call}
}
// MockTransactionValidatorsCall wrap *gomock.Call
type MockTransactionValidatorsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockTransactionValidatorsCall) Return(arg0 []storage.Validator, arg1 error) *MockTransactionValidatorsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockTransactionValidatorsCall) Do(f func(context.Context) ([]storage.Validator, error)) *MockTransactionValidatorsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockTransactionValidatorsCall) DoAndReturn(f func(context.Context) ([]storage.Validator, error)) *MockTransactionValidatorsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// MockISearch is a mock of ISearch interface.
type MockISearch struct {
ctrl *gomock.Controller
recorder *MockISearchMockRecorder
}
// MockISearchMockRecorder is the mock recorder for MockISearch.
type MockISearchMockRecorder struct {
mock *MockISearch
}
// NewMockISearch creates a new mock instance.
func NewMockISearch(ctrl *gomock.Controller) *MockISearch {
mock := &MockISearch{ctrl: ctrl}
mock.recorder = &MockISearchMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockISearch) EXPECT() *MockISearchMockRecorder {
return m.recorder
}
// Search mocks base method.
func (m *MockISearch) Search(ctx context.Context, query string) ([]storage.SearchResult, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Search", ctx, query)
ret0, _ := ret[0].([]storage.SearchResult)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Search indicates an expected call of Search.
func (mr *MockISearchMockRecorder) Search(ctx, query any) *MockISearchSearchCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Search", reflect.TypeOf((*MockISearch)(nil).Search), ctx, query)
return &MockISearchSearchCall{Call: call}
}
// MockISearchSearchCall wrap *gomock.Call
type MockISearchSearchCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockISearchSearchCall) Return(arg0 []storage.SearchResult, arg1 error) *MockISearchSearchCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockISearchSearchCall) Do(f func(context.Context, string) ([]storage.SearchResult, error)) *MockISearchSearchCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockISearchSearchCall) DoAndReturn(f func(context.Context, string) ([]storage.SearchResult, error)) *MockISearchSearchCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// MockNotificator is a mock of Notificator interface.
type MockNotificator struct {
ctrl *gomock.Controller
recorder *MockNotificatorMockRecorder
}
// MockNotificatorMockRecorder is the mock recorder for MockNotificator.
type MockNotificatorMockRecorder struct {
mock *MockNotificator
}
// NewMockNotificator creates a new mock instance.
func NewMockNotificator(ctrl *gomock.Controller) *MockNotificator {
mock := &MockNotificator{ctrl: ctrl}
mock.recorder = &MockNotificatorMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockNotificator) EXPECT() *MockNotificatorMockRecorder {
return m.recorder
}
// Notify mocks base method.
func (m *MockNotificator) Notify(ctx context.Context, channel, payload string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Notify", ctx, channel, payload)
ret0, _ := ret[0].(error)
return ret0
}
// Notify indicates an expected call of Notify.
func (mr *MockNotificatorMockRecorder) Notify(ctx, channel, payload any) *MockNotificatorNotifyCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Notify", reflect.TypeOf((*MockNotificator)(nil).Notify), ctx, channel, payload)
return &MockNotificatorNotifyCall{Call: call}
}
// MockNotificatorNotifyCall wrap *gomock.Call
type MockNotificatorNotifyCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockNotificatorNotifyCall) Return(arg0 error) *MockNotificatorNotifyCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockNotificatorNotifyCall) Do(f func(context.Context, string, string) error) *MockNotificatorNotifyCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockNotificatorNotifyCall) DoAndReturn(f func(context.Context, string, string) error) *MockNotificatorNotifyCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// MockListener is a mock of Listener interface.
type MockListener struct {
ctrl *gomock.Controller
recorder *MockListenerMockRecorder
}
// MockListenerMockRecorder is the mock recorder for MockListener.
type MockListenerMockRecorder struct {
mock *MockListener
}
// NewMockListener creates a new mock instance.
func NewMockListener(ctrl *gomock.Controller) *MockListener {
mock := &MockListener{ctrl: ctrl}
mock.recorder = &MockListenerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockListener) EXPECT() *MockListenerMockRecorder {
return m.recorder
}
// Close mocks base method.
func (m *MockListener) Close() error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Close")
ret0, _ := ret[0].(error)
return ret0
}
// Close indicates an expected call of Close.
func (mr *MockListenerMockRecorder) Close() *MockListenerCloseCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockListener)(nil).Close))
return &MockListenerCloseCall{Call: call}
}
// MockListenerCloseCall wrap *gomock.Call
type MockListenerCloseCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockListenerCloseCall) Return(arg0 error) *MockListenerCloseCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockListenerCloseCall) Do(f func() error) *MockListenerCloseCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockListenerCloseCall) DoAndReturn(f func() error) *MockListenerCloseCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Listen mocks base method.
func (m *MockListener) Listen() chan *pq.Notification {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Listen")
ret0, _ := ret[0].(chan *pq.Notification)
return ret0
}
// Listen indicates an expected call of Listen.
func (mr *MockListenerMockRecorder) Listen() *MockListenerListenCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Listen", reflect.TypeOf((*MockListener)(nil).Listen))
return &MockListenerListenCall{Call: call}
}
// MockListenerListenCall wrap *gomock.Call
type MockListenerListenCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockListenerListenCall) Return(arg0 chan *pq.Notification) *MockListenerListenCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockListenerListenCall) Do(f func() chan *pq.Notification) *MockListenerListenCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockListenerListenCall) DoAndReturn(f func() chan *pq.Notification) *MockListenerListenCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Subscribe mocks base method.
func (m *MockListener) Subscribe(ctx context.Context, channels ...string) error {
m.ctrl.T.Helper()
varargs := []any{ctx}
for _, a := range channels {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Subscribe", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// Subscribe indicates an expected call of Subscribe.
func (mr *MockListenerMockRecorder) Subscribe(ctx any, channels ...any) *MockListenerSubscribeCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx}, channels...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Subscribe", reflect.TypeOf((*MockListener)(nil).Subscribe), varargs...)
return &MockListenerSubscribeCall{Call: call}
}
// MockListenerSubscribeCall wrap *gomock.Call
type MockListenerSubscribeCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockListenerSubscribeCall) Return(arg0 error) *MockListenerSubscribeCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockListenerSubscribeCall) Do(f func(context.Context, ...string) error) *MockListenerSubscribeCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockListenerSubscribeCall) DoAndReturn(f func(context.Context, ...string) error) *MockListenerSubscribeCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// MockListenerFactory is a mock of ListenerFactory interface.
type MockListenerFactory struct {
ctrl *gomock.Controller
recorder *MockListenerFactoryMockRecorder
}
// MockListenerFactoryMockRecorder is the mock recorder for MockListenerFactory.
type MockListenerFactoryMockRecorder struct {
mock *MockListenerFactory
}
// NewMockListenerFactory creates a new mock instance.
func NewMockListenerFactory(ctrl *gomock.Controller) *MockListenerFactory {
mock := &MockListenerFactory{ctrl: ctrl}
mock.recorder = &MockListenerFactoryMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockListenerFactory) EXPECT() *MockListenerFactoryMockRecorder {
return m.recorder
}
// CreateListener mocks base method.
func (m *MockListenerFactory) CreateListener() storage.Listener {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateListener")
ret0, _ := ret[0].(storage.Listener)
return ret0
}
// CreateListener indicates an expected call of CreateListener.
func (mr *MockListenerFactoryMockRecorder) CreateListener() *MockListenerFactoryCreateListenerCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateListener", reflect.TypeOf((*MockListenerFactory)(nil).CreateListener))
return &MockListenerFactoryCreateListenerCall{Call: call}
}
// MockListenerFactoryCreateListenerCall wrap *gomock.Call
type MockListenerFactoryCreateListenerCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockListenerFactoryCreateListenerCall) Return(arg0 storage.Listener) *MockListenerFactoryCreateListenerCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockListenerFactoryCreateListenerCall) Do(f func() storage.Listener) *MockListenerFactoryCreateListenerCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockListenerFactoryCreateListenerCall) DoAndReturn(f func() storage.Listener) *MockListenerFactoryCreateListenerCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: market.go
//
// Generated by this command:
//
// mockgen -source=market.go -destination=mock/market.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIMarket is a mock of IMarket interface.
type MockIMarket struct {
ctrl *gomock.Controller
recorder *MockIMarketMockRecorder
}
// MockIMarketMockRecorder is the mock recorder for MockIMarket.
type MockIMarketMockRecorder struct {
mock *MockIMarket
}
// NewMockIMarket creates a new mock instance.
func NewMockIMarket(ctrl *gomock.Controller) *MockIMarket {
mock := &MockIMarket{ctrl: ctrl}
mock.recorder = &MockIMarketMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIMarket) EXPECT() *MockIMarketMockRecorder {
return m.recorder
}
// Decimals mocks base method.
func (m *MockIMarket) Decimals(ctx context.Context, pair string) (int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Decimals", ctx, pair)
ret0, _ := ret[0].(int)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Decimals indicates an expected call of Decimals.
func (mr *MockIMarketMockRecorder) Decimals(ctx, pair any) *MockIMarketDecimalsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Decimals", reflect.TypeOf((*MockIMarket)(nil).Decimals), ctx, pair)
return &MockIMarketDecimalsCall{Call: call}
}
// MockIMarketDecimalsCall wrap *gomock.Call
type MockIMarketDecimalsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIMarketDecimalsCall) Return(arg0 int, arg1 error) *MockIMarketDecimalsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIMarketDecimalsCall) Do(f func(context.Context, string) (int, error)) *MockIMarketDecimalsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIMarketDecimalsCall) DoAndReturn(f func(context.Context, string) (int, error)) *MockIMarketDecimalsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Get mocks base method.
func (m *MockIMarket) Get(ctx context.Context, pair string) (storage.Market, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Get", ctx, pair)
ret0, _ := ret[0].(storage.Market)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Get indicates an expected call of Get.
func (mr *MockIMarketMockRecorder) Get(ctx, pair any) *MockIMarketGetCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockIMarket)(nil).Get), ctx, pair)
return &MockIMarketGetCall{Call: call}
}
// MockIMarketGetCall wrap *gomock.Call
type MockIMarketGetCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIMarketGetCall) Return(arg0 storage.Market, arg1 error) *MockIMarketGetCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIMarketGetCall) Do(f func(context.Context, string) (storage.Market, error)) *MockIMarketGetCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIMarketGetCall) DoAndReturn(f func(context.Context, string) (storage.Market, error)) *MockIMarketGetCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIMarket) List(ctx context.Context, limit, offset int) ([]storage.Market, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset)
ret0, _ := ret[0].([]storage.Market)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIMarketMockRecorder) List(ctx, limit, offset any) *MockIMarketListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIMarket)(nil).List), ctx, limit, offset)
return &MockIMarketListCall{Call: call}
}
// MockIMarketListCall wrap *gomock.Call
type MockIMarketListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIMarketListCall) Return(arg0 []storage.Market, arg1 error) *MockIMarketListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIMarketListCall) Do(f func(context.Context, int, int) ([]storage.Market, error)) *MockIMarketListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIMarketListCall) DoAndReturn(f func(context.Context, int, int) ([]storage.Market, error)) *MockIMarketListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: price.go
//
// Generated by this command:
//
// mockgen -source=price.go -destination=mock/price.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIPrice is a mock of IPrice interface.
type MockIPrice struct {
ctrl *gomock.Controller
recorder *MockIPriceMockRecorder
}
// MockIPriceMockRecorder is the mock recorder for MockIPrice.
type MockIPriceMockRecorder struct {
mock *MockIPrice
}
// NewMockIPrice creates a new mock instance.
func NewMockIPrice(ctrl *gomock.Controller) *MockIPrice {
mock := &MockIPrice{ctrl: ctrl}
mock.recorder = &MockIPriceMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIPrice) EXPECT() *MockIPriceMockRecorder {
return m.recorder
}
// All mocks base method.
func (m *MockIPrice) All(ctx context.Context, limit, offset int) ([]storage.Price, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "All", ctx, limit, offset)
ret0, _ := ret[0].([]storage.Price)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// All indicates an expected call of All.
func (mr *MockIPriceMockRecorder) All(ctx, limit, offset any) *MockIPriceAllCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "All", reflect.TypeOf((*MockIPrice)(nil).All), ctx, limit, offset)
return &MockIPriceAllCall{Call: call}
}
// MockIPriceAllCall wrap *gomock.Call
type MockIPriceAllCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceAllCall) Return(arg0 []storage.Price, arg1 error) *MockIPriceAllCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceAllCall) Do(f func(context.Context, int, int) ([]storage.Price, error)) *MockIPriceAllCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceAllCall) DoAndReturn(f func(context.Context, int, int) ([]storage.Price, error)) *MockIPriceAllCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIPrice) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Price, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Price)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIPriceMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIPriceCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIPrice)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIPriceCursorListCall{Call: call}
}
// MockIPriceCursorListCall wrap *gomock.Call
type MockIPriceCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceCursorListCall) Return(arg0 []*storage.Price, arg1 error) *MockIPriceCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Price, error)) *MockIPriceCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Price, error)) *MockIPriceCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIPrice) GetByID(ctx context.Context, id uint64) (*storage.Price, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Price)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIPriceMockRecorder) GetByID(ctx, id any) *MockIPriceGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIPrice)(nil).GetByID), ctx, id)
return &MockIPriceGetByIDCall{Call: call}
}
// MockIPriceGetByIDCall wrap *gomock.Call
type MockIPriceGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceGetByIDCall) Return(arg0 *storage.Price, arg1 error) *MockIPriceGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceGetByIDCall) Do(f func(context.Context, uint64) (*storage.Price, error)) *MockIPriceGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Price, error)) *MockIPriceGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIPrice) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIPriceMockRecorder) IsNoRows(err any) *MockIPriceIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIPrice)(nil).IsNoRows), err)
return &MockIPriceIsNoRowsCall{Call: call}
}
// MockIPriceIsNoRowsCall wrap *gomock.Call
type MockIPriceIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceIsNoRowsCall) Return(arg0 bool) *MockIPriceIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceIsNoRowsCall) Do(f func(error) bool) *MockIPriceIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIPriceIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Last mocks base method.
func (m *MockIPrice) Last(ctx context.Context, currencyPair string) (storage.Price, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Last", ctx, currencyPair)
ret0, _ := ret[0].(storage.Price)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Last indicates an expected call of Last.
func (mr *MockIPriceMockRecorder) Last(ctx, currencyPair any) *MockIPriceLastCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Last", reflect.TypeOf((*MockIPrice)(nil).Last), ctx, currencyPair)
return &MockIPriceLastCall{Call: call}
}
// MockIPriceLastCall wrap *gomock.Call
type MockIPriceLastCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceLastCall) Return(arg0 storage.Price, arg1 error) *MockIPriceLastCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceLastCall) Do(f func(context.Context, string) (storage.Price, error)) *MockIPriceLastCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceLastCall) DoAndReturn(f func(context.Context, string) (storage.Price, error)) *MockIPriceLastCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIPrice) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIPriceMockRecorder) LastID(ctx any) *MockIPriceLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIPrice)(nil).LastID), ctx)
return &MockIPriceLastIDCall{Call: call}
}
// MockIPriceLastIDCall wrap *gomock.Call
type MockIPriceLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceLastIDCall) Return(arg0 uint64, arg1 error) *MockIPriceLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIPriceLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIPriceLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIPrice) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Price, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Price)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIPriceMockRecorder) List(ctx, limit, offset, order any) *MockIPriceListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIPrice)(nil).List), ctx, limit, offset, order)
return &MockIPriceListCall{Call: call}
}
// MockIPriceListCall wrap *gomock.Call
type MockIPriceListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceListCall) Return(arg0 []*storage.Price, arg1 error) *MockIPriceListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Price, error)) *MockIPriceListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Price, error)) *MockIPriceListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIPrice) Save(ctx context.Context, m *storage.Price) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIPriceMockRecorder) Save(ctx, m any) *MockIPriceSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIPrice)(nil).Save), ctx, m)
return &MockIPriceSaveCall{Call: call}
}
// MockIPriceSaveCall wrap *gomock.Call
type MockIPriceSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceSaveCall) Return(arg0 error) *MockIPriceSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceSaveCall) Do(f func(context.Context, *storage.Price) error) *MockIPriceSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceSaveCall) DoAndReturn(f func(context.Context, *storage.Price) error) *MockIPriceSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Series mocks base method.
func (m *MockIPrice) Series(ctx context.Context, currencyPair string, timeframe storage.Timeframe) ([]storage.Candle, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Series", ctx, currencyPair, timeframe)
ret0, _ := ret[0].([]storage.Candle)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Series indicates an expected call of Series.
func (mr *MockIPriceMockRecorder) Series(ctx, currencyPair, timeframe any) *MockIPriceSeriesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Series", reflect.TypeOf((*MockIPrice)(nil).Series), ctx, currencyPair, timeframe)
return &MockIPriceSeriesCall{Call: call}
}
// MockIPriceSeriesCall wrap *gomock.Call
type MockIPriceSeriesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceSeriesCall) Return(arg0 []storage.Candle, arg1 error) *MockIPriceSeriesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceSeriesCall) Do(f func(context.Context, string, storage.Timeframe) ([]storage.Candle, error)) *MockIPriceSeriesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceSeriesCall) DoAndReturn(f func(context.Context, string, storage.Timeframe) ([]storage.Candle, error)) *MockIPriceSeriesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIPrice) Update(ctx context.Context, m *storage.Price) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIPriceMockRecorder) Update(ctx, m any) *MockIPriceUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIPrice)(nil).Update), ctx, m)
return &MockIPriceUpdateCall{Call: call}
}
// MockIPriceUpdateCall wrap *gomock.Call
type MockIPriceUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIPriceUpdateCall) Return(arg0 error) *MockIPriceUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIPriceUpdateCall) Do(f func(context.Context, *storage.Price) error) *MockIPriceUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIPriceUpdateCall) DoAndReturn(f func(context.Context, *storage.Price) error) *MockIPriceUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: rollup.go
//
// Generated by this command:
//
// mockgen -source=rollup.go -destination=mock/rollup.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
types "github.com/celenium-io/astria-indexer/pkg/types"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIRollup is a mock of IRollup interface.
type MockIRollup struct {
ctrl *gomock.Controller
recorder *MockIRollupMockRecorder
}
// MockIRollupMockRecorder is the mock recorder for MockIRollup.
type MockIRollupMockRecorder struct {
mock *MockIRollup
}
// NewMockIRollup creates a new mock instance.
func NewMockIRollup(ctrl *gomock.Controller) *MockIRollup {
mock := &MockIRollup{ctrl: ctrl}
mock.recorder = &MockIRollupMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIRollup) EXPECT() *MockIRollupMockRecorder {
return m.recorder
}
// ActionsByHeight mocks base method.
func (m *MockIRollup) ActionsByHeight(ctx context.Context, height types.Level, limit, offset int) ([]storage.RollupAction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ActionsByHeight", ctx, height, limit, offset)
ret0, _ := ret[0].([]storage.RollupAction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ActionsByHeight indicates an expected call of ActionsByHeight.
func (mr *MockIRollupMockRecorder) ActionsByHeight(ctx, height, limit, offset any) *MockIRollupActionsByHeightCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ActionsByHeight", reflect.TypeOf((*MockIRollup)(nil).ActionsByHeight), ctx, height, limit, offset)
return &MockIRollupActionsByHeightCall{Call: call}
}
// MockIRollupActionsByHeightCall wrap *gomock.Call
type MockIRollupActionsByHeightCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupActionsByHeightCall) Return(arg0 []storage.RollupAction, arg1 error) *MockIRollupActionsByHeightCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupActionsByHeightCall) Do(f func(context.Context, types.Level, int, int) ([]storage.RollupAction, error)) *MockIRollupActionsByHeightCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupActionsByHeightCall) DoAndReturn(f func(context.Context, types.Level, int, int) ([]storage.RollupAction, error)) *MockIRollupActionsByHeightCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ActionsByTxId mocks base method.
func (m *MockIRollup) ActionsByTxId(ctx context.Context, txId uint64, limit, offset int) ([]storage.RollupAction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ActionsByTxId", ctx, txId, limit, offset)
ret0, _ := ret[0].([]storage.RollupAction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ActionsByTxId indicates an expected call of ActionsByTxId.
func (mr *MockIRollupMockRecorder) ActionsByTxId(ctx, txId, limit, offset any) *MockIRollupActionsByTxIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ActionsByTxId", reflect.TypeOf((*MockIRollup)(nil).ActionsByTxId), ctx, txId, limit, offset)
return &MockIRollupActionsByTxIdCall{Call: call}
}
// MockIRollupActionsByTxIdCall wrap *gomock.Call
type MockIRollupActionsByTxIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupActionsByTxIdCall) Return(arg0 []storage.RollupAction, arg1 error) *MockIRollupActionsByTxIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupActionsByTxIdCall) Do(f func(context.Context, uint64, int, int) ([]storage.RollupAction, error)) *MockIRollupActionsByTxIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupActionsByTxIdCall) DoAndReturn(f func(context.Context, uint64, int, int) ([]storage.RollupAction, error)) *MockIRollupActionsByTxIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Addresses mocks base method.
func (m *MockIRollup) Addresses(ctx context.Context, rollupId uint64, limit, offset int, sort storage0.SortOrder) ([]storage.RollupAddress, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Addresses", ctx, rollupId, limit, offset, sort)
ret0, _ := ret[0].([]storage.RollupAddress)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Addresses indicates an expected call of Addresses.
func (mr *MockIRollupMockRecorder) Addresses(ctx, rollupId, limit, offset, sort any) *MockIRollupAddressesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Addresses", reflect.TypeOf((*MockIRollup)(nil).Addresses), ctx, rollupId, limit, offset, sort)
return &MockIRollupAddressesCall{Call: call}
}
// MockIRollupAddressesCall wrap *gomock.Call
type MockIRollupAddressesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupAddressesCall) Return(arg0 []storage.RollupAddress, arg1 error) *MockIRollupAddressesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupAddressesCall) Do(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.RollupAddress, error)) *MockIRollupAddressesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupAddressesCall) DoAndReturn(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.RollupAddress, error)) *MockIRollupAddressesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByHash mocks base method.
func (m *MockIRollup) ByHash(ctx context.Context, hash []byte) (storage.Rollup, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByHash", ctx, hash)
ret0, _ := ret[0].(storage.Rollup)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByHash indicates an expected call of ByHash.
func (mr *MockIRollupMockRecorder) ByHash(ctx, hash any) *MockIRollupByHashCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByHash", reflect.TypeOf((*MockIRollup)(nil).ByHash), ctx, hash)
return &MockIRollupByHashCall{Call: call}
}
// MockIRollupByHashCall wrap *gomock.Call
type MockIRollupByHashCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupByHashCall) Return(arg0 storage.Rollup, arg1 error) *MockIRollupByHashCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupByHashCall) Do(f func(context.Context, []byte) (storage.Rollup, error)) *MockIRollupByHashCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupByHashCall) DoAndReturn(f func(context.Context, []byte) (storage.Rollup, error)) *MockIRollupByHashCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CountActionsByHeight mocks base method.
func (m *MockIRollup) CountActionsByHeight(ctx context.Context, height types.Level) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CountActionsByHeight", ctx, height)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CountActionsByHeight indicates an expected call of CountActionsByHeight.
func (mr *MockIRollupMockRecorder) CountActionsByHeight(ctx, height any) *MockIRollupCountActionsByHeightCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountActionsByHeight", reflect.TypeOf((*MockIRollup)(nil).CountActionsByHeight), ctx, height)
return &MockIRollupCountActionsByHeightCall{Call: call}
}
// MockIRollupCountActionsByHeightCall wrap *gomock.Call
type MockIRollupCountActionsByHeightCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupCountActionsByHeightCall) Return(arg0 int64, arg1 error) *MockIRollupCountActionsByHeightCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupCountActionsByHeightCall) Do(f func(context.Context, types.Level) (int64, error)) *MockIRollupCountActionsByHeightCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupCountActionsByHeightCall) DoAndReturn(f func(context.Context, types.Level) (int64, error)) *MockIRollupCountActionsByHeightCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CountActionsByTxId mocks base method.
func (m *MockIRollup) CountActionsByTxId(ctx context.Context, txId uint64) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CountActionsByTxId", ctx, txId)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CountActionsByTxId indicates an expected call of CountActionsByTxId.
func (mr *MockIRollupMockRecorder) CountActionsByTxId(ctx, txId any) *MockIRollupCountActionsByTxIdCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountActionsByTxId", reflect.TypeOf((*MockIRollup)(nil).CountActionsByTxId), ctx, txId)
return &MockIRollupCountActionsByTxIdCall{Call: call}
}
// MockIRollupCountActionsByTxIdCall wrap *gomock.Call
type MockIRollupCountActionsByTxIdCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupCountActionsByTxIdCall) Return(arg0 int64, arg1 error) *MockIRollupCountActionsByTxIdCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupCountActionsByTxIdCall) Do(f func(context.Context, uint64) (int64, error)) *MockIRollupCountActionsByTxIdCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupCountActionsByTxIdCall) DoAndReturn(f func(context.Context, uint64) (int64, error)) *MockIRollupCountActionsByTxIdCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIRollup) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Rollup, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Rollup)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIRollupMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIRollupCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIRollup)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIRollupCursorListCall{Call: call}
}
// MockIRollupCursorListCall wrap *gomock.Call
type MockIRollupCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupCursorListCall) Return(arg0 []*storage.Rollup, arg1 error) *MockIRollupCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Rollup, error)) *MockIRollupCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Rollup, error)) *MockIRollupCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIRollup) GetByID(ctx context.Context, id uint64) (*storage.Rollup, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Rollup)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIRollupMockRecorder) GetByID(ctx, id any) *MockIRollupGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIRollup)(nil).GetByID), ctx, id)
return &MockIRollupGetByIDCall{Call: call}
}
// MockIRollupGetByIDCall wrap *gomock.Call
type MockIRollupGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupGetByIDCall) Return(arg0 *storage.Rollup, arg1 error) *MockIRollupGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupGetByIDCall) Do(f func(context.Context, uint64) (*storage.Rollup, error)) *MockIRollupGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Rollup, error)) *MockIRollupGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIRollup) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIRollupMockRecorder) IsNoRows(err any) *MockIRollupIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIRollup)(nil).IsNoRows), err)
return &MockIRollupIsNoRowsCall{Call: call}
}
// MockIRollupIsNoRowsCall wrap *gomock.Call
type MockIRollupIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupIsNoRowsCall) Return(arg0 bool) *MockIRollupIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupIsNoRowsCall) Do(f func(error) bool) *MockIRollupIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIRollupIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIRollup) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIRollupMockRecorder) LastID(ctx any) *MockIRollupLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIRollup)(nil).LastID), ctx)
return &MockIRollupLastIDCall{Call: call}
}
// MockIRollupLastIDCall wrap *gomock.Call
type MockIRollupLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupLastIDCall) Return(arg0 uint64, arg1 error) *MockIRollupLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIRollupLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIRollupLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIRollup) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Rollup, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Rollup)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIRollupMockRecorder) List(ctx, limit, offset, order any) *MockIRollupListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIRollup)(nil).List), ctx, limit, offset, order)
return &MockIRollupListCall{Call: call}
}
// MockIRollupListCall wrap *gomock.Call
type MockIRollupListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupListCall) Return(arg0 []*storage.Rollup, arg1 error) *MockIRollupListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Rollup, error)) *MockIRollupListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Rollup, error)) *MockIRollupListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ListExt mocks base method.
func (m *MockIRollup) ListExt(ctx context.Context, fltrs storage.RollupListFilter) ([]storage.Rollup, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListExt", ctx, fltrs)
ret0, _ := ret[0].([]storage.Rollup)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListExt indicates an expected call of ListExt.
func (mr *MockIRollupMockRecorder) ListExt(ctx, fltrs any) *MockIRollupListExtCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListExt", reflect.TypeOf((*MockIRollup)(nil).ListExt), ctx, fltrs)
return &MockIRollupListExtCall{Call: call}
}
// MockIRollupListExtCall wrap *gomock.Call
type MockIRollupListExtCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupListExtCall) Return(arg0 []storage.Rollup, arg1 error) *MockIRollupListExtCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupListExtCall) Do(f func(context.Context, storage.RollupListFilter) ([]storage.Rollup, error)) *MockIRollupListExtCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupListExtCall) DoAndReturn(f func(context.Context, storage.RollupListFilter) ([]storage.Rollup, error)) *MockIRollupListExtCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ListRollupsByAddress mocks base method.
func (m *MockIRollup) ListRollupsByAddress(ctx context.Context, addressId uint64, limit, offset int, sort storage0.SortOrder) ([]storage.RollupAddress, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListRollupsByAddress", ctx, addressId, limit, offset, sort)
ret0, _ := ret[0].([]storage.RollupAddress)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListRollupsByAddress indicates an expected call of ListRollupsByAddress.
func (mr *MockIRollupMockRecorder) ListRollupsByAddress(ctx, addressId, limit, offset, sort any) *MockIRollupListRollupsByAddressCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListRollupsByAddress", reflect.TypeOf((*MockIRollup)(nil).ListRollupsByAddress), ctx, addressId, limit, offset, sort)
return &MockIRollupListRollupsByAddressCall{Call: call}
}
// MockIRollupListRollupsByAddressCall wrap *gomock.Call
type MockIRollupListRollupsByAddressCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupListRollupsByAddressCall) Return(arg0 []storage.RollupAddress, arg1 error) *MockIRollupListRollupsByAddressCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupListRollupsByAddressCall) Do(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.RollupAddress, error)) *MockIRollupListRollupsByAddressCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupListRollupsByAddressCall) DoAndReturn(f func(context.Context, uint64, int, int, storage0.SortOrder) ([]storage.RollupAddress, error)) *MockIRollupListRollupsByAddressCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIRollup) Save(ctx context.Context, m *storage.Rollup) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIRollupMockRecorder) Save(ctx, m any) *MockIRollupSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIRollup)(nil).Save), ctx, m)
return &MockIRollupSaveCall{Call: call}
}
// MockIRollupSaveCall wrap *gomock.Call
type MockIRollupSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupSaveCall) Return(arg0 error) *MockIRollupSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupSaveCall) Do(f func(context.Context, *storage.Rollup) error) *MockIRollupSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupSaveCall) DoAndReturn(f func(context.Context, *storage.Rollup) error) *MockIRollupSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIRollup) Update(ctx context.Context, m *storage.Rollup) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIRollupMockRecorder) Update(ctx, m any) *MockIRollupUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIRollup)(nil).Update), ctx, m)
return &MockIRollupUpdateCall{Call: call}
}
// MockIRollupUpdateCall wrap *gomock.Call
type MockIRollupUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIRollupUpdateCall) Return(arg0 error) *MockIRollupUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIRollupUpdateCall) Do(f func(context.Context, *storage.Rollup) error) *MockIRollupUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIRollupUpdateCall) DoAndReturn(f func(context.Context, *storage.Rollup) error) *MockIRollupUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: state.go
//
// Generated by this command:
//
// mockgen -source=state.go -destination=mock/state.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIState is a mock of IState interface.
type MockIState struct {
ctrl *gomock.Controller
recorder *MockIStateMockRecorder
}
// MockIStateMockRecorder is the mock recorder for MockIState.
type MockIStateMockRecorder struct {
mock *MockIState
}
// NewMockIState creates a new mock instance.
func NewMockIState(ctrl *gomock.Controller) *MockIState {
mock := &MockIState{ctrl: ctrl}
mock.recorder = &MockIStateMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIState) EXPECT() *MockIStateMockRecorder {
return m.recorder
}
// ByName mocks base method.
func (m *MockIState) ByName(ctx context.Context, name string) (storage.State, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByName", ctx, name)
ret0, _ := ret[0].(storage.State)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByName indicates an expected call of ByName.
func (mr *MockIStateMockRecorder) ByName(ctx, name any) *MockIStateByNameCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByName", reflect.TypeOf((*MockIState)(nil).ByName), ctx, name)
return &MockIStateByNameCall{Call: call}
}
// MockIStateByNameCall wrap *gomock.Call
type MockIStateByNameCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStateByNameCall) Return(arg0 storage.State, arg1 error) *MockIStateByNameCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStateByNameCall) Do(f func(context.Context, string) (storage.State, error)) *MockIStateByNameCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStateByNameCall) DoAndReturn(f func(context.Context, string) (storage.State, error)) *MockIStateByNameCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockIState) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.State, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.State)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIStateMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIStateCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIState)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIStateCursorListCall{Call: call}
}
// MockIStateCursorListCall wrap *gomock.Call
type MockIStateCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStateCursorListCall) Return(arg0 []*storage.State, arg1 error) *MockIStateCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStateCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.State, error)) *MockIStateCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStateCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.State, error)) *MockIStateCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIState) GetByID(ctx context.Context, id uint64) (*storage.State, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.State)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIStateMockRecorder) GetByID(ctx, id any) *MockIStateGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIState)(nil).GetByID), ctx, id)
return &MockIStateGetByIDCall{Call: call}
}
// MockIStateGetByIDCall wrap *gomock.Call
type MockIStateGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStateGetByIDCall) Return(arg0 *storage.State, arg1 error) *MockIStateGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStateGetByIDCall) Do(f func(context.Context, uint64) (*storage.State, error)) *MockIStateGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStateGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.State, error)) *MockIStateGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIState) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIStateMockRecorder) IsNoRows(err any) *MockIStateIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIState)(nil).IsNoRows), err)
return &MockIStateIsNoRowsCall{Call: call}
}
// MockIStateIsNoRowsCall wrap *gomock.Call
type MockIStateIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStateIsNoRowsCall) Return(arg0 bool) *MockIStateIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStateIsNoRowsCall) Do(f func(error) bool) *MockIStateIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStateIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIStateIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIState) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIStateMockRecorder) LastID(ctx any) *MockIStateLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIState)(nil).LastID), ctx)
return &MockIStateLastIDCall{Call: call}
}
// MockIStateLastIDCall wrap *gomock.Call
type MockIStateLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStateLastIDCall) Return(arg0 uint64, arg1 error) *MockIStateLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStateLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIStateLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStateLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIStateLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIState) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.State, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.State)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIStateMockRecorder) List(ctx, limit, offset, order any) *MockIStateListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIState)(nil).List), ctx, limit, offset, order)
return &MockIStateListCall{Call: call}
}
// MockIStateListCall wrap *gomock.Call
type MockIStateListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStateListCall) Return(arg0 []*storage.State, arg1 error) *MockIStateListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStateListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.State, error)) *MockIStateListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStateListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.State, error)) *MockIStateListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIState) Save(ctx context.Context, m *storage.State) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIStateMockRecorder) Save(ctx, m any) *MockIStateSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIState)(nil).Save), ctx, m)
return &MockIStateSaveCall{Call: call}
}
// MockIStateSaveCall wrap *gomock.Call
type MockIStateSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStateSaveCall) Return(arg0 error) *MockIStateSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStateSaveCall) Do(f func(context.Context, *storage.State) error) *MockIStateSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStateSaveCall) DoAndReturn(f func(context.Context, *storage.State) error) *MockIStateSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIState) Update(ctx context.Context, m *storage.State) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIStateMockRecorder) Update(ctx, m any) *MockIStateUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIState)(nil).Update), ctx, m)
return &MockIStateUpdateCall{Call: call}
}
// MockIStateUpdateCall wrap *gomock.Call
type MockIStateUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStateUpdateCall) Return(arg0 error) *MockIStateUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStateUpdateCall) Do(f func(context.Context, *storage.State) error) *MockIStateUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStateUpdateCall) DoAndReturn(f func(context.Context, *storage.State) error) *MockIStateUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: stats.go
//
// Generated by this command:
//
// mockgen -source=stats.go -destination=mock/stats.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIStats is a mock of IStats interface.
type MockIStats struct {
ctrl *gomock.Controller
recorder *MockIStatsMockRecorder
}
// MockIStatsMockRecorder is the mock recorder for MockIStats.
type MockIStatsMockRecorder struct {
mock *MockIStats
}
// NewMockIStats creates a new mock instance.
func NewMockIStats(ctrl *gomock.Controller) *MockIStats {
mock := &MockIStats{ctrl: ctrl}
mock.recorder = &MockIStatsMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIStats) EXPECT() *MockIStatsMockRecorder {
return m.recorder
}
// ActiveAddressesCount mocks base method.
func (m *MockIStats) ActiveAddressesCount(ctx context.Context) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ActiveAddressesCount", ctx)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ActiveAddressesCount indicates an expected call of ActiveAddressesCount.
func (mr *MockIStatsMockRecorder) ActiveAddressesCount(ctx any) *MockIStatsActiveAddressesCountCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ActiveAddressesCount", reflect.TypeOf((*MockIStats)(nil).ActiveAddressesCount), ctx)
return &MockIStatsActiveAddressesCountCall{Call: call}
}
// MockIStatsActiveAddressesCountCall wrap *gomock.Call
type MockIStatsActiveAddressesCountCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStatsActiveAddressesCountCall) Return(arg0 int64, arg1 error) *MockIStatsActiveAddressesCountCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStatsActiveAddressesCountCall) Do(f func(context.Context) (int64, error)) *MockIStatsActiveAddressesCountCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStatsActiveAddressesCountCall) DoAndReturn(f func(context.Context) (int64, error)) *MockIStatsActiveAddressesCountCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// FeeSummary mocks base method.
func (m *MockIStats) FeeSummary(ctx context.Context) ([]storage.FeeSummary, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FeeSummary", ctx)
ret0, _ := ret[0].([]storage.FeeSummary)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FeeSummary indicates an expected call of FeeSummary.
func (mr *MockIStatsMockRecorder) FeeSummary(ctx any) *MockIStatsFeeSummaryCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FeeSummary", reflect.TypeOf((*MockIStats)(nil).FeeSummary), ctx)
return &MockIStatsFeeSummaryCall{Call: call}
}
// MockIStatsFeeSummaryCall wrap *gomock.Call
type MockIStatsFeeSummaryCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStatsFeeSummaryCall) Return(arg0 []storage.FeeSummary, arg1 error) *MockIStatsFeeSummaryCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStatsFeeSummaryCall) Do(f func(context.Context) ([]storage.FeeSummary, error)) *MockIStatsFeeSummaryCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStatsFeeSummaryCall) DoAndReturn(f func(context.Context) ([]storage.FeeSummary, error)) *MockIStatsFeeSummaryCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// RollupSeries mocks base method.
func (m *MockIStats) RollupSeries(ctx context.Context, rollupId uint64, timeframe storage.Timeframe, name string, req storage.SeriesRequest) ([]storage.SeriesItem, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RollupSeries", ctx, rollupId, timeframe, name, req)
ret0, _ := ret[0].([]storage.SeriesItem)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// RollupSeries indicates an expected call of RollupSeries.
func (mr *MockIStatsMockRecorder) RollupSeries(ctx, rollupId, timeframe, name, req any) *MockIStatsRollupSeriesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollupSeries", reflect.TypeOf((*MockIStats)(nil).RollupSeries), ctx, rollupId, timeframe, name, req)
return &MockIStatsRollupSeriesCall{Call: call}
}
// MockIStatsRollupSeriesCall wrap *gomock.Call
type MockIStatsRollupSeriesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStatsRollupSeriesCall) Return(arg0 []storage.SeriesItem, arg1 error) *MockIStatsRollupSeriesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStatsRollupSeriesCall) Do(f func(context.Context, uint64, storage.Timeframe, string, storage.SeriesRequest) ([]storage.SeriesItem, error)) *MockIStatsRollupSeriesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStatsRollupSeriesCall) DoAndReturn(f func(context.Context, uint64, storage.Timeframe, string, storage.SeriesRequest) ([]storage.SeriesItem, error)) *MockIStatsRollupSeriesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Series mocks base method.
func (m *MockIStats) Series(ctx context.Context, timeframe storage.Timeframe, name string, req storage.SeriesRequest) ([]storage.SeriesItem, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Series", ctx, timeframe, name, req)
ret0, _ := ret[0].([]storage.SeriesItem)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Series indicates an expected call of Series.
func (mr *MockIStatsMockRecorder) Series(ctx, timeframe, name, req any) *MockIStatsSeriesCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Series", reflect.TypeOf((*MockIStats)(nil).Series), ctx, timeframe, name, req)
return &MockIStatsSeriesCall{Call: call}
}
// MockIStatsSeriesCall wrap *gomock.Call
type MockIStatsSeriesCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStatsSeriesCall) Return(arg0 []storage.SeriesItem, arg1 error) *MockIStatsSeriesCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStatsSeriesCall) Do(f func(context.Context, storage.Timeframe, string, storage.SeriesRequest) ([]storage.SeriesItem, error)) *MockIStatsSeriesCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStatsSeriesCall) DoAndReturn(f func(context.Context, storage.Timeframe, string, storage.SeriesRequest) ([]storage.SeriesItem, error)) *MockIStatsSeriesCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Summary mocks base method.
func (m *MockIStats) Summary(ctx context.Context) (storage.NetworkSummary, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Summary", ctx)
ret0, _ := ret[0].(storage.NetworkSummary)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Summary indicates an expected call of Summary.
func (mr *MockIStatsMockRecorder) Summary(ctx any) *MockIStatsSummaryCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Summary", reflect.TypeOf((*MockIStats)(nil).Summary), ctx)
return &MockIStatsSummaryCall{Call: call}
}
// MockIStatsSummaryCall wrap *gomock.Call
type MockIStatsSummaryCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStatsSummaryCall) Return(arg0 storage.NetworkSummary, arg1 error) *MockIStatsSummaryCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStatsSummaryCall) Do(f func(context.Context) (storage.NetworkSummary, error)) *MockIStatsSummaryCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStatsSummaryCall) DoAndReturn(f func(context.Context) (storage.NetworkSummary, error)) *MockIStatsSummaryCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SummaryTimeframe mocks base method.
func (m *MockIStats) SummaryTimeframe(ctx context.Context, timeframe storage.Timeframe) (storage.NetworkSummaryWithChange, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SummaryTimeframe", ctx, timeframe)
ret0, _ := ret[0].(storage.NetworkSummaryWithChange)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SummaryTimeframe indicates an expected call of SummaryTimeframe.
func (mr *MockIStatsMockRecorder) SummaryTimeframe(ctx, timeframe any) *MockIStatsSummaryTimeframeCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SummaryTimeframe", reflect.TypeOf((*MockIStats)(nil).SummaryTimeframe), ctx, timeframe)
return &MockIStatsSummaryTimeframeCall{Call: call}
}
// MockIStatsSummaryTimeframeCall wrap *gomock.Call
type MockIStatsSummaryTimeframeCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStatsSummaryTimeframeCall) Return(arg0 storage.NetworkSummaryWithChange, arg1 error) *MockIStatsSummaryTimeframeCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStatsSummaryTimeframeCall) Do(f func(context.Context, storage.Timeframe) (storage.NetworkSummaryWithChange, error)) *MockIStatsSummaryTimeframeCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStatsSummaryTimeframeCall) DoAndReturn(f func(context.Context, storage.Timeframe) (storage.NetworkSummaryWithChange, error)) *MockIStatsSummaryTimeframeCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// TokenTransferDistribution mocks base method.
func (m *MockIStats) TokenTransferDistribution(ctx context.Context, limit int) ([]storage.TokenTransferDistributionItem, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "TokenTransferDistribution", ctx, limit)
ret0, _ := ret[0].([]storage.TokenTransferDistributionItem)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// TokenTransferDistribution indicates an expected call of TokenTransferDistribution.
func (mr *MockIStatsMockRecorder) TokenTransferDistribution(ctx, limit any) *MockIStatsTokenTransferDistributionCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TokenTransferDistribution", reflect.TypeOf((*MockIStats)(nil).TokenTransferDistribution), ctx, limit)
return &MockIStatsTokenTransferDistributionCall{Call: call}
}
// MockIStatsTokenTransferDistributionCall wrap *gomock.Call
type MockIStatsTokenTransferDistributionCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIStatsTokenTransferDistributionCall) Return(arg0 []storage.TokenTransferDistributionItem, arg1 error) *MockIStatsTokenTransferDistributionCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIStatsTokenTransferDistributionCall) Do(f func(context.Context, int) ([]storage.TokenTransferDistributionItem, error)) *MockIStatsTokenTransferDistributionCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIStatsTokenTransferDistributionCall) DoAndReturn(f func(context.Context, int) ([]storage.TokenTransferDistributionItem, error)) *MockIStatsTokenTransferDistributionCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: transfer.go
//
// Generated by this command:
//
// mockgen -source=transfer.go -destination=mock/transfer.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockITransfer is a mock of ITransfer interface.
type MockITransfer struct {
ctrl *gomock.Controller
recorder *MockITransferMockRecorder
}
// MockITransferMockRecorder is the mock recorder for MockITransfer.
type MockITransferMockRecorder struct {
mock *MockITransfer
}
// NewMockITransfer creates a new mock instance.
func NewMockITransfer(ctrl *gomock.Controller) *MockITransfer {
mock := &MockITransfer{ctrl: ctrl}
mock.recorder = &MockITransferMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockITransfer) EXPECT() *MockITransferMockRecorder {
return m.recorder
}
// CursorList mocks base method.
func (m *MockITransfer) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Transfer, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Transfer)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockITransferMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockITransferCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockITransfer)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockITransferCursorListCall{Call: call}
}
// MockITransferCursorListCall wrap *gomock.Call
type MockITransferCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITransferCursorListCall) Return(arg0 []*storage.Transfer, arg1 error) *MockITransferCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITransferCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Transfer, error)) *MockITransferCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITransferCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Transfer, error)) *MockITransferCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockITransfer) GetByID(ctx context.Context, id uint64) (*storage.Transfer, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Transfer)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockITransferMockRecorder) GetByID(ctx, id any) *MockITransferGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockITransfer)(nil).GetByID), ctx, id)
return &MockITransferGetByIDCall{Call: call}
}
// MockITransferGetByIDCall wrap *gomock.Call
type MockITransferGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITransferGetByIDCall) Return(arg0 *storage.Transfer, arg1 error) *MockITransferGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITransferGetByIDCall) Do(f func(context.Context, uint64) (*storage.Transfer, error)) *MockITransferGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITransferGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Transfer, error)) *MockITransferGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockITransfer) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockITransferMockRecorder) IsNoRows(err any) *MockITransferIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockITransfer)(nil).IsNoRows), err)
return &MockITransferIsNoRowsCall{Call: call}
}
// MockITransferIsNoRowsCall wrap *gomock.Call
type MockITransferIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITransferIsNoRowsCall) Return(arg0 bool) *MockITransferIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITransferIsNoRowsCall) Do(f func(error) bool) *MockITransferIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITransferIsNoRowsCall) DoAndReturn(f func(error) bool) *MockITransferIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockITransfer) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockITransferMockRecorder) LastID(ctx any) *MockITransferLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockITransfer)(nil).LastID), ctx)
return &MockITransferLastIDCall{Call: call}
}
// MockITransferLastIDCall wrap *gomock.Call
type MockITransferLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITransferLastIDCall) Return(arg0 uint64, arg1 error) *MockITransferLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITransferLastIDCall) Do(f func(context.Context) (uint64, error)) *MockITransferLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITransferLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockITransferLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockITransfer) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Transfer, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Transfer)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockITransferMockRecorder) List(ctx, limit, offset, order any) *MockITransferListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockITransfer)(nil).List), ctx, limit, offset, order)
return &MockITransferListCall{Call: call}
}
// MockITransferListCall wrap *gomock.Call
type MockITransferListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITransferListCall) Return(arg0 []*storage.Transfer, arg1 error) *MockITransferListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITransferListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Transfer, error)) *MockITransferListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITransferListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Transfer, error)) *MockITransferListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockITransfer) Save(ctx context.Context, m *storage.Transfer) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockITransferMockRecorder) Save(ctx, m any) *MockITransferSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockITransfer)(nil).Save), ctx, m)
return &MockITransferSaveCall{Call: call}
}
// MockITransferSaveCall wrap *gomock.Call
type MockITransferSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITransferSaveCall) Return(arg0 error) *MockITransferSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITransferSaveCall) Do(f func(context.Context, *storage.Transfer) error) *MockITransferSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITransferSaveCall) DoAndReturn(f func(context.Context, *storage.Transfer) error) *MockITransferSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockITransfer) Update(ctx context.Context, m *storage.Transfer) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockITransferMockRecorder) Update(ctx, m any) *MockITransferUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockITransfer)(nil).Update), ctx, m)
return &MockITransferUpdateCall{Call: call}
}
// MockITransferUpdateCall wrap *gomock.Call
type MockITransferUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITransferUpdateCall) Return(arg0 error) *MockITransferUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITransferUpdateCall) Do(f func(context.Context, *storage.Transfer) error) *MockITransferUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITransferUpdateCall) DoAndReturn(f func(context.Context, *storage.Transfer) error) *MockITransferUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: tx.go
//
// Generated by this command:
//
// mockgen -source=tx.go -destination=mock/tx.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
types "github.com/celenium-io/astria-indexer/pkg/types"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockITx is a mock of ITx interface.
type MockITx struct {
ctrl *gomock.Controller
recorder *MockITxMockRecorder
}
// MockITxMockRecorder is the mock recorder for MockITx.
type MockITxMockRecorder struct {
mock *MockITx
}
// NewMockITx creates a new mock instance.
func NewMockITx(ctrl *gomock.Controller) *MockITx {
mock := &MockITx{ctrl: ctrl}
mock.recorder = &MockITxMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockITx) EXPECT() *MockITxMockRecorder {
return m.recorder
}
// ByAddress mocks base method.
func (m *MockITx) ByAddress(ctx context.Context, addressId uint64, fltrs storage.TxFilter) ([]storage.Tx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByAddress", ctx, addressId, fltrs)
ret0, _ := ret[0].([]storage.Tx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByAddress indicates an expected call of ByAddress.
func (mr *MockITxMockRecorder) ByAddress(ctx, addressId, fltrs any) *MockITxByAddressCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByAddress", reflect.TypeOf((*MockITx)(nil).ByAddress), ctx, addressId, fltrs)
return &MockITxByAddressCall{Call: call}
}
// MockITxByAddressCall wrap *gomock.Call
type MockITxByAddressCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxByAddressCall) Return(arg0 []storage.Tx, arg1 error) *MockITxByAddressCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxByAddressCall) Do(f func(context.Context, uint64, storage.TxFilter) ([]storage.Tx, error)) *MockITxByAddressCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxByAddressCall) DoAndReturn(f func(context.Context, uint64, storage.TxFilter) ([]storage.Tx, error)) *MockITxByAddressCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByHash mocks base method.
func (m *MockITx) ByHash(ctx context.Context, hash []byte) (storage.Tx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByHash", ctx, hash)
ret0, _ := ret[0].(storage.Tx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByHash indicates an expected call of ByHash.
func (mr *MockITxMockRecorder) ByHash(ctx, hash any) *MockITxByHashCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByHash", reflect.TypeOf((*MockITx)(nil).ByHash), ctx, hash)
return &MockITxByHashCall{Call: call}
}
// MockITxByHashCall wrap *gomock.Call
type MockITxByHashCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxByHashCall) Return(arg0 storage.Tx, arg1 error) *MockITxByHashCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxByHashCall) Do(f func(context.Context, []byte) (storage.Tx, error)) *MockITxByHashCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxByHashCall) DoAndReturn(f func(context.Context, []byte) (storage.Tx, error)) *MockITxByHashCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ByHeight mocks base method.
func (m *MockITx) ByHeight(ctx context.Context, height types.Level, limit, offset int) ([]storage.Tx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ByHeight", ctx, height, limit, offset)
ret0, _ := ret[0].([]storage.Tx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ByHeight indicates an expected call of ByHeight.
func (mr *MockITxMockRecorder) ByHeight(ctx, height, limit, offset any) *MockITxByHeightCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ByHeight", reflect.TypeOf((*MockITx)(nil).ByHeight), ctx, height, limit, offset)
return &MockITxByHeightCall{Call: call}
}
// MockITxByHeightCall wrap *gomock.Call
type MockITxByHeightCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxByHeightCall) Return(arg0 []storage.Tx, arg1 error) *MockITxByHeightCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxByHeightCall) Do(f func(context.Context, types.Level, int, int) ([]storage.Tx, error)) *MockITxByHeightCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxByHeightCall) DoAndReturn(f func(context.Context, types.Level, int, int) ([]storage.Tx, error)) *MockITxByHeightCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CursorList mocks base method.
func (m *MockITx) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Tx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Tx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockITxMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockITxCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockITx)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockITxCursorListCall{Call: call}
}
// MockITxCursorListCall wrap *gomock.Call
type MockITxCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxCursorListCall) Return(arg0 []*storage.Tx, arg1 error) *MockITxCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Tx, error)) *MockITxCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Tx, error)) *MockITxCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Filter mocks base method.
func (m *MockITx) Filter(ctx context.Context, fltrs storage.TxFilter) ([]storage.Tx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Filter", ctx, fltrs)
ret0, _ := ret[0].([]storage.Tx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Filter indicates an expected call of Filter.
func (mr *MockITxMockRecorder) Filter(ctx, fltrs any) *MockITxFilterCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Filter", reflect.TypeOf((*MockITx)(nil).Filter), ctx, fltrs)
return &MockITxFilterCall{Call: call}
}
// MockITxFilterCall wrap *gomock.Call
type MockITxFilterCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxFilterCall) Return(arg0 []storage.Tx, arg1 error) *MockITxFilterCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxFilterCall) Do(f func(context.Context, storage.TxFilter) ([]storage.Tx, error)) *MockITxFilterCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxFilterCall) DoAndReturn(f func(context.Context, storage.TxFilter) ([]storage.Tx, error)) *MockITxFilterCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockITx) GetByID(ctx context.Context, id uint64) (*storage.Tx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Tx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockITxMockRecorder) GetByID(ctx, id any) *MockITxGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockITx)(nil).GetByID), ctx, id)
return &MockITxGetByIDCall{Call: call}
}
// MockITxGetByIDCall wrap *gomock.Call
type MockITxGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxGetByIDCall) Return(arg0 *storage.Tx, arg1 error) *MockITxGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxGetByIDCall) Do(f func(context.Context, uint64) (*storage.Tx, error)) *MockITxGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Tx, error)) *MockITxGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockITx) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockITxMockRecorder) IsNoRows(err any) *MockITxIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockITx)(nil).IsNoRows), err)
return &MockITxIsNoRowsCall{Call: call}
}
// MockITxIsNoRowsCall wrap *gomock.Call
type MockITxIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxIsNoRowsCall) Return(arg0 bool) *MockITxIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxIsNoRowsCall) Do(f func(error) bool) *MockITxIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxIsNoRowsCall) DoAndReturn(f func(error) bool) *MockITxIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockITx) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockITxMockRecorder) LastID(ctx any) *MockITxLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockITx)(nil).LastID), ctx)
return &MockITxLastIDCall{Call: call}
}
// MockITxLastIDCall wrap *gomock.Call
type MockITxLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxLastIDCall) Return(arg0 uint64, arg1 error) *MockITxLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxLastIDCall) Do(f func(context.Context) (uint64, error)) *MockITxLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockITxLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockITx) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Tx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Tx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockITxMockRecorder) List(ctx, limit, offset, order any) *MockITxListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockITx)(nil).List), ctx, limit, offset, order)
return &MockITxListCall{Call: call}
}
// MockITxListCall wrap *gomock.Call
type MockITxListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxListCall) Return(arg0 []*storage.Tx, arg1 error) *MockITxListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Tx, error)) *MockITxListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Tx, error)) *MockITxListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockITx) Save(ctx context.Context, m *storage.Tx) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockITxMockRecorder) Save(ctx, m any) *MockITxSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockITx)(nil).Save), ctx, m)
return &MockITxSaveCall{Call: call}
}
// MockITxSaveCall wrap *gomock.Call
type MockITxSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxSaveCall) Return(arg0 error) *MockITxSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxSaveCall) Do(f func(context.Context, *storage.Tx) error) *MockITxSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxSaveCall) DoAndReturn(f func(context.Context, *storage.Tx) error) *MockITxSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockITx) Update(ctx context.Context, m *storage.Tx) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockITxMockRecorder) Update(ctx, m any) *MockITxUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockITx)(nil).Update), ctx, m)
return &MockITxUpdateCall{Call: call}
}
// MockITxUpdateCall wrap *gomock.Call
type MockITxUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockITxUpdateCall) Return(arg0 error) *MockITxUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockITxUpdateCall) Do(f func(context.Context, *storage.Tx) error) *MockITxUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockITxUpdateCall) DoAndReturn(f func(context.Context, *storage.Tx) error) *MockITxUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Code generated by MockGen. DO NOT EDIT.
// Source: validator.go
//
// Generated by this command:
//
// mockgen -source=validator.go -destination=mock/validator.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
storage "github.com/celenium-io/astria-indexer/internal/storage"
storage0 "github.com/dipdup-net/indexer-sdk/pkg/storage"
gomock "go.uber.org/mock/gomock"
)
// MockIValidator is a mock of IValidator interface.
type MockIValidator struct {
ctrl *gomock.Controller
recorder *MockIValidatorMockRecorder
}
// MockIValidatorMockRecorder is the mock recorder for MockIValidator.
type MockIValidatorMockRecorder struct {
mock *MockIValidator
}
// NewMockIValidator creates a new mock instance.
func NewMockIValidator(ctrl *gomock.Controller) *MockIValidator {
mock := &MockIValidator{ctrl: ctrl}
mock.recorder = &MockIValidatorMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIValidator) EXPECT() *MockIValidatorMockRecorder {
return m.recorder
}
// CursorList mocks base method.
func (m *MockIValidator) CursorList(ctx context.Context, id, limit uint64, order storage0.SortOrder, cmp storage0.Comparator) ([]*storage.Validator, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CursorList", ctx, id, limit, order, cmp)
ret0, _ := ret[0].([]*storage.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CursorList indicates an expected call of CursorList.
func (mr *MockIValidatorMockRecorder) CursorList(ctx, id, limit, order, cmp any) *MockIValidatorCursorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CursorList", reflect.TypeOf((*MockIValidator)(nil).CursorList), ctx, id, limit, order, cmp)
return &MockIValidatorCursorListCall{Call: call}
}
// MockIValidatorCursorListCall wrap *gomock.Call
type MockIValidatorCursorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIValidatorCursorListCall) Return(arg0 []*storage.Validator, arg1 error) *MockIValidatorCursorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIValidatorCursorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Validator, error)) *MockIValidatorCursorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIValidatorCursorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder, storage0.Comparator) ([]*storage.Validator, error)) *MockIValidatorCursorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetByID mocks base method.
func (m *MockIValidator) GetByID(ctx context.Context, id uint64) (*storage.Validator, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByID", ctx, id)
ret0, _ := ret[0].(*storage.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByID indicates an expected call of GetByID.
func (mr *MockIValidatorMockRecorder) GetByID(ctx, id any) *MockIValidatorGetByIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockIValidator)(nil).GetByID), ctx, id)
return &MockIValidatorGetByIDCall{Call: call}
}
// MockIValidatorGetByIDCall wrap *gomock.Call
type MockIValidatorGetByIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIValidatorGetByIDCall) Return(arg0 *storage.Validator, arg1 error) *MockIValidatorGetByIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIValidatorGetByIDCall) Do(f func(context.Context, uint64) (*storage.Validator, error)) *MockIValidatorGetByIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIValidatorGetByIDCall) DoAndReturn(f func(context.Context, uint64) (*storage.Validator, error)) *MockIValidatorGetByIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// IsNoRows mocks base method.
func (m *MockIValidator) IsNoRows(err error) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNoRows", err)
ret0, _ := ret[0].(bool)
return ret0
}
// IsNoRows indicates an expected call of IsNoRows.
func (mr *MockIValidatorMockRecorder) IsNoRows(err any) *MockIValidatorIsNoRowsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNoRows", reflect.TypeOf((*MockIValidator)(nil).IsNoRows), err)
return &MockIValidatorIsNoRowsCall{Call: call}
}
// MockIValidatorIsNoRowsCall wrap *gomock.Call
type MockIValidatorIsNoRowsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIValidatorIsNoRowsCall) Return(arg0 bool) *MockIValidatorIsNoRowsCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIValidatorIsNoRowsCall) Do(f func(error) bool) *MockIValidatorIsNoRowsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIValidatorIsNoRowsCall) DoAndReturn(f func(error) bool) *MockIValidatorIsNoRowsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// LastID mocks base method.
func (m *MockIValidator) LastID(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LastID", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LastID indicates an expected call of LastID.
func (mr *MockIValidatorMockRecorder) LastID(ctx any) *MockIValidatorLastIDCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastID", reflect.TypeOf((*MockIValidator)(nil).LastID), ctx)
return &MockIValidatorLastIDCall{Call: call}
}
// MockIValidatorLastIDCall wrap *gomock.Call
type MockIValidatorLastIDCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIValidatorLastIDCall) Return(arg0 uint64, arg1 error) *MockIValidatorLastIDCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIValidatorLastIDCall) Do(f func(context.Context) (uint64, error)) *MockIValidatorLastIDCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIValidatorLastIDCall) DoAndReturn(f func(context.Context) (uint64, error)) *MockIValidatorLastIDCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// List mocks base method.
func (m *MockIValidator) List(ctx context.Context, limit, offset uint64, order storage0.SortOrder) ([]*storage.Validator, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", ctx, limit, offset, order)
ret0, _ := ret[0].([]*storage.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockIValidatorMockRecorder) List(ctx, limit, offset, order any) *MockIValidatorListCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIValidator)(nil).List), ctx, limit, offset, order)
return &MockIValidatorListCall{Call: call}
}
// MockIValidatorListCall wrap *gomock.Call
type MockIValidatorListCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIValidatorListCall) Return(arg0 []*storage.Validator, arg1 error) *MockIValidatorListCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIValidatorListCall) Do(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Validator, error)) *MockIValidatorListCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIValidatorListCall) DoAndReturn(f func(context.Context, uint64, uint64, storage0.SortOrder) ([]*storage.Validator, error)) *MockIValidatorListCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// ListByPower mocks base method.
func (m *MockIValidator) ListByPower(ctx context.Context, limit, offset int, order storage0.SortOrder) ([]storage.Validator, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListByPower", ctx, limit, offset, order)
ret0, _ := ret[0].([]storage.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListByPower indicates an expected call of ListByPower.
func (mr *MockIValidatorMockRecorder) ListByPower(ctx, limit, offset, order any) *MockIValidatorListByPowerCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListByPower", reflect.TypeOf((*MockIValidator)(nil).ListByPower), ctx, limit, offset, order)
return &MockIValidatorListByPowerCall{Call: call}
}
// MockIValidatorListByPowerCall wrap *gomock.Call
type MockIValidatorListByPowerCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIValidatorListByPowerCall) Return(arg0 []storage.Validator, arg1 error) *MockIValidatorListByPowerCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIValidatorListByPowerCall) Do(f func(context.Context, int, int, storage0.SortOrder) ([]storage.Validator, error)) *MockIValidatorListByPowerCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIValidatorListByPowerCall) DoAndReturn(f func(context.Context, int, int, storage0.SortOrder) ([]storage.Validator, error)) *MockIValidatorListByPowerCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Save mocks base method.
func (m_2 *MockIValidator) Save(ctx context.Context, m *storage.Validator) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Save", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Save indicates an expected call of Save.
func (mr *MockIValidatorMockRecorder) Save(ctx, m any) *MockIValidatorSaveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIValidator)(nil).Save), ctx, m)
return &MockIValidatorSaveCall{Call: call}
}
// MockIValidatorSaveCall wrap *gomock.Call
type MockIValidatorSaveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIValidatorSaveCall) Return(arg0 error) *MockIValidatorSaveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIValidatorSaveCall) Do(f func(context.Context, *storage.Validator) error) *MockIValidatorSaveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIValidatorSaveCall) DoAndReturn(f func(context.Context, *storage.Validator) error) *MockIValidatorSaveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Update mocks base method.
func (m_2 *MockIValidator) Update(ctx context.Context, m *storage.Validator) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "Update", ctx, m)
ret0, _ := ret[0].(error)
return ret0
}
// Update indicates an expected call of Update.
func (mr *MockIValidatorMockRecorder) Update(ctx, m any) *MockIValidatorUpdateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockIValidator)(nil).Update), ctx, m)
return &MockIValidatorUpdateCall{Call: call}
}
// MockIValidatorUpdateCall wrap *gomock.Call
type MockIValidatorUpdateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockIValidatorUpdateCall) Return(arg0 error) *MockIValidatorUpdateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockIValidatorUpdateCall) Do(f func(context.Context, *storage.Validator) error) *MockIValidatorUpdateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockIValidatorUpdateCall) DoAndReturn(f func(context.Context, *storage.Validator) error) *MockIValidatorUpdateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/uptrace/bun"
)
// Action -
type Action struct {
*postgres.Table[*storage.Action]
}
// NewAction -
func NewAction(db *postgres.Storage) *Action {
return &Action{
Table: postgres.NewTable[*storage.Action](db.Connection()),
}
}
func (a *Action) ByBlock(ctx context.Context, height types.Level, limit, offset int) (actions []storage.ActionWithTx, err error) {
query := a.DB().NewSelect().
Model((*storage.Action)(nil)).
Where("height = ?", height)
query = limitScope(query, limit)
query = offsetScope(query, offset)
err = a.DB().NewSelect().
TableExpr("(?) as action", query).
ColumnExpr("action.*").
ColumnExpr("fee.asset as fee__asset, fee.amount as fee__amount").
ColumnExpr("tx.hash as tx__hash").
Join("left join tx on tx.id = action.tx_id").
Join("left join fee on fee.action_id = action.id").
Scan(ctx, &actions)
return
}
func (a *Action) ByTxId(ctx context.Context, txId uint64, limit, offset int) (actions []storage.Action, err error) {
query := a.DB().NewSelect().
Model((*storage.Action)(nil)).
Where("tx_id = ?", txId)
query = limitScope(query, limit)
query = offsetScope(query, offset)
err = a.DB().NewSelect().
TableExpr("(?) as action", query).
ColumnExpr("fee.asset as fee__asset, fee.amount as fee__amount").
ColumnExpr("action.*").
Join("left join fee on fee.action_id = action.id").
Scan(ctx, &actions)
return
}
func (a *Action) ByAddress(ctx context.Context, addressId uint64, filters storage.AddressActionsFilter) (actions []storage.AddressAction, err error) {
subQuery := a.DB().NewSelect().
Model((*storage.AddressAction)(nil)).
Where("address_id = ?", addressId)
if filters.ActionTypes.Bits > 0 {
subQuery = subQuery.Where("action_type IN (?)", bun.In(filters.ActionTypes.Strings()))
}
subQuery = sortScope(subQuery, "action_id", filters.Sort)
subQuery = limitScope(subQuery, filters.Limit)
subQuery = offsetScope(subQuery, filters.Offset)
query := a.DB().NewSelect().
TableExpr("(?) as address_action", subQuery).
ColumnExpr("address_action.*").
ColumnExpr("action.id as action__id, action.height as action__height, action.time as action__time, action.position as action__position, action.type as action__type, action.tx_id as action__tx_id, action.data as action__data").
ColumnExpr("fee.asset as action__fee__asset, fee.amount as action__fee__amount").
ColumnExpr("tx.hash as tx__hash").
Join("left join tx on tx.id = address_action.tx_id").
Join("left join action on action.id = address_action.action_id").
Join("left join fee on fee.action_id = address_action.action_id")
query = sortScope(query, "action_id", filters.Sort)
err = query.Scan(ctx, &actions)
return
}
func (a *Action) ByRollup(ctx context.Context, rollupId uint64, limit, offset int, sort sdk.SortOrder) (actions []storage.RollupAction, err error) {
subQuery := a.DB().NewSelect().
Model((*storage.RollupAction)(nil)).
Where("rollup_id = ?", rollupId)
subQuery = sortScope(subQuery, "action_id", sort)
subQuery = limitScope(subQuery, limit)
subQuery = offsetScope(subQuery, offset)
query := a.DB().NewSelect().
TableExpr("(?) as rollup_action", subQuery).
ColumnExpr("rollup_action.*").
ColumnExpr("fee.asset as action__fee__asset, fee.amount as action__fee__amount").
ColumnExpr("action.id as action__id, action.height as action__height, action.time as action__time, action.position as action__position, action.type as action__type, action.tx_id as action__tx_id, action.data as action__data").
ColumnExpr("tx.hash as tx__hash").
Join("left join tx on tx.id = rollup_action.tx_id").
Join("left join action on action.id = rollup_action.action_id").
Join("left join fee on fee.action_id = rollup_action.action_id")
query = sortScope(query, "action_id", sort)
err = query.Scan(ctx, &actions)
return
}
func (a *Action) ByRollupAndBridge(ctx context.Context, rollupId uint64, fltrs storage.RollupAndBridgeActionsFilter) (actions []storage.ActionWithTx, err error) {
rollupActions := a.DB().NewSelect().
Model((*storage.RollupAction)(nil)).
Column("action_id", "time", "tx_id").
Where("rollup_id = ?", rollupId)
rollupActions = sortScope(rollupActions, "time", fltrs.Sort)
bridges := a.DB().NewSelect().
Model((*storage.Bridge)(nil)).
Column("address_id").
Where("rollup_id = ?", rollupId)
addressActions := a.DB().NewSelect().
Model((*storage.AddressAction)(nil)).
Column("action_id", "time", "tx_id").
Where("address_id IN (?)", bridges)
addressActions = sortScope(addressActions, "time", fltrs.Sort)
if !fltrs.From.IsZero() {
rollupActions = rollupActions.Where("time >= ?", fltrs.From)
addressActions = addressActions.Where("time >= ?", fltrs.From)
}
if !fltrs.To.IsZero() {
rollupActions = rollupActions.Where("time < ?", fltrs.To)
addressActions = addressActions.Where("time < ?", fltrs.To)
}
if !fltrs.ActionTypes.Empty() {
rollupActions = rollupActions.Where("action_type IN (?)", bun.In(fltrs.ActionTypes.Strings()))
addressActions = addressActions.Where("action_type IN (?)", bun.In(fltrs.ActionTypes.Strings()))
}
var subQuery *bun.SelectQuery
switch {
case fltrs.BridgeActions && fltrs.RollupActions:
subQuery = a.DB().NewSelect().TableExpr("(?) as rollup_action", rollupActions.Union(addressActions))
subQuery = sortScope(subQuery, "time", fltrs.Sort)
case !fltrs.BridgeActions && fltrs.RollupActions:
subQuery = rollupActions
case fltrs.BridgeActions && !fltrs.RollupActions:
subQuery = addressActions
case !fltrs.BridgeActions && !fltrs.RollupActions:
return
}
subQuery = limitScope(subQuery, fltrs.Limit)
subQuery = offsetScope(subQuery, fltrs.Offset)
query := a.DB().NewSelect().
With("rollup_action", subQuery).
Table("rollup_action").
ColumnExpr("fee.asset as fee__asset, fee.amount as fee__amount").
ColumnExpr("action.*").
ColumnExpr("tx.hash as tx__hash").
Join("left join tx on tx.id = rollup_action.tx_id").
Join("left join action on action.id = rollup_action.action_id").
Join("left join fee on fee.action_id = rollup_action.action_id")
query = sortScope(query, "rollup_action.time", fltrs.Sort)
err = query.Scan(ctx, &actions)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/uptrace/bun"
)
// Address -
type Address struct {
*postgres.Table[*storage.Address]
}
// NewAddress -
func NewAddress(db *postgres.Storage) *Address {
return &Address{
Table: postgres.NewTable[*storage.Address](db.Connection()),
}
}
// ByHash -
func (a *Address) ByHash(ctx context.Context, hash string) (address storage.Address, err error) {
err = a.DB().NewSelect().
Model(&address).
Where("hash = ?", hash).
Relation("Balance").
Scan(ctx)
return
}
func (a *Address) ListWithBalance(ctx context.Context, fltrs storage.AddressListFilter) (address []storage.Address, err error) {
query := a.DB().NewSelect().
Model(&address).
Offset(fltrs.Offset)
if fltrs.Asset != "" {
query = query.Relation("Balance", func(sq *bun.SelectQuery) *bun.SelectQuery {
return sq.Where("currency = ?", fltrs.Asset)
})
} else {
query = query.Relation("Balance", func(sq *bun.SelectQuery) *bun.SelectQuery {
return sq.Where("currency = 'nria'")
})
}
query = addressListFilter(query, fltrs)
err = query.Scan(ctx)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"fmt"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/pkg/errors"
"github.com/uptrace/bun"
)
// App -
type App struct {
*postgres.Table[*storage.App]
}
// NewApp -
func NewApp(db *postgres.Storage) *App {
return &App{
Table: postgres.NewTable[*storage.App](db.Connection()),
}
}
func (app *App) Leaderboard(ctx context.Context, fltrs storage.LeaderboardFilters) (rollups []storage.AppWithStats, err error) {
switch fltrs.SortField {
case columnTime:
fltrs.SortField = "last_time"
case columnSize, columnActionsCount:
case "":
fltrs.SortField = columnSize
default:
return nil, errors.Errorf("unknown sort field: %s", fltrs.SortField)
}
query := app.DB().NewSelect().
Table(storage.ViewLeaderboard).
Offset(fltrs.Offset)
if len(fltrs.Category) > 0 {
query = query.Where("category IN (?)", bun.In(fltrs.Category))
}
query = sortScope(query, fmt.Sprintf("%s.%s", storage.ViewLeaderboard, fltrs.SortField), fltrs.Sort)
query = limitScope(query, fltrs.Limit)
query = query.
ColumnExpr("leaderboard.*").
ColumnExpr("address.hash as bridge__hash").
ColumnExpr("rollup.astria_id as rollup__astria_id").
Join("left join address on native_bridge_id = address.id").
Join("left join rollup on rollup.id = rollup_id")
err = query.Scan(ctx, &rollups)
return
}
func (app *App) BySlug(ctx context.Context, slug string) (result storage.AppWithStats, err error) {
err = app.DB().NewSelect().
Table(storage.ViewLeaderboard).
ColumnExpr("leaderboard.*").
ColumnExpr("address.hash as bridge__hash").
ColumnExpr("rollup.astria_id as rollup__astria_id").
Join("left join address on native_bridge_id = address.id").
Join("left join rollup on rollup.id = rollup_id").
Where("slug = ?", slug).
Limit(1).
Scan(ctx, &result)
return
}
func (app *App) ByRollupId(ctx context.Context, rollupId uint64) (result storage.AppWithStats, err error) {
err = app.DB().NewSelect().
Table(storage.ViewLeaderboard).
ColumnExpr("leaderboard.*").
ColumnExpr("address.hash as bridge__hash").
Where("rollup_id = ?", rollupId).
Join("left join address on native_bridge_id = address.id").
Limit(1).
Scan(ctx, &result)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
type Asset struct {
db *postgres.Storage
}
// NewAsset -
func NewAsset(db *postgres.Storage) *Asset {
return &Asset{
db: db,
}
}
var validSortFieldsForAssetList = map[string]struct{}{
"fee": {},
"transferred": {},
"transfer_count": {},
"fee_count": {},
"supply": {},
}
func (a *Asset) List(ctx context.Context, limit int, offset int, sortBy string, order sdk.SortOrder) (assets []storage.Asset, err error) {
transferredQuery := a.db.Connection().DB().NewSelect().
Model((*storage.Transfer)(nil)).
ColumnExpr("asset, count(*) as c, sum(amount) as amount").
Group("asset")
feesQuery := a.db.Connection().DB().NewSelect().
Model((*storage.Fee)(nil)).
ColumnExpr("asset, count(*) as c, sum(amount) as amount").
Group("asset")
supplyQuery := a.db.Connection().DB().NewSelect().
Model((*storage.Balance)(nil)).
ColumnExpr("currency, sum(total) as amount").
Group("currency")
query := a.db.Connection().DB().NewSelect().
With("fees", feesQuery).
With("transferred", transferredQuery).
With("supply", supplyQuery).
Table("supply").
ColumnExpr("(case when fees.asset is not NULL then fees.asset when supply.currency is not NULL then supply.currency else transferred.asset end) as asset").
ColumnExpr("(case when fees.amount is NULL then 0 else fees.amount end) as fee").
ColumnExpr("(case when transferred.amount is NULL then 0 else transferred.amount end) as transferred").
ColumnExpr("(case when supply.amount is NULL then 0 else supply.amount end) as supply").
ColumnExpr("(case when fees.c is NULL then 0 else fees.c end) as fee_count").
ColumnExpr("(case when transferred.c is NULL then 0 else transferred.c end) as transfer_count").
Join("left join transferred on supply.currency = transferred.asset").
Join("left join fees on supply.currency = fees.asset")
query = limitScope(query, limit)
query = offsetScope(query, offset)
if _, ok := validSortFieldsForAssetList[sortBy]; ok {
query = sortScope(query, sortBy, order)
} else {
query = sortScope(query, "supply", order)
}
err = query.Scan(ctx, &assets)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/uptrace/bun"
)
// Blocks -
type Blocks struct {
*postgres.Table[*storage.Block]
}
// NewBlocks -
func NewBlocks(db *postgres.Storage) *Blocks {
return &Blocks{
Table: postgres.NewTable[*storage.Block](db.Connection()),
}
}
// ByHeight -
func (b *Blocks) ByHeight(ctx context.Context, height types.Level, withStats bool) (block storage.Block, err error) {
subQuery := b.DB().NewSelect().
Model((*storage.Block)(nil)).
Where("height = ?", height).
Limit(1)
query := b.DB().NewSelect().
TableExpr("(?) as block", subQuery).
ColumnExpr("block.*").
ColumnExpr("validator.id as proposer__id, validator.address as proposer__address, validator.name as proposer__name").
Join("left join validator on block.proposer_id = validator.id")
if withStats {
query = query.
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
Join("left join block_stats as stats ON stats.height = block.height AND stats.time = block.time")
}
err = query.Scan(ctx, &block)
return
}
// Last -
func (b *Blocks) Last(ctx context.Context) (block storage.Block, err error) {
err = b.DB().NewSelect().Model(&block).
Relation("Proposer", func(sq *bun.SelectQuery) *bun.SelectQuery {
return sq.Column("id", "address", "name")
}).
Order("id desc").
Limit(1).
Scan(ctx)
return
}
// ByHash -
func (b *Blocks) ByHash(ctx context.Context, hash []byte) (block storage.Block, err error) {
subQuery := b.DB().NewSelect().
Model((*storage.Block)(nil)).
Where("hash = ?", hash).
Limit(1)
err = b.DB().NewSelect().
TableExpr("(?) as block", subQuery).
ColumnExpr("block.*").
ColumnExpr("validator.id as proposer__id, validator.address as proposer__address, validator.name as proposer__name").
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
Join("left join validator on block.proposer_id = validator.id").
Join("left join block_stats as stats ON stats.height = block.height AND stats.time = block.time").
Scan(ctx, &block)
return
}
// ListWithStats -
func (b *Blocks) ListWithStats(ctx context.Context, limit, offset uint64, order sdk.SortOrder) (blocks []*storage.Block, err error) {
subQuery := b.DB().NewSelect().Model(&blocks)
subQuery = sortScope(subQuery, "block.time", order)
subQuery = limitScope(subQuery, int(limit))
subQuery = offsetScope(subQuery, int(offset))
query := b.DB().NewSelect().
ColumnExpr("block.*").
ColumnExpr("v.id AS proposer__id, v.address as proposer__address, v.name as proposer__name").
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
TableExpr("(?) as block", subQuery).
Join("LEFT JOIN block_stats as stats ON stats.height = block.height AND stats.time = block.time").
Join("LEFT JOIN validator as v ON v.id = block.proposer_id")
query = sortScope(query, "block.time", order)
err = query.Scan(ctx, &blocks)
return
}
func (b *Blocks) ByProposer(ctx context.Context, proposerId uint64, limit, offset int, order sdk.SortOrder) (blocks []storage.Block, err error) {
subQuery := b.DB().NewSelect().Model(&blocks).
Where("proposer_id = ?", proposerId)
subQuery = sortScope(subQuery, "id", order)
subQuery = limitScope(subQuery, limit)
subQuery = offsetScope(subQuery, offset)
query := b.DB().NewSelect().
ColumnExpr("block.*").
ColumnExpr("v.id AS proposer__id, v.address as proposer__address, v.name as proposer__name").
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
TableExpr("(?) as block", subQuery).
Join("LEFT JOIN block_stats as stats ON stats.height = block.height AND stats.time = block.time").
Join("LEFT JOIN validator as v ON v.id = block.proposer_id")
query = sortScope(query, "block.id", order)
err = query.Scan(ctx, &blocks)
return
}
func (b *Blocks) ByIdWithRelations(ctx context.Context, id uint64) (block storage.Block, err error) {
query := b.DB().NewSelect().
Model((*storage.Block)(nil)).
Where("id = ?", id).
Limit(1)
err = b.DB().NewSelect().
TableExpr("(?) as block", query).
ColumnExpr("block.*").
ColumnExpr("validator.id as proposer__id, validator.address as proposer__address, validator.name as proposer__name, validator.pubkey as proposer__pubkey, validator.pubkey_type as proposer__pubkey_type, validator.power as proposer__power, validator.height as proposer__height").
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
Join("left join validator on block.proposer_id = validator.id").
Join("left join block_stats as stats ON stats.height = block.height AND stats.time = block.time").
Scan(ctx, &block)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// BlockSignature -
type BlockSignature struct {
*postgres.Table[*storage.BlockSignature]
}
// NewBlockSignature -
func NewBlockSignature(db *postgres.Storage) *BlockSignature {
return &BlockSignature{
Table: postgres.NewTable[*storage.BlockSignature](db.Connection()),
}
}
func (bs *BlockSignature) LevelsByValidator(ctx context.Context, validatorId uint64, startHeight types.Level) (levels []types.Level, err error) {
err = bs.DB().NewSelect().
Model((*storage.BlockSignature)(nil)).
Column("height").
Where("validator_id = ?", validatorId).
Where("height > ?", startHeight).
Order("id desc").
Scan(ctx, &levels)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// BlockStats -
type BlockStats struct {
db *postgres.Storage
}
// NewBlockStats -
func NewBlockStats(db *postgres.Storage) *BlockStats {
return &BlockStats{
db: db,
}
}
// ByHeight -
func (b *BlockStats) ByHeight(ctx context.Context, height types.Level) (stats storage.BlockStats, err error) {
err = b.db.Connection().DB().NewSelect().Model(&stats).
Where("height = ?", height).
Limit(1).
Scan(ctx)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Bridge -
type Bridge struct {
*postgres.Table[*storage.Bridge]
}
// NewBridge -
func NewBridge(db *postgres.Storage) *Bridge {
return &Bridge{
Table: postgres.NewTable[*storage.Bridge](db.Connection()),
}
}
func (b *Bridge) ByAddress(ctx context.Context, addressId uint64) (bridge storage.Bridge, err error) {
query := b.DB().NewSelect().
Model((*storage.Bridge)(nil)).
Where("address_id = ?", addressId)
err = b.DB().NewSelect().
TableExpr("(?) as bridge", query).
ColumnExpr("bridge.*").
ColumnExpr("address.hash as address__hash").
ColumnExpr("sudo.hash as sudo__hash").
ColumnExpr("withdrawer.hash as withdrawer__hash").
ColumnExpr("rollup.astria_id as rollup__astria_id").
Join("left join address as address on address.id = bridge.address_id").
Join("left join address as sudo on sudo.id = bridge.sudo_id").
Join("left join address as withdrawer on withdrawer.id = bridge.withdrawer_id").
Join("left join rollup on rollup.id = bridge.rollup_id").
Scan(ctx, &bridge)
return
}
func (b *Bridge) ByRollup(ctx context.Context, rollupId uint64, limit, offset int) (bridge []storage.Bridge, err error) {
query := b.DB().NewSelect().
Model((*storage.Bridge)(nil)).
Where("rollup_id = ?", rollupId).
Offset(offset)
query = limitScope(query, limit)
err = b.DB().NewSelect().
TableExpr("(?) as bridge", query).
ColumnExpr("bridge.*").
ColumnExpr("address.hash as address__hash").
ColumnExpr("sudo.hash as sudo__hash").
ColumnExpr("withdrawer.hash as withdrawer__hash").
ColumnExpr("rollup.astria_id as rollup__astria_id").
Join("left join address as address on address.id = bridge.address_id").
Join("left join address as sudo on sudo.id = bridge.sudo_id").
Join("left join address as withdrawer on withdrawer.id = bridge.withdrawer_id").
Join("left join rollup on rollup.id = bridge.rollup_id").
Scan(ctx, &bridge)
return
}
func (b *Bridge) ByRoles(ctx context.Context, addressId uint64, limit, offset int) (result []storage.Bridge, err error) {
query := b.DB().NewSelect().
Model((*storage.Bridge)(nil)).
Where("sudo_id = ?", addressId).
WhereOr("withdrawer_id = ?", addressId).
Offset(offset)
query = limitScope(query, limit)
err = b.DB().NewSelect().
TableExpr("(?) as bridge", query).
ColumnExpr("bridge.*").
ColumnExpr("address.hash as address__hash").
ColumnExpr("sudo.hash as sudo__hash").
ColumnExpr("withdrawer.hash as withdrawer__hash").
ColumnExpr("rollup.astria_id as rollup__astria_id").
Join("left join address as address on address.id = bridge.address_id").
Join("left join address as sudo on sudo.id = bridge.sudo_id").
Join("left join address as withdrawer on withdrawer.id = bridge.withdrawer_id").
Join("left join rollup on rollup.id = bridge.rollup_id").
Scan(ctx, &result)
return
}
func (b *Bridge) ListWithAddress(ctx context.Context, limit, offset int) (result []storage.Bridge, err error) {
query := b.DB().NewSelect().
Model((*storage.Bridge)(nil)).
Offset(offset)
query = limitScope(query, limit)
query = sortScope(query, "id", sdk.SortOrderAsc)
err = b.DB().NewSelect().
TableExpr("(?) as bridge", query).
ColumnExpr("bridge.*").
ColumnExpr("address.hash as address__hash").
Join("left join address as address on address.id = bridge.address_id").
Scan(ctx, &result)
return
}
func (b *Bridge) ById(ctx context.Context, id uint64) (bridge storage.Bridge, err error) {
query := b.DB().NewSelect().
Model((*storage.Bridge)(nil)).
Where("id = ?", id)
err = b.DB().NewSelect().
TableExpr("(?) as bridge", query).
ColumnExpr("bridge.*").
ColumnExpr("address.hash as address__hash").
ColumnExpr("rollup.astria_id as rollup__astria_id").
Join("left join address as address on address.id = bridge.address_id").
Join("left join rollup on rollup.id = bridge.rollup_id").
Scan(ctx, &bridge)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"database/sql"
"errors"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Constant -
type Constant struct {
db *postgres.Storage
}
// NewConstant -
func NewConstant(db *postgres.Storage) *Constant {
return &Constant{
db: db,
}
}
func (constant *Constant) Get(ctx context.Context, module types.ModuleName, name string) (c storage.Constant, err error) {
err = constant.db.Connection().DB().NewSelect().Model(&c).
Where("module = ?", module).
Where("name = ?", name).
Scan(ctx)
return
}
func (constant *Constant) ByModule(ctx context.Context, module types.ModuleName) (c []storage.Constant, err error) {
err = constant.db.Connection().DB().NewSelect().Model(&c).
Where("module = ?", module).
Scan(ctx)
return
}
func (constant *Constant) All(ctx context.Context) (c []storage.Constant, err error) {
err = constant.db.Connection().DB().NewSelect().Model(&c).Scan(ctx)
return
}
func (constant *Constant) IsNoRows(err error) bool {
return errors.Is(err, sql.ErrNoRows)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
models "github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/postgres/migrations"
"github.com/dipdup-net/go-lib/config"
"github.com/dipdup-net/go-lib/database"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/pkg/errors"
"github.com/uptrace/bun"
"github.com/uptrace/bun/migrate"
)
// Create -
func Create(ctx context.Context, cfg config.Database, scriptsDir string, withMigrations bool) (*postgres.Storage, error) {
init := initDatabase
if withMigrations {
init = initDatabaseWithMigrations
}
strg, err := postgres.Create(ctx, cfg, init)
if err != nil {
return nil, errors.Wrap(err, "create database")
}
if err := createScripts(ctx, strg.Connection(), scriptsDir, "functions", false); err != nil {
return nil, errors.Wrap(err, "creating functions")
}
if err := createScripts(ctx, strg.Connection(), scriptsDir, "views", true); err != nil {
return nil, errors.Wrap(err, "creating views")
}
return strg, nil
}
func initDatabase(ctx context.Context, conn *database.Bun) error {
if err := createExtensions(ctx, conn); err != nil {
return errors.Wrap(err, "create extensions")
}
if err := createTypes(ctx, conn); err != nil {
return errors.Wrap(err, "creating custom types")
}
// register many-to-many relationships
conn.DB().RegisterModel(
(*models.RollupAction)(nil),
(*models.RollupAddress)(nil),
(*models.AddressAction)(nil),
)
if err := database.CreateTables(ctx, conn, models.Models...); err != nil {
if err := conn.Close(); err != nil {
return err
}
return err
}
if err := database.MakeComments(ctx, conn, models.Models...); err != nil {
if err := conn.Close(); err != nil {
return err
}
return errors.Wrap(err, "make comments")
}
if err := createHypertables(ctx, conn); err != nil {
if err := conn.Close(); err != nil {
return err
}
return errors.Wrap(err, "create hypertables")
}
return createIndices(ctx, conn)
}
func initDatabaseWithMigrations(ctx context.Context, conn *database.Bun) error {
if err := initDatabase(ctx, conn); err != nil {
return err
}
return migrateDatabase(ctx, conn)
}
func migrateDatabase(ctx context.Context, db *database.Bun) error {
migrator := migrate.NewMigrator(db.DB(), migrations.Migrations)
if err := migrator.Init(ctx); err != nil {
return err
}
if err := migrator.Lock(ctx); err != nil {
return err
}
defer migrator.Unlock(ctx) //nolint:errcheck
_, err := migrator.Migrate(ctx)
return err
}
func createHypertables(ctx context.Context, conn *database.Bun) error {
return conn.DB().RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
for _, model := range []storage.Model{
&models.Block{},
&models.BlockStats{},
&models.Tx{},
&models.Action{},
&models.BlockSignature{},
&models.RollupAction{},
&models.Fee{},
&models.Transfer{},
&models.Deposit{},
&models.Price{},
} {
if _, err := tx.ExecContext(ctx,
`SELECT create_hypertable(?, 'time', chunk_time_interval => INTERVAL '1 month', if_not_exists => TRUE);`,
model.TableName(),
); err != nil {
return err
}
}
return nil
})
}
func createExtensions(ctx context.Context, conn *database.Bun) error {
return conn.DB().RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
_, err := tx.ExecContext(ctx, "CREATE EXTENSION IF NOT EXISTS pg_trgm;")
return err
})
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"database/sql"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/dipdup-net/go-lib/database"
"github.com/rs/zerolog/log"
"github.com/uptrace/bun"
)
const (
createTypeQuery = `DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = ?) THEN
CREATE TYPE ? AS ENUM (?);
END IF;
END$$;`
)
func createTypes(ctx context.Context, conn *database.Bun) error {
log.Info().Msg("creating custom types...")
return conn.DB().RunInTx(ctx, &sql.TxOptions{}, func(ctx context.Context, tx bun.Tx) error {
if _, err := tx.ExecContext(
ctx,
createTypeQuery,
"action_type",
bun.Safe("action_type"),
bun.In(types.ActionTypeValues()),
); err != nil {
return err
}
if _, err := tx.ExecContext(
ctx,
createTypeQuery,
"status",
bun.Safe("status"),
bun.In(types.StatusValues()),
); err != nil {
return err
}
if _, err := tx.ExecContext(
ctx,
createTypeQuery,
"module_name",
bun.Safe("module_name"),
bun.In(types.ModuleNameValues()),
); err != nil {
return err
}
if _, err := tx.ExecContext(
ctx,
createTypeQuery,
"app_type",
bun.Safe("app_type"),
bun.In(types.AppTypeValues()),
); err != nil {
return err
}
if _, err := tx.ExecContext(
ctx,
createTypeQuery,
"app_category",
bun.Safe("app_category"),
bun.In(types.AppCategoryValues()),
); err != nil {
return err
}
return nil
})
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Fee -
type Deposit struct {
*postgres.Table[*storage.Deposit]
}
// NewDeposit -
func NewDeposit(db *postgres.Storage) *Deposit {
return &Deposit{
Table: postgres.NewTable[*storage.Deposit](db.Connection()),
}
}
func (d *Deposit) ByBridgeId(ctx context.Context, bridgeId uint64, limit, offset int, sort sdk.SortOrder) (deposits []storage.Deposit, err error) {
query := d.DB().NewSelect().
Model((*storage.Deposit)(nil)).
Where("bridge_id = ?", bridgeId)
query = limitScope(query, limit)
query = offsetScope(query, offset)
query = sortScope(query, "time", sort)
err = d.DB().NewSelect().
TableExpr("(?) as deposit", query).
ColumnExpr("deposit.*").
ColumnExpr("tx.hash as tx__hash").
Join("left join tx on tx.id = tx_id").
Scan(ctx, &deposits)
return
}
func (d *Deposit) ByRollupId(ctx context.Context, rollupId uint64, limit, offset int, sort sdk.SortOrder) (deposits []storage.Deposit, err error) {
query := d.DB().NewSelect().
Model((*storage.Deposit)(nil)).
Where("rollup_id = ?", rollupId)
query = limitScope(query, limit)
query = offsetScope(query, offset)
query = sortScope(query, "time", sort)
err = d.DB().NewSelect().
TableExpr("(?) as deposit", query).
ColumnExpr("deposit.*").
ColumnExpr("tx.hash as tx__hash").
ColumnExpr("bridge.address_id as bridge__address_id").
ColumnExpr("address.hash as bridge__address__hash").
Join("left join tx on tx.id = tx_id").
Join("left join bridge on bridge_id = bridge.id").
Join("left join address on address_id = address.id").
Scan(ctx, &deposits)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Fee -
type Fee struct {
*postgres.Table[*storage.Fee]
}
// NewFee -
func NewFee(db *postgres.Storage) *Fee {
return &Fee{
Table: postgres.NewTable[*storage.Fee](db.Connection()),
}
}
func (f *Fee) ByTxId(ctx context.Context, id uint64, limit, offset int) (fees []storage.Fee, err error) {
query := f.DB().NewSelect().
Model((*storage.Fee)(nil)).
Where("tx_id = ?", id)
query = limitScope(query, limit)
query = offsetScope(query, offset)
err = f.DB().NewSelect().
TableExpr("(?) as fee", query).
ColumnExpr("fee.*").
ColumnExpr("address.hash as payer__hash").
Join("left join address on address.id = fee.payer_id").
Scan(ctx, &fees)
return
}
func (f *Fee) ByPayerId(ctx context.Context, id uint64, limit, offset int, sort sdk.SortOrder) (fees []storage.Fee, err error) {
query := f.DB().NewSelect().
Model((*storage.Fee)(nil)).
Where("payer_id = ?", id)
query = limitScope(query, limit)
query = offsetScope(query, offset)
query = sortScope(query, "time", sort)
err = f.DB().NewSelect().
TableExpr("(?) as fee", query).
ColumnExpr("fee.*").
ColumnExpr("tx.hash as tx__hash").
Join("left join tx on tx.id = fee.tx_id").
Scan(ctx, &fees)
return
}
func (f *Fee) FullTxFee(ctx context.Context, id uint64) (fees []storage.Fee, err error) {
err = f.DB().NewSelect().
Model(&fees).
ColumnExpr("sum(amount) as amount, asset").
Where("tx_id = ?", id).
Group("asset").
Scan(ctx)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"database/sql"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/go-lib/database"
"github.com/rs/zerolog/log"
"github.com/uptrace/bun"
)
func createIndices(ctx context.Context, conn *database.Bun) error {
log.Info().Msg("creating indexes...")
return conn.DB().RunInTx(ctx, &sql.TxOptions{}, func(ctx context.Context, tx bun.Tx) error {
// Address
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Address)(nil)).
Index("address_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
// Block
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Block)(nil)).
Index("block_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Block)(nil)).
Index("block_proposer_id_idx").
Column("proposer_id").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Block)(nil)).
Index("block_hash_idx").
Column("hash").
Using("HASH").
Exec(ctx); err != nil {
return err
}
// BlockStats
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.BlockStats)(nil)).
Index("block_stats_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
// Tx
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Tx)(nil)).
Index("tx_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Tx)(nil)).
Index("tx_hash_idx").
Column("hash").
Using("HASH").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Tx)(nil)).
Index("tx_status_idx").
Column("status").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Tx)(nil)).
Index("tx_signer_id_idx").
Column("signer_id").
Exec(ctx); err != nil {
return err
}
// Action
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Action)(nil)).
Index("action_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Action)(nil)).
Index("action_tx_id_idx").
Column("tx_id").
Where("tx_id IS NOT NULL").
Exec(ctx); err != nil {
return err
}
// Rollup
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Rollup)(nil)).
Index("rollup_first_height_idx").
Column("first_height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Rollup)(nil)).
Index("rollup_hash_idx").
Column("astria_id").
Using("HASH").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Rollup)(nil)).
Index("rollup_size_idx").
Column("size").
Exec(ctx); err != nil {
return err
}
// Rollup actions
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.RollupAction)(nil)).
Index("rollup_action_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.RollupAction)(nil)).
Index("rollup_action_tx_id_idx").
Column("tx_id").
Where("tx_id IS NOT NULL").
Exec(ctx); err != nil {
return err
}
// Address actions
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.AddressAction)(nil)).
Index("address_action_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.AddressAction)(nil)).
Index("address_action_tx_id_idx").
Column("tx_id").
Where("tx_id IS NOT NULL").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.AddressAction)(nil)).
Index("address_action_type_idx").
Column("action_type").
Where("tx_id IS NOT NULL").
Exec(ctx); err != nil {
return err
}
// Validators
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Validator)(nil)).
Index("validator_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Validator)(nil)).
Index("validator_name_idx").
ColumnExpr("name gin_trgm_ops").
Using("GIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Validator)(nil)).
Index("validator_power_idx").
ColumnExpr("power").
Exec(ctx); err != nil {
return err
}
// Bridge
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Bridge)(nil)).
Index("bridge_init_height_idx").
Column("init_height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Bridge)(nil)).
Index("bridge_sudo_id_idx").
Column("sudo_id").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Bridge)(nil)).
Index("bridge_withdrawer_id_idx").
Column("withdrawer_id").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Bridge)(nil)).
Index("bridge_rollup_id_idx").
Column("rollup_id").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Bridge)(nil)).
Index("bridge_asset_idx").
ColumnExpr("asset gin_trgm_ops").
Using("GIN").
Exec(ctx); err != nil {
return err
}
// Fee
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Fee)(nil)).
Index("fee_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Fee)(nil)).
Index("fee_action_id_idx").
Column("action_id").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Fee)(nil)).
Index("fee_tx_id_idx").
Column("tx_id").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Fee)(nil)).
Index("fee_asset_idx").
Column("asset").
Exec(ctx); err != nil {
return err
}
// Transfer
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Transfer)(nil)).
Index("transfer_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Transfer)(nil)).
Index("transfer_src_id_idx").
Column("src_id").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Transfer)(nil)).
Index("transfer_dest_id_idx").
Column("dest_id").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Transfer)(nil)).
Index("transfer_asset_idx").
Column("asset").
Exec(ctx); err != nil {
return err
}
// Deposit
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Deposit)(nil)).
Index("deposit_height_idx").
Column("height").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Deposit)(nil)).
Index("deposit_action_id_idx").
Column("action_id").
Using("BRIN").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Deposit)(nil)).
Index("deposit_rollup_id_idx").
Column("rollup_id").
Exec(ctx); err != nil {
return err
}
if _, err := tx.NewCreateIndex().
IfNotExists().
Model((*storage.Deposit)(nil)).
Index("deposit_bridge_id_idx").
Column("bridge_id").
Exec(ctx); err != nil {
return err
}
return nil
})
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/go-lib/config"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
type ListenerFactory struct {
cfg config.Database
db *postgres.Storage
}
func NewListenerFactory(cfg config.Database, db *postgres.Storage) *ListenerFactory {
return &ListenerFactory{
cfg: cfg,
db: db,
}
}
func (factory *ListenerFactory) CreateListener() storage.Listener {
return NewNotificator(factory.cfg, factory.db)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/go-lib/database"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
type Market struct {
db *database.Bun
}
func NewMarket(conn *postgres.Storage) *Market {
return &Market{
db: conn.Connection(),
}
}
func (m *Market) List(ctx context.Context, limit, offset int) (markets []storage.Market, err error) {
priceQuery := m.db.DB().NewSelect().
Model((*storage.Price)(nil)).
ColumnExpr("max(time) as time").
ColumnExpr("last(price, time) as price").
Column("currency_pair").
Group("currency_pair")
query := m.db.DB().NewSelect().
Model((*storage.Market)(nil))
query = limitScope(query, limit)
query = offsetScope(query, offset)
err = m.db.DB().NewSelect().
With("prices", priceQuery).
TableExpr("(?) as market", query).
ColumnExpr("market.*, p.price as price__price, p.time as price__time").
Join("left join prices p on p.currency_pair = market.pair").
Scan(ctx, &markets)
return
}
func (m *Market) Get(ctx context.Context, pair string) (market storage.Market, err error) {
priceQuery := m.db.DB().NewSelect().
Model((*storage.Price)(nil)).
ColumnExpr("max(time) as time").
ColumnExpr("last(price, time) as price").
Column("currency_pair").
Group("currency_pair")
query := m.db.DB().NewSelect().
Model((*storage.Market)(nil)).
Where("pair = ?", pair)
if err = m.db.DB().NewSelect().
With("prices", priceQuery).
TableExpr("(?) as market", query).
ColumnExpr("market.*, p.price as price__price, p.time as price__time").
Join("left join prices p on p.currency_pair = market.pair").
Scan(ctx, &market); err != nil {
return
}
err = m.db.DB().NewSelect().
Model(&market.Providers).
Column("provider", "off_chain_ticker").
Where("pair = ?", pair).
Scan(ctx)
return
}
func (m *Market) Decimals(ctx context.Context, pair string) (decimals int, err error) {
err = m.db.DB().NewSelect().
Model((*storage.Market)(nil)).
Column("decimals").
Where("pair = ?", pair).
Limit(1).
Scan(ctx, &decimals)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"fmt"
"time"
"github.com/dipdup-net/go-lib/config"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/lib/pq"
"github.com/uptrace/bun"
)
const (
connectionName = "astria_notifications"
minReconnectInterval = 10 * time.Second
maxReconnectInterval = time.Minute
)
type Notificator struct {
db *bun.DB
l *pq.Listener
}
func NewNotificator(cfg config.Database, db *postgres.Storage) *Notificator {
connStr := fmt.Sprintf(
"postgres://%s:%s@%s:%d/%s?sslmode=disable",
cfg.User,
cfg.Password,
cfg.Host,
cfg.Port,
cfg.Database,
)
return &Notificator{
l: pq.NewListener(
connStr,
minReconnectInterval,
maxReconnectInterval,
nil,
),
db: db.Connection().DB(),
}
}
func (n *Notificator) Notify(ctx context.Context, channel string, payload string) error {
_, err := n.db.ExecContext(ctx, "NOTIFY ?, ?", bun.Ident(channel), payload)
return err
}
func (n *Notificator) Listen() chan *pq.Notification {
return n.l.Notify
}
func (n *Notificator) Subscribe(ctx context.Context, channels ...string) error {
for i := range channels {
if err := n.l.Listen(channels[i]); err != nil {
return err
}
}
return nil
}
func (n *Notificator) Close() error {
return n.l.Close()
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/pkg/errors"
)
type Price struct {
*postgres.Table[*storage.Price]
}
func NewPrice(db *postgres.Storage) *Price {
return &Price{
Table: postgres.NewTable[*storage.Price](db.Connection()),
}
}
func (p *Price) Series(ctx context.Context, currencyPair string, timeframe storage.Timeframe) (prices []storage.Candle, err error) {
query := p.DB().NewSelect()
switch timeframe {
case storage.TimeframeHour:
query = query.Table(storage.ViewPriceByHour)
case storage.TimeframeDay:
query = query.Table(storage.ViewPriceByDay)
default:
return nil, errors.Errorf("invalid timeframe %s", timeframe)
}
err = query.
Where("currency_pair = ?", currencyPair).
Order("time DESC").
Scan(ctx, &prices)
return
}
func (p *Price) Last(ctx context.Context, currencyPair string) (price storage.Price, err error) {
err = p.DB().NewSelect().
Model(&price).
Where("currency_pair = ?", currencyPair).
Order("time DESC").
Limit(1).
Scan(ctx)
return
}
func (p *Price) All(ctx context.Context, limit, offset int) (prices []storage.Price, err error) {
query := p.DB().NewSelect().
ColumnExpr("max(time) as time").
ColumnExpr("last(price, time) as price").
Column("currency_pair").
Model(&prices).
Group("currency_pair")
query = limitScope(query, limit)
query = offsetScope(query, offset)
err = query.Scan(ctx)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Rollup -
type Rollup struct {
*postgres.Table[*storage.Rollup]
}
// NewRollup -
func NewRollup(db *postgres.Storage) *Rollup {
return &Rollup{
Table: postgres.NewTable[*storage.Rollup](db.Connection()),
}
}
func (r *Rollup) ActionsByHeight(ctx context.Context, height types.Level, limit, offset int) (actions []storage.RollupAction, err error) {
query := r.DB().NewSelect().Model(&actions).
Where("rollup_action.height = ?", height).
Relation("Rollup").
Relation("Action")
query = limitScope(query, limit)
query = offsetScope(query, offset)
err = query.Scan(ctx)
return
}
func (r *Rollup) CountActionsByHeight(ctx context.Context, height types.Level) (int64, error) {
count, err := r.DB().NewSelect().Model((*storage.RollupAction)(nil)).
Where("height = ?", height).
Count(ctx)
return int64(count), err
}
func (r *Rollup) ActionsByTxId(ctx context.Context, txId uint64, limit, offset int) (actions []storage.RollupAction, err error) {
query := r.DB().NewSelect().Model(&actions).
Where("rollup_action.tx_id = ?", txId).
Relation("Rollup").
Relation("Action")
query = limitScope(query, limit)
query = offsetScope(query, offset)
err = query.Scan(ctx)
return
}
func (r *Rollup) CountActionsByTxId(ctx context.Context, txId uint64) (int64, error) {
count, err := r.DB().NewSelect().Model((*storage.RollupAction)(nil)).
Where("tx_id = ?", txId).
Count(ctx)
return int64(count), err
}
func (r *Rollup) ByHash(ctx context.Context, hash []byte) (rollup storage.Rollup, err error) {
err = r.DB().NewSelect().Model(&rollup).
Where("astria_id = ?", hash).
Limit(1).
Scan(ctx)
return
}
func (r *Rollup) Addresses(ctx context.Context, rollupId uint64, limit, offset int, sort sdk.SortOrder) (addresses []storage.RollupAddress, err error) {
query := r.DB().NewSelect().Model(&addresses).
Where("rollup_id = ?", rollupId).
Relation("Address")
query = limitScope(query, limit)
query = sortScope(query, "address_id", sort)
query = offsetScope(query, offset)
err = query.Scan(ctx)
return
}
func (r *Rollup) ListRollupsByAddress(ctx context.Context, addressId uint64, limit, offset int, sort sdk.SortOrder) (addresses []storage.RollupAddress, err error) {
query := r.DB().NewSelect().Model(&addresses).
Where("address_id = ?", addressId).
Relation("Rollup")
query = limitScope(query, limit)
query = sortScope(query, "rollup_id", sort)
query = offsetScope(query, offset)
err = query.Scan(ctx)
return
}
func (r *Rollup) ListExt(ctx context.Context, fltrs storage.RollupListFilter) (rollups []storage.Rollup, err error) {
query := r.DB().NewSelect().Model(&rollups)
query = limitScope(query, fltrs.Limit)
switch fltrs.SortField {
case "size":
query = sortScope(query, "size", fltrs.SortOrder)
default:
query = sortScope(query, "id", fltrs.SortOrder)
}
query = offsetScope(query, fltrs.Offset)
err = query.Scan(ctx)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"github.com/celenium-io/astria-indexer/internal/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
const (
columnSize = "size"
columnActionsCount = "actions_count"
columnTime = "time"
)
func limitScope(q *bun.SelectQuery, limit int) *bun.SelectQuery {
if limit < 1 || limit > 100 {
limit = 10
}
return q.Limit(limit)
}
func offsetScope(q *bun.SelectQuery, offset int) *bun.SelectQuery {
if offset > 0 {
return q.Offset(offset)
}
return q
}
func sortScope(q *bun.SelectQuery, field string, sort sdk.SortOrder) *bun.SelectQuery {
if sort != sdk.SortOrderAsc && sort != sdk.SortOrderDesc {
sort = sdk.SortOrderAsc
}
return q.OrderExpr("? ?", bun.Ident(field), bun.Safe(sort))
}
func addressListFilter(query *bun.SelectQuery, fltrs storage.AddressListFilter) *bun.SelectQuery {
query = limitScope(query, fltrs.Limit)
query = sortScope(query, "id", fltrs.Sort)
return query
}
func txFilter(query *bun.SelectQuery, fltrs storage.TxFilter) *bun.SelectQuery {
query = limitScope(query, fltrs.Limit)
query = sortScope(query, "tx.id", fltrs.Sort)
query = offsetScope(query, fltrs.Offset)
if !fltrs.ActionTypes.Empty() {
query = query.Where("action_types & ? > 0", fltrs.ActionTypes.Bits)
}
if len(fltrs.Status) > 0 {
query = query.WhereGroup(" AND ", func(sq *bun.SelectQuery) *bun.SelectQuery {
for i := range fltrs.Status {
sq = sq.WhereOr("status = ?", fltrs.Status[i])
}
return sq
})
}
if fltrs.Height > 0 {
query = query.Where("tx.height = ?", fltrs.Height)
}
if !fltrs.TimeFrom.IsZero() {
query = query.Where("tx.time >= ?", fltrs.TimeFrom)
}
if !fltrs.TimeTo.IsZero() {
query = query.Where("tx.time < ?", fltrs.TimeTo)
}
if fltrs.WithActions {
query = query.Relation("Actions")
}
return query
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"bytes"
"context"
"os"
"path/filepath"
"github.com/dipdup-net/go-lib/database"
"github.com/pkg/errors"
)
func createScripts(ctx context.Context, conn *database.Bun, dir, subFolder string, split bool) error {
scriptsDir := filepath.Join(dir, subFolder)
files, err := os.ReadDir(scriptsDir)
if err != nil {
return err
}
for i := range files {
if files[i].IsDir() {
continue
}
path := filepath.Join(scriptsDir, files[i].Name())
raw, err := os.ReadFile(path)
if err != nil {
return err
}
if split {
queries := bytes.Split(raw, []byte{';'})
if len(queries) == 0 {
continue
}
for _, query := range queries {
query = bytes.TrimLeft(query, "\n ")
if len(query) == 0 {
continue
}
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 := conn.DB().NewRaw(string(raw)).Exec(ctx); err != nil {
return errors.Wrapf(err, "creating %s '%s'", subFolder, files[i].Name())
}
}
}
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"encoding/base64"
"encoding/hex"
"strconv"
"github.com/celenium-io/astria-indexer/internal/astria"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/go-lib/database"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Search -
type Search struct {
db *database.Bun
}
// NewSearch -
func NewSearch(db *postgres.Storage) *Search {
return &Search{
db: db.Connection(),
}
}
func (s *Search) Search(ctx context.Context, query string) (results []storage.SearchResult, err error) {
text := "%" + query + "%"
searchQuery := s.db.DB().NewSelect().
Model((*storage.Validator)(nil)).
ColumnExpr("id, name as value, 'validator' as type").
Where("name ILIKE ?", text)
bridgeQuery := s.db.DB().NewSelect().
Model((*storage.Bridge)(nil)).
ColumnExpr("id, asset as value, 'bridge' as type").
Where("asset ILIKE ?", text)
appQuery := s.db.DB().NewSelect().
Model((*storage.App)(nil)).
ColumnExpr("id, name as value, 'app' as type").
Where("name ILIKE ?", text)
searchQuery = searchQuery.
UnionAll(bridgeQuery).
UnionAll(appQuery)
if height, err := strconv.ParseInt(query, 10, 64); err == nil {
heightQuery := s.db.DB().NewSelect().
Model((*storage.Block)(nil)).
ColumnExpr("id, encode(hash, 'hex') as value, 'block' as type").
Where("height = ?", height)
searchQuery = searchQuery.UnionAll(heightQuery)
}
if hash, err := hex.DecodeString(query); err == nil {
blockQuery := s.db.DB().NewSelect().
Model((*storage.Block)(nil)).
ColumnExpr("id, encode(hash, 'hex') as value, 'block' as type").
Where("hash = ?", hash)
txQuery := s.db.DB().NewSelect().
Model((*storage.Tx)(nil)).
ColumnExpr("id, encode(hash, 'hex') as value, 'tx' as type").
Where("hash = ?", hash)
rollupQuery := s.db.DB().NewSelect().
Model((*storage.Rollup)(nil)).
ColumnExpr("id, encode(astria_id, 'hex') as value, 'rollup' as type").
Where("astria_id = ?", hash)
searchQuery = searchQuery.
UnionAll(blockQuery).
UnionAll(txQuery).
UnionAll(rollupQuery)
}
if astria.IsAddress(query) {
addressQuery := s.db.DB().NewSelect().
Model((*storage.Address)(nil)).
ColumnExpr("id, hash as value, 'address' as type").
Where("hash = ?", query)
validatorQuery := s.db.DB().NewSelect().
Model((*storage.Validator)(nil)).
ColumnExpr("id, name as value, 'validator' as type").
Where("address = ?", query)
searchQuery = searchQuery.
UnionAll(addressQuery).
UnionAll(validatorQuery)
}
if decoded, err := base64.StdEncoding.DecodeString(query); err == nil {
rollupQuery := s.db.DB().NewSelect().
Model((*storage.Rollup)(nil)).
ColumnExpr("id, encode(astria_id, 'hex') as value, 'rollup' as type").
Where("astria_id = ?", decoded)
searchQuery = searchQuery.
UnionAll(rollupQuery)
}
err = s.db.DB().NewSelect().
TableExpr("(?) as search", searchQuery).
Limit(10).
Offset(0).
Scan(ctx, &results)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"database/sql"
"fmt"
"strconv"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
"go.opentelemetry.io/otel/trace"
"github.com/getsentry/sentry-go"
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect"
"github.com/uptrace/bun/schema"
)
type SentryHook struct {
dbName string
formatQueries bool
tracer trace.Tracer
}
var _ bun.QueryHook = (*SentryHook)(nil)
func NewSentryHook(dbName string, tracer trace.Tracer, formatQueries bool) *SentryHook {
h := new(SentryHook)
h.dbName = dbName
h.formatQueries = formatQueries
h.tracer = tracer
return h
}
func (h *SentryHook) Init(db *bun.DB) {}
func (h *SentryHook) BeforeQuery(ctx context.Context, event *bun.QueryEvent) context.Context {
ctx, _ = h.tracer.Start(ctx, "db", trace.WithSpanKind(trace.SpanKindClient))
return ctx
}
func (h *SentryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent) {
operation := event.Operation()
root := sentry.TransactionFromContext(ctx)
if root == nil {
return
}
span := root.StartChild(operation, sentry.WithOpName("db"))
defer span.Finish()
query := h.eventQuery(event)
span.Description = query
span.SetData("db.statement", query)
span.SetTag("db.operation", operation)
span.SetTag("db.name", h.dbName)
if event.IQuery != nil {
if tableName := event.IQuery.GetTableName(); tableName != "" {
span.SetTag("db.sql.table", tableName)
}
}
if sys := dbSystem(event.DB); sys.Valid() {
span.SetTag(string(sys.Key), sys.Value.AsString())
}
if event.Result != nil {
if n, _ := event.Result.RowsAffected(); n > 0 {
span.SetData("db.rows_affected", strconv.Itoa(int(n)))
}
}
switch event.Err {
case nil, sql.ErrNoRows, sql.ErrTxDone:
// ignore
default:
span.SetTag("exception.message", event.Err.Error())
span.SetTag("exception.type", fmt.Sprintf("%T", event.Err))
// span.SetStatus(codes.Error, event.Err.Error())
}
}
func (h *SentryHook) eventQuery(event *bun.QueryEvent) string {
const softQueryLimit = 8000
const hardQueryLimit = 16000
var query string
if h.formatQueries && len(event.Query) <= softQueryLimit {
query = event.Query
} else {
query = unformattedQuery(event)
}
if len(query) > hardQueryLimit {
query = query[:hardQueryLimit]
}
return query
}
func unformattedQuery(event *bun.QueryEvent) string {
if event.IQuery != nil {
if b, err := event.IQuery.AppendQuery(schema.NewNopFormatter(), nil); err == nil {
return string(b)
}
}
return event.QueryTemplate
}
func dbSystem(db *bun.DB) attribute.KeyValue {
switch db.Dialect().Name() {
case dialect.PG:
return semconv.DBSystemPostgreSQL
case dialect.MySQL:
return semconv.DBSystemMySQL
case dialect.SQLite:
return semconv.DBSystemSqlite
case dialect.MSSQL:
return semconv.DBSystemMSSQL
default:
return attribute.KeyValue{}
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// State -
type State struct {
*postgres.Table[*storage.State]
}
// NewState -
func NewState(db *postgres.Storage) *State {
return &State{
Table: postgres.NewTable[*storage.State](db.Connection()),
}
}
// ByName -
func (s *State) ByName(ctx context.Context, name string) (state storage.State, err error) {
err = s.DB().NewSelect().Model(&state).Where("name = ?", name).Scan(ctx)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/go-lib/database"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
"github.com/pkg/errors"
"github.com/uptrace/bun"
)
type Stats struct {
db *database.Bun
}
func NewStats(conn *postgres.Storage) Stats {
return Stats{
db: conn.Connection(),
}
}
func (s Stats) Series(ctx context.Context, timeframe storage.Timeframe, name string, req storage.SeriesRequest) (response []storage.SeriesItem, err error) {
var view string
switch timeframe {
case storage.TimeframeHour:
view = storage.ViewBlockStatsByHour
case storage.TimeframeDay:
view = storage.ViewBlockStatsByDay
case storage.TimeframeMonth:
view = storage.ViewBlockStatsByMonth
default:
return nil, errors.Errorf("unexpected timeframe %s", timeframe)
}
query := s.db.DB().NewSelect().Table(view)
switch name {
case storage.SeriesDataSize:
query.ColumnExpr("ts, data_size as value")
case storage.SeriesTPS:
query.ColumnExpr("ts, tps as value, tps_max as max, tps_min as min")
case storage.SeriesBPS:
query.ColumnExpr("ts, bps as value, bps_max as max, bps_min as min")
case storage.SeriesRBPS:
query.ColumnExpr("ts, rbps as value, rbps_max as max, rbps_min as min")
case storage.SeriesFee:
query.ColumnExpr("ts, fee as value")
case storage.SeriesSupplyChange:
query.ColumnExpr("ts, supply_change as value")
case storage.SeriesBlockTime:
query.ColumnExpr("ts, block_time as value")
case storage.SeriesTxCount:
query.ColumnExpr("ts, tx_count as value")
case storage.SeriesBytesInBlock:
query.ColumnExpr("ts, bytes_in_block as value")
default:
return nil, errors.Errorf("unexpected series name: %s", name)
}
if !req.From.IsZero() {
query = query.Where("ts >= ?", req.From)
}
if !req.To.IsZero() {
query = query.Where("ts < ?", req.To)
}
err = query.Limit(100).Scan(ctx, &response)
return
}
func (s Stats) RollupSeries(ctx context.Context, rollupId uint64, timeframe storage.Timeframe, name string, req storage.SeriesRequest) (response []storage.SeriesItem, err error) {
var view string
switch timeframe {
case storage.TimeframeHour:
view = storage.ViewRollupStatsByHour
case storage.TimeframeDay:
view = storage.ViewRollupStatsByDay
case storage.TimeframeMonth:
view = storage.ViewRollupStatsByMonth
default:
return nil, errors.Errorf("unexpected timeframe %s", timeframe)
}
query := s.db.DB().NewSelect().Table(view).
Where("rollup_id = ?", rollupId)
switch name {
case storage.RollupSeriesActionsCount:
query.ColumnExpr("ts, actions_count as value")
case storage.RollupSeriesAvgSize:
query.ColumnExpr("ts, avg_size as value")
case storage.RollupSeriesMaxSize:
query.ColumnExpr("ts, max_size as value")
case storage.RollupSeriesMinSize:
query.ColumnExpr("ts, min_size as value")
case storage.RollupSeriesSize:
query.ColumnExpr("ts, size as value")
default:
return nil, errors.Errorf("unexpected series name: %s", name)
}
if !req.From.IsZero() {
query = query.Where("ts >= ?", req.From)
}
if !req.To.IsZero() {
query = query.Where("ts < ?", req.To)
}
err = query.Limit(100).Scan(ctx, &response)
return
}
func (s Stats) Summary(ctx context.Context) (summary storage.NetworkSummary, err error) {
err = s.db.DB().NewSelect().Table(storage.ViewBlockStatsByMonth).
ColumnExpr("sum(data_size) as data_size, sum(fee) as fee, sum(supply_change) as supply, sum(tx_count) as tx_count, sum(bytes_in_block) as bytes_in_block").
ColumnExpr("avg(tps) as tps, avg(bps) as bps, avg(rbps) as rbps, avg(block_time) as block_time").
Scan(ctx, &summary)
return
}
func (s Stats) buildSummaryQuery(table string, prevDate, currDate time.Time) (*bun.SelectQuery, *bun.SelectQuery) {
curr := s.db.DB().NewSelect().
Table(table).
Where("ts >= ?", currDate).
ColumnExpr("sum(data_size) as data_size, sum(tx_count) as tx_count, sum(bytes_in_block) as bytes_in_block").
ColumnExpr("avg(tps) as tps, avg(bps) as bps, avg(rbps) as rbps, avg(block_time) as block_time")
prev := s.db.DB().NewSelect().
Table(table).
Where("ts < ?", currDate).
Where("ts >= ?", prevDate).
ColumnExpr("sum(data_size) as data_size, sum(tx_count) as tx_count, sum(bytes_in_block) as bytes_in_block").
ColumnExpr("avg(tps) as tps, avg(bps) as bps, avg(rbps) as rbps, avg(block_time) as block_time")
return curr, prev
}
func (s Stats) SummaryTimeframe(ctx context.Context, timeframe storage.Timeframe) (summary storage.NetworkSummaryWithChange, err error) {
var (
currDate, prevDate time.Time
table string
)
switch timeframe {
case storage.TimeframeDay:
currDate = time.Now().AddDate(0, 0, -1).UTC()
prevDate = currDate.AddDate(0, 0, -1).UTC()
table = storage.ViewBlockStatsByHour
case storage.TimeframeWeek:
currDate = time.Now().AddDate(0, 0, -7).UTC()
prevDate = currDate.AddDate(0, 0, -7).UTC()
table = storage.ViewBlockStatsByHour
case storage.TimeframeMonth:
currDate = time.Now().AddDate(0, -1, 0).UTC()
prevDate = currDate.AddDate(0, -1, 0).UTC()
table = storage.ViewBlockStatsByMonth
default:
return summary, errors.Errorf("unknown timeframe: %s", timeframe)
}
curr, prev := s.buildSummaryQuery(table, prevDate, currDate)
err = s.db.DB().NewSelect().
With("curr", curr).
With("prev", prev).
Table("curr", "prev").
ColumnExpr("curr.data_size as data_size, curr.tx_count as tx_count, curr.bytes_in_block as bytes_in_block, curr.tps as tps, curr.bps as bps, curr.rbps as rbps, curr.block_time as block_time").
ColumnExpr("case when prev.data_size = 0 then 100 else (curr.data_size - prev.data_size) * 100 / prev.data_size end as data_size_pct").
ColumnExpr("case when prev.tx_count = 0 then 100 else (curr.tx_count - prev.tx_count)* 100 / prev.tx_count end as tx_count_pct").
ColumnExpr("case when prev.bytes_in_block = 0 then 100 else (curr.bytes_in_block - prev.bytes_in_block)* 100 / prev.bytes_in_block end as bytes_in_block_pct").
ColumnExpr("case when prev.tps = 0 then 100 else (curr.tps - prev.tps)* 100 / prev.tps end as tps_pct").
ColumnExpr("case when prev.bps = 0 then 100 else (curr.bps - prev.bps)* 100 / prev.bps end as bps_pct").
ColumnExpr("case when prev.rbps = 0 then 100 else (curr.rbps - prev.rbps)* 100 / prev.rbps end as rbps_pct").
ColumnExpr("case when prev.block_time = 0 then 100 else (curr.block_time - prev.block_time)* 100 / prev.block_time end as block_time_pct").
Scan(ctx, &summary)
return
}
func (s Stats) FeeSummary(ctx context.Context) (response []storage.FeeSummary, err error) {
err = s.db.DB().NewSelect().
Table(storage.ViewFeeStatsByMonth).
ColumnExpr("sum(amount) as amount").
ColumnExpr("min(min_amount) as min_amount").
ColumnExpr("max(max_amount) as max_amount").
ColumnExpr("sum(fee_count) as fee_count").
Column("asset").
Group("asset").
Order("amount desc").
Scan(ctx, &response)
return
}
func (s Stats) TokenTransferDistribution(ctx context.Context, limit int) (items []storage.TokenTransferDistributionItem, err error) {
query := s.db.DB().NewSelect().
Table(storage.ViewTransferStatsByMonth).
ColumnExpr("sum(transfers_count) as transfers_count").
ColumnExpr("sum(amount) as amount").
Column("asset").
Group("asset").
Order("amount desc")
query = limitScope(query, limit)
err = query.Scan(ctx, &items)
return
}
func (s Stats) ActiveAddressesCount(ctx context.Context) (val int64, err error) {
err = s.db.DB().NewSelect().
Model((*storage.Tx)(nil)).
ColumnExpr("count(distinct signer_id)").
Where("time > now() - '1 month'::interval").
Scan(ctx, &val)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/lib/pq"
"github.com/uptrace/bun"
models "github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
)
type Transaction struct {
storage.Transaction
}
func BeginTransaction(ctx context.Context, tx storage.Transactable) (models.Transaction, error) {
t, err := tx.BeginTransaction(ctx)
return Transaction{t}, err
}
func (tx Transaction) SaveConstants(ctx context.Context, constants ...models.Constant) error {
if len(constants) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&constants).Exec(ctx)
return err
}
func (tx Transaction) SaveTransactions(ctx context.Context, txs ...*models.Tx) error {
if len(txs) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&txs).Returning("id").Exec(ctx)
return err
}
type addedAddress struct {
bun.BaseModel `bun:"address"`
*models.Address
Xmax uint64 `bun:"xmax"`
}
func (tx Transaction) SaveAddresses(ctx context.Context, addresses ...*models.Address) (int64, error) {
if len(addresses) == 0 {
return 0, nil
}
addr := make([]addedAddress, len(addresses))
for i := range addresses {
addr[i].Address = addresses[i]
}
_, err := tx.Tx().NewInsert().Model(&addr).
Column("height", "hash", "nonce", "actions_count", "signed_tx_count", "is_bridge", "is_ibc_relayer").
On("CONFLICT ON CONSTRAINT address_hash DO UPDATE").
Set("actions_count = added_address.actions_count + EXCLUDED.actions_count").
Set("signed_tx_count = added_address.signed_tx_count + EXCLUDED.signed_tx_count").
Set("nonce = GREATEST(EXCLUDED.nonce, added_address.nonce)").
Set("is_bridge = EXCLUDED.is_bridge OR added_address.is_bridge").
Set("is_ibc_relayer = CASE WHEN EXCLUDED.is_ibc_relayer IS NOT NULL THEN EXCLUDED.is_ibc_relayer ELSE added_address.is_ibc_relayer END").
Returning("xmax, id").
Exec(ctx)
if err != nil {
return 0, err
}
var count int64
for i := range addr {
if addr[i].Xmax == 0 {
count++
}
}
return count, err
}
func (tx Transaction) SaveBalances(ctx context.Context, balances ...models.Balance) error {
if len(balances) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&balances).
Column("id", "currency", "total").
On("CONFLICT (id, currency) DO UPDATE").
Set("total = EXCLUDED.total + balance.total").
Exec(ctx)
return err
}
func (tx Transaction) SaveActions(ctx context.Context, actions ...*models.Action) error {
if len(actions) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&actions).Returning("id").Exec(ctx)
return err
}
func (tx Transaction) SaveFees(ctx context.Context, fees ...*models.Fee) error {
if len(fees) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&fees).Returning("id").Exec(ctx)
return err
}
func (tx Transaction) SaveDeposits(ctx context.Context, deposits ...*models.Deposit) error {
if len(deposits) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&deposits).Returning("id").Exec(ctx)
return err
}
func (tx Transaction) SaveTransfers(ctx context.Context, transfers ...*models.Transfer) error {
if len(transfers) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&transfers).Returning("id").Exec(ctx)
return err
}
func (tx Transaction) SaveMarkets(ctx context.Context, markets ...models.MarketUpdate) error {
if len(markets) == 0 {
return nil
}
for i := range markets {
switch markets[i].Type {
case models.MarketUpdateTypeCreate:
if _, err := tx.Tx().NewInsert().Model(&markets[i].Market).Exec(ctx); err != nil {
return err
}
case models.MarketUpdateTypeRemove:
if _, err := tx.Tx().NewDelete().Model(&markets[i].Market).WherePK().Exec(ctx); err != nil {
return err
}
case models.MarketUpdateTypeUpdate:
if _, err := tx.Tx().NewUpdate().
Model(&markets[i].Market).
Set("decimals = ?", markets[i].Decimals).
Set("enabled = ?", markets[i].Enabled).
Set("min_provider_count = ?", markets[i].MinProviderCount).
WherePK().
Exec(ctx); err != nil {
return err
}
}
}
return nil
}
func (tx Transaction) SaveMarketProviders(ctx context.Context, providers ...models.MarketProviderUpdate) error {
if len(providers) == 0 {
return nil
}
for i := range providers {
switch providers[i].Type {
case models.MarketUpdateTypeCreate:
if _, err := tx.Tx().NewInsert().Model(&providers[i].MarketProvider).Exec(ctx); err != nil {
return err
}
case models.MarketUpdateTypeRemove:
if _, err := tx.Tx().NewDelete().Model(&providers[i].MarketProvider).WherePK().Exec(ctx); err != nil {
return err
}
case models.MarketUpdateTypeUpdate:
if _, err := tx.Tx().NewUpdate().
Model(&providers[i].MarketProvider).
Set("off_chain_ticker = ?", providers[i].OffChainTicker).
WherePK().
Exec(ctx); err != nil {
return err
}
}
}
return nil
}
func (tx Transaction) SaveValidators(ctx context.Context, validators ...*models.Validator) error {
if len(validators) == 0 {
return nil
}
for i := range validators {
query := tx.Tx().NewInsert().Model(validators[i]).
On("CONFLICT ON CONSTRAINT validator_pubkey DO UPDATE").
Set("power = EXCLUDED.power")
if validators[i].Name != "" {
query.Set("name = ?", validators[i].Name)
}
_, err := query.
Returning("id").
Exec(ctx)
if err != nil {
return err
}
}
return nil
}
type addedRollup struct {
bun.BaseModel `bun:"rollup"`
*models.Rollup
Xmax uint64 `bun:"xmax"`
}
func (tx Transaction) SaveRollups(ctx context.Context, rollups ...*models.Rollup) (int64, error) {
if len(rollups) == 0 {
return 0, nil
}
rs := make([]addedRollup, len(rollups))
for i := range rollups {
rs[i].Rollup = rollups[i]
}
query := tx.Tx().NewInsert().Model(&rs).
Column("first_height", "astria_id", "actions_count", "bridge_count", "size").
On("CONFLICT ON CONSTRAINT rollup_id DO UPDATE").
Set("actions_count = added_rollup.actions_count + EXCLUDED.actions_count").
Set("bridge_count = added_rollup.bridge_count + EXCLUDED.bridge_count").
Set("size = added_rollup.size + EXCLUDED.size")
if _, err := query.Returning("xmax, id").Exec(ctx); err != nil {
return 0, err
}
var count int64
for i := range rs {
if rs[i].Xmax == 0 {
count++
}
}
return count, nil
}
func (tx Transaction) SaveRollupActions(ctx context.Context, actions ...*models.RollupAction) error {
if len(actions) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&actions).Exec(ctx)
return err
}
func (tx Transaction) SaveRollupAddresses(ctx context.Context, addresses ...*models.RollupAddress) error {
if len(addresses) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&addresses).
On("CONFLICT (rollup_id, address_id) DO NOTHING").
Exec(ctx)
return err
}
func (tx Transaction) SaveAddressActions(ctx context.Context, actions ...*models.AddressAction) error {
if len(actions) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&actions).Exec(ctx)
return err
}
func (tx Transaction) SaveBlockSignatures(ctx context.Context, signs ...models.BlockSignature) error {
if len(signs) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&signs).Exec(ctx)
return err
}
func (tx Transaction) SaveBalanceUpdates(ctx context.Context, updates ...models.BalanceUpdate) error {
if len(updates) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&updates).Exec(ctx)
return err
}
type addedBiridge struct {
bun.BaseModel `bun:"bridge"`
*models.Bridge
Xmax uint64 `bun:"xmax"`
}
func (tx Transaction) SaveBridges(ctx context.Context, bridges ...*models.Bridge) (int64, error) {
if len(bridges) == 0 {
return 0, nil
}
var count int64
for i := range bridges {
add := new(addedBiridge)
add.Bridge = bridges[i]
query := tx.Tx().NewInsert().Model(add).
Column("rollup_id", "address_id", "asset", "fee_asset", "sudo_id", "withdrawer_id", "init_height").
On("CONFLICT (address_id) DO UPDATE")
if bridges[i].SudoId > 0 {
query.Set("sudo_id = ?", bridges[i].SudoId)
}
if bridges[i].WithdrawerId > 0 {
query.Set("withdrawer_id = ?", bridges[i].WithdrawerId)
}
if bridges[i].FeeAsset != "" {
query.Set("fee_asset = ?", bridges[i].FeeAsset)
}
if _, err := query.Returning("xmax, id").Exec(ctx); err != nil {
return count, err
}
if add.Xmax == 0 {
count++
}
}
return count, nil
}
func (tx Transaction) SavePrices(ctx context.Context, prices ...models.Price) error {
if len(prices) == 0 {
return nil
}
_, err := tx.Tx().NewInsert().Model(&prices).Exec(ctx)
return err
}
func (tx Transaction) LastBlock(ctx context.Context) (block models.Block, err error) {
err = tx.Tx().NewSelect().Model(&block).Order("id desc").Limit(1).Scan(ctx)
return
}
func (tx Transaction) State(ctx context.Context, name string) (state models.State, err error) {
err = tx.Tx().NewSelect().Model(&state).Where("name = ?", name).Scan(ctx)
return
}
func (tx Transaction) RollbackBlock(ctx context.Context, height types.Level) error {
_, err := tx.Tx().NewDelete().
Model((*models.Block)(nil)).
Where("height = ?", height).
Exec(ctx)
return err
}
func (tx Transaction) RollbackBlockStats(ctx context.Context, height types.Level) (stats models.BlockStats, err error) {
_, err = tx.Tx().NewDelete().Model(&stats).Where("height = ?", height).Returning("*").Exec(ctx)
return
}
func (tx Transaction) RollbackAddresses(ctx context.Context, height types.Level) (address []models.Address, err error) {
_, err = tx.Tx().NewDelete().Model(&address).Where("height = ?", height).Returning("*").Exec(ctx)
return
}
func (tx Transaction) RollbackTxs(ctx context.Context, height types.Level) (txs []models.Tx, err error) {
_, err = tx.Tx().NewDelete().Model(&txs).Where("height = ?", height).Returning("*").Exec(ctx)
return
}
func (tx Transaction) RollbackActions(ctx context.Context, height types.Level) (actions []models.Action, err error) {
_, err = tx.Tx().NewDelete().Model(&actions).Where("height = ?", height).Returning("*").Exec(ctx)
return
}
func (tx Transaction) RollbackValidators(ctx context.Context, height types.Level) (err error) {
_, err = tx.Tx().NewDelete().Model((*models.Validator)(nil)).Where("height = ?", height).Exec(ctx)
return
}
func (tx Transaction) RollbackBlockSignatures(ctx context.Context, height types.Level) (err error) {
_, err = tx.Tx().NewDelete().Model((*models.BlockSignature)(nil)).
Where("height = ?", height).Exec(ctx)
return
}
func (tx Transaction) RollbackBalanceUpdates(ctx context.Context, height types.Level) (updates []models.BalanceUpdate, err error) {
_, err = tx.Tx().NewDelete().Model(&updates).Where("height = ?", height).Returning("*").Exec(ctx)
return
}
func (tx Transaction) RollbackBridges(ctx context.Context, height types.Level) (int, error) {
var bridge []models.Bridge
_, err := tx.Tx().NewDelete().Model(&bridge).Where("init_height = ?", height).Returning("*").Exec(ctx)
return len(bridge), err
}
func (tx Transaction) RollbackAddressActions(ctx context.Context, height types.Level) (addrActions []models.AddressAction, err error) {
_, err = tx.Tx().NewDelete().Model(&addrActions).
Where("height = ?", height).
Returning("*").
Exec(ctx)
return
}
func (tx Transaction) RollbackRollupActions(ctx context.Context, height types.Level) (rActions []models.RollupAction, err error) {
_, err = tx.Tx().NewDelete().Model(&rActions).
Where("height = ?", height).
Returning("*").
Exec(ctx)
return
}
func (tx Transaction) RollbackRollupAddresses(ctx context.Context, height types.Level) (err error) {
_, err = tx.Tx().NewDelete().Model((*models.RollupAddress)(nil)).
Where("height = ?", height).Exec(ctx)
return
}
func (tx Transaction) RollbackRollups(ctx context.Context, height types.Level) (rollups []models.Rollup, err error) {
_, err = tx.Tx().NewDelete().
Model(&rollups).
Where("first_height = ?", height).
Returning("*").
Exec(ctx)
return
}
func (tx Transaction) RollbackFees(ctx context.Context, height types.Level) (err error) {
_, err = tx.Tx().NewDelete().
Model((*models.Fee)(nil)).
Where("height = ?", height).
Exec(ctx)
return
}
func (tx Transaction) RollbackDeposits(ctx context.Context, height types.Level) (err error) {
_, err = tx.Tx().NewDelete().
Model((*models.Deposit)(nil)).
Where("height = ?", height).
Exec(ctx)
return
}
func (tx Transaction) RollbackTransfers(ctx context.Context, height types.Level) (err error) {
_, err = tx.Tx().NewDelete().
Model((*models.Transfer)(nil)).
Where("height = ?", height).
Exec(ctx)
return
}
func (tx Transaction) RollbackBalances(ctx context.Context, ids []uint64) error {
if len(ids) == 0 {
return nil
}
_, err := tx.Tx().NewDelete().
Model((*models.Balance)(nil)).
Where("id IN (?)", bun.In(ids)).
Exec(ctx)
return err
}
func (tx Transaction) UpdateAddresses(ctx context.Context, addresses ...*models.Address) error {
if len(addresses) == 0 {
return nil
}
values := tx.Tx().NewValues(&addresses)
_, err := tx.Tx().NewUpdate().
With("_data", values).
Model((*models.Address)(nil)).
TableExpr("_data").
Set("actions_count = address.actions_count + _data.actions_count").
Set("signed_tx_count = address.signed_tx_count + _data.signed_tx_count").
Set("nonce = GREATEST(_data.nonce, address.nonce)").
Where("address.id = _data.id").
Exec(ctx)
return err
}
func (tx Transaction) UpdateRollups(ctx context.Context, rollups ...*models.Rollup) error {
if len(rollups) == 0 {
return nil
}
values := tx.Tx().NewValues(&rollups)
_, err := tx.Tx().NewUpdate().
With("_data", values).
Model((*models.Rollup)(nil)).
TableExpr("_data").
Set("actions_count = rollup.actions_count + _data.actions_count").
Set("size = rollup.size + _data.size").
Where("rollup.id = _data.id").
Exec(ctx)
return err
}
func (tx Transaction) LastNonce(ctx context.Context, id uint64) (uint32, error) {
var nonce uint32
_, err := tx.Tx().NewSelect().
Model((*models.Tx)(nil)).
Column("nonce").
Where("signer_id = ?", id).
Order("id desc").
Limit(1).
Exec(ctx, &nonce)
return nonce, err
}
func (tx Transaction) GetProposerId(ctx context.Context, address string) (id uint64, err error) {
err = tx.Tx().NewSelect().
Model((*models.Validator)(nil)).
Column("id").
Where("address = ?", address).
Limit(1).
Scan(ctx, &id)
return
}
func (tx Transaction) Validators(ctx context.Context) (validators []models.Validator, err error) {
err = tx.Tx().NewSelect().
Model(&validators).
Column("id", "address", "pubkey").
Scan(ctx)
return
}
func (tx Transaction) RetentionBlockSignatures(ctx context.Context, height types.Level) error {
_, err := tx.Tx().NewDelete().Model((*models.BlockSignature)(nil)).
Where("height <= ?", height).
Exec(ctx)
return err
}
func (tx Transaction) UpdateConstants(ctx context.Context, constants ...*models.Constant) error {
if len(constants) == 0 {
return nil
}
values := tx.Tx().NewValues(&constants)
_, err := tx.Tx().NewUpdate().
With("_data", values).
Model((*models.Constant)(nil)).
TableExpr("_data").
Set("value = _data.value").
Where("constant.module = _data.module").
Where("constant.name = _data.name").
Exec(ctx)
return err
}
func (tx Transaction) GetRollup(ctx context.Context, rollupId []byte) (rollup models.Rollup, err error) {
err = tx.Tx().NewSelect().
Model(&rollup).
Where("astria_id = ?", rollupId).
Scan(ctx)
return
}
func (tx Transaction) GetBridgeIdByAddressId(ctx context.Context, id uint64) (bridgeId uint64, err error) {
err = tx.Tx().NewSelect().
Column("id").
Model((*models.Bridge)(nil)).
Where("address_id = ?", id).
Scan(ctx, &bridgeId)
return
}
func (tx Transaction) GetAddressId(ctx context.Context, hash string) (addrId uint64, err error) {
err = tx.Tx().NewSelect().
Column("id").
Model((*models.Address)(nil)).
Where("hash = ?", hash).
Scan(ctx, &addrId)
return
}
func (tx Transaction) SaveApp(ctx context.Context, app *models.App) error {
if app == nil {
return nil
}
_, err := tx.Tx().NewInsert().Model(app).Exec(ctx)
return err
}
func (tx Transaction) UpdateApp(ctx context.Context, app *models.App) error {
if app == nil || app.IsEmpty() {
return nil
}
query := tx.Tx().NewUpdate().Model(app).WherePK()
if app.Group != "" {
query = query.Set("group = ?", app.Group)
}
if app.Name != "" {
query = query.Set("name = ?", app.Name)
}
if app.Slug != "" {
query = query.Set("slug = ?", app.Slug)
}
if app.Description != "" {
query = query.Set("description = ?", app.Description)
}
if app.Twitter != "" {
query = query.Set("twitter = ?", app.Twitter)
}
if app.Github != "" {
query = query.Set("github = ?", app.Github)
}
if app.Website != "" {
query = query.Set("website = ?", app.Website)
}
if app.Logo != "" {
query = query.Set("logo = ?", app.Logo)
}
if app.L2Beat != "" {
query = query.Set("l2beat = ?", app.L2Beat)
}
if app.Explorer != "" {
query = query.Set("explorer = ?", app.Explorer)
}
if app.Stack != "" {
query = query.Set("stack = ?", app.Stack)
}
if app.Links != nil {
query = query.Set("links = ?", pq.Array(app.Links))
}
if app.Type != "" {
query = query.Set("type = ?", app.Type)
}
if app.Category != "" {
query = query.Set("category = ?", app.Category)
}
if app.Provider != "" {
query = query.Set("provider = ?", app.Provider)
}
if app.VM != "" {
query = query.Set("vm = ?", app.VM)
}
if app.RollupId > 0 {
query = query.Set("rollup_id = ?", app.RollupId)
}
_, err := query.Exec(ctx)
return err
}
func (tx Transaction) DeleteApp(ctx context.Context, appId uint64) error {
if appId == 0 {
return nil
}
_, err := tx.Tx().NewDelete().
Model((*models.App)(nil)).
Where("id = ?", appId).
Exec(ctx)
return err
}
func (tx Transaction) RefreshLeaderboard(ctx context.Context) error {
_, err := tx.Tx().ExecContext(ctx, "REFRESH MATERIALIZED VIEW leaderboard;")
return err
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Transfer -
type Transfer struct {
*postgres.Table[*storage.Transfer]
}
// NewTransfer -
func NewTransfer(db *postgres.Storage) *Transfer {
return &Transfer{
Table: postgres.NewTable[*storage.Transfer](db.Connection()),
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Tx -
type Tx struct {
*postgres.Table[*storage.Tx]
}
// NewTx -
func NewTx(db *postgres.Storage) *Tx {
return &Tx{
Table: postgres.NewTable[*storage.Tx](db.Connection()),
}
}
func (tx *Tx) ByHash(ctx context.Context, hash []byte) (transaction storage.Tx, err error) {
query := tx.DB().NewSelect().Model((*storage.Tx)(nil)).
Where("hash = ?", hash).
Limit(1)
err = tx.DB().NewSelect().
TableExpr("(?) as tx", query).
ColumnExpr("tx.*").
ColumnExpr("address.hash as signer__hash").
Join("left join address on address.id = tx.signer_id").
Scan(ctx, &transaction)
return
}
func (tx *Tx) ByHeight(ctx context.Context, height types.Level, limit, offset int) (txs []storage.Tx, err error) {
query := tx.DB().NewSelect().Model((*storage.Tx)(nil)).
Where("tx.height = ?", height)
query = limitScope(query, limit)
if offset > 0 {
query = query.Offset(offset)
}
err = tx.DB().NewSelect().
TableExpr("(?) as tx", query).
ColumnExpr("tx.*").
ColumnExpr("address.hash as signer__hash").
Join("left join address on address.id = tx.signer_id").
Scan(ctx, &txs)
return
}
func (tx *Tx) Filter(ctx context.Context, fltrs storage.TxFilter) (txs []storage.Tx, err error) {
query := tx.DB().NewSelect().Model(&txs).Relation("Signer")
query = txFilter(query, fltrs)
err = query.Scan(ctx)
return
}
func (tx *Tx) ByAddress(ctx context.Context, addressId uint64, fltrs storage.TxFilter) (txs []storage.Tx, err error) {
query := tx.DB().NewSelect().
Model(&txs).
Where("signer_id = ?", addressId).
Relation("Signer")
query = txFilter(query, fltrs)
err = query.Scan(ctx)
return txs, err
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// Validator -
type Validator struct {
*postgres.Table[*storage.Validator]
}
// NewValidator -
func NewValidator(db *postgres.Storage) *Validator {
return &Validator{
Table: postgres.NewTable[*storage.Validator](db.Connection()),
}
}
func (v *Validator) ListByPower(ctx context.Context, limit, offset int, order sdk.SortOrder) (validators []storage.Validator, err error) {
query := v.DB().NewSelect().
Model(&validators).
Offset(offset)
query = limitScope(query, limit)
query = sortScope(query, "power", order)
err = query.Scan(ctx)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IPrice interface {
storage.Table[*Price]
Series(ctx context.Context, currencyPair string, timeframe Timeframe) ([]Candle, error)
Last(ctx context.Context, currencyPair string) (Price, error)
All(ctx context.Context, limit, offset int) ([]Price, error)
}
type Price struct {
bun.BaseModel `bun:"price" comment:"Table with currency prices"`
CurrencyPair string `bun:"currency_pair,pk,notnull" comment:"Currency pair"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of price event"`
Price decimal.Decimal `bun:"price,type:numeric" comment:"Price of the asset"`
}
// TableName -
func (Price) TableName() string {
return "price"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"encoding/hex"
"github.com/celenium-io/astria-indexer/pkg/types"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IRollup interface {
sdk.Table[*Rollup]
ActionsByHeight(ctx context.Context, height types.Level, limit, offset int) ([]RollupAction, error)
CountActionsByHeight(ctx context.Context, height types.Level) (int64, error)
ActionsByTxId(ctx context.Context, txId uint64, limit, offset int) ([]RollupAction, error)
CountActionsByTxId(ctx context.Context, txId uint64) (int64, error)
ByHash(ctx context.Context, hash []byte) (Rollup, error)
Addresses(ctx context.Context, rollupId uint64, limit, offset int, sort sdk.SortOrder) ([]RollupAddress, error)
ListRollupsByAddress(ctx context.Context, addressId uint64, limit, offset int, sort sdk.SortOrder) ([]RollupAddress, error)
ListExt(ctx context.Context, fltrs RollupListFilter) ([]Rollup, error)
}
type Rollup struct {
bun.BaseModel `bun:"rollup" comment:"Table with rollups"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
AstriaId []byte `bun:"astria_id,unique:rollup_id" comment:"Astria rollup identity"`
FirstHeight types.Level `bun:"first_height" comment:"Block number of the first rollup occurrence"`
ActionsCount int64 `bun:"actions_count" comment:"Count of actions in which the rollup was involved"`
BridgeCount int64 `bun:"bridge_count" comment:"Count of connected bridges"`
Size int64 `bun:"size" comment:"Count bytes which was saved in the rollup"`
}
// TableName -
func (Rollup) TableName() string {
return "rollup"
}
func (r Rollup) String() string {
return hex.EncodeToString(r.AstriaId)
}
type RollupListFilter struct {
Limit int
Offset int
SortField string
SortOrder sdk.SortOrder
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"time"
"github.com/celenium-io/astria-indexer/internal/storage/types"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/uptrace/bun"
)
type RollupAction struct {
bun.BaseModel `bun:"rollup_action" comment:"Table with rollup actions"`
RollupId uint64 `bun:"rollup_id,pk" comment:"Rollup internal id"`
ActionId uint64 `bun:"action_id,pk" comment:"Action internal id"`
Time time.Time `bun:"time,notnull,pk" comment:"Action time"`
ActionType types.ActionType `bun:"action_type,type:action_type" comment:"Action type"`
Height pkgTypes.Level `bun:"height" comment:"Action block height"`
TxId uint64 `bun:"tx_id" comment:"Transaction internal id"`
Size int64 `bun:"size" comment:"Count bytes which was pushed to the rollup"`
Action *Action `bun:"rel:belongs-to,join:action_id=id"`
Rollup *Rollup `bun:"rel:belongs-to,join:rollup_id=id"`
Tx *Tx `bun:"rel:belongs-to,join:tx_id=id"`
}
func (RollupAction) TableName() string {
return "rollup_action"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"fmt"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/uptrace/bun"
)
type RollupAddress struct {
bun.BaseModel `bun:"rollup_address" comment:"Table with rollup addresses"`
RollupId uint64 `bun:"rollup_id,pk" comment:"Rollup internal id"`
AddressId uint64 `bun:"address_id,pk" comment:"Address internal id"`
Height types.Level `bun:"height" comment:"Block height of the first sequence action"`
Address *Address `bun:"rel:belongs-to,join:address_id=id"`
Rollup *Rollup `bun:"rel:belongs-to,join:rollup_id=id"`
}
func (RollupAddress) TableName() string {
return "rollup_address"
}
func (r RollupAddress) String() string {
if r.Address == nil || r.Rollup == nil {
return ""
}
return fmt.Sprintf("%s_%s", r.Address.String(), r.Rollup.String())
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IState interface {
storage.Table[*State]
ByName(ctx context.Context, name string) (State, error)
}
// State -
type State struct {
bun.BaseModel `bun:"state" comment:"Current indexer state"`
Id uint64 `bun:",pk,autoincrement" comment:"Unique internal identity" json:"id"`
Name string `bun:",unique:state_name" comment:"Indexer name" json:"name"`
LastHeight types.Level `bun:"last_height" comment:"Last block height" json:"height"`
LastHash []byte `bun:"last_hash" comment:"Last block hash" json:"hash"`
LastTime time.Time `bun:"last_time" comment:"Time of last block" json:"time"`
ChainId string `bun:"chain_id" comment:"Astria chain id" json:"chain_id"`
TotalTx int64 `bun:"total_tx" comment:"Transactions count" json:"tx"`
TotalAccounts int64 `bun:"total_accounts" comment:"Accounts count" json:"accounts"`
TotalRollups int64 `bun:"total_rollups" comment:"Rollups count" json:"rollups"`
TotalValidators int `bun:"total_validators" comment:"Validators count" json:"validators"`
TotalSupply decimal.Decimal `bun:"total_supply,type:numeric" comment:"Total supply" json:"supply"`
TotalBridges int64 `bun:"total_bridges" comment:"Count of bridges" json:"bridges"`
TotalBytes int64 `bun:"total_bytes" comment:"Total rollup bytes" json:"bytes"`
}
// TableName -
func (State) TableName() string {
return "state"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
"github.com/shopspring/decimal"
)
type Timeframe string
const (
TimeframeHour Timeframe = "hour"
TimeframeDay Timeframe = "day"
TimeframeWeek Timeframe = "week"
TimeframeMonth Timeframe = "month"
)
type TPS struct {
Low float64
High float64
Current float64
ChangeLastHourPct float64
}
type TxCountForLast24hItem struct {
Time time.Time `bun:"ts"`
TxCount int64 `bun:"tx_count"`
TPS float64 `bun:"tps"`
}
type SeriesRequest struct {
From time.Time
To time.Time
}
func NewSeriesRequest(from, to int64) (sr SeriesRequest) {
if from > 0 {
sr.From = time.Unix(from, 0).UTC()
}
if to > 0 {
sr.To = time.Unix(to, 0).UTC()
}
return
}
type SeriesItem struct {
Time time.Time `bun:"ts"`
Value string `bun:"value"`
Max string `bun:"max"`
Min string `bun:"min"`
}
const (
SeriesDataSize = "data_size"
SeriesTPS = "tps"
SeriesBPS = "bps"
SeriesRBPS = "rbps"
SeriesFee = "fee"
SeriesSupplyChange = "supply_change"
SeriesBlockTime = "block_time"
SeriesTxCount = "tx_count"
SeriesBytesInBlock = "bytes_in_block"
RollupSeriesActionsCount = "actions_count"
RollupSeriesSize = "size"
RollupSeriesAvgSize = "avg_size"
RollupSeriesMinSize = "min_size"
RollupSeriesMaxSize = "max_size"
)
type NetworkSummary struct {
DataSize int64 `bun:"data_size"`
TPS float64 `bun:"tps"`
BPS float64 `bun:"bps"`
RBPS float64 `bun:"rbps"`
Fee decimal.Decimal `bun:"fee"`
Supply decimal.Decimal `bun:"supply"`
BlockTime float64 `bun:"block_time"`
TxCount int64 `bun:"tx_count"`
BytesInBlock int64 `bun:"bytes_in_block"`
}
type NetworkSummaryWithChange struct {
DataSize int64 `bun:"data_size"`
DataSizePct float64 `bun:"data_size_pct"`
TPS float64 `bun:"tps"`
TPSPct float64 `bun:"tps_pct"`
BPS float64 `bun:"bps"`
BPSPct float64 `bun:"bps_pct"`
RBPS float64 `bun:"rbps"`
RBPSPct float64 `bun:"rbps_pct"`
BlockTime float64 `bun:"block_time"`
BlockTimePct float64 `bun:"block_time_pct"`
TxCount int64 `bun:"tx_count"`
TxCountPct float64 `bun:"tx_count_pct"`
BytesInBlock int64 `bun:"bytes_in_block"`
BytesInBlockPct float64 `bun:"bytes_in_block_pct"`
}
type RollupSummary struct {
ActionsCount int64 `bun:"actions_count"`
Size int64 `bun:"size"`
AvgSize int64 `bun:"avg_size"`
MinSize int64 `bun:"min_size"`
MaxSize int64 `bun:"max_size"`
}
type FeeSummary struct {
Asset string `bun:"asset"`
Amount string `bun:"amount"`
MinAmount string `bun:"min_amount"`
MaxAmount string `bun:"max_amount"`
FeeCount int64 `bun:"fee_count"`
}
type TokenTransferDistributionItem struct {
Asset string `bun:"asset"`
Amount string `bun:"amount"`
TransfersCount int64 `bun:"transfers_count"`
}
type Candle struct {
Time time.Time `bun:"time"`
Open decimal.Decimal `bun:"open"`
Close decimal.Decimal `bun:"close"`
High decimal.Decimal `bun:"high"`
Low decimal.Decimal `bun:"low"`
CurrencyPair string `bun:"currency_pair"`
}
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IStats interface {
Summary(ctx context.Context) (NetworkSummary, error)
SummaryTimeframe(ctx context.Context, timeframe Timeframe) (NetworkSummaryWithChange, error)
Series(ctx context.Context, timeframe Timeframe, name string, req SeriesRequest) ([]SeriesItem, error)
RollupSeries(ctx context.Context, rollupId uint64, timeframe Timeframe, name string, req SeriesRequest) ([]SeriesItem, error)
FeeSummary(ctx context.Context) ([]FeeSummary, error)
TokenTransferDistribution(ctx context.Context, limit int) ([]TokenTransferDistributionItem, error)
ActiveAddressesCount(ctx context.Context) (int64, error)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type ITransfer interface {
storage.Table[*Transfer]
}
type Transfer struct {
bun.BaseModel `bun:"transfer" comment:"Table with asset transfers"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Height pkgTypes.Level `bun:"height,notnull" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
Asset string `bun:"asset" comment:"Transfer asset"`
Amount decimal.Decimal `bun:"amount,type:numeric" comment:"Transfer amount"`
SourceId uint64 `bun:"src_id" comment:"Who made transfer"`
DestinationId uint64 `bun:"dest_id" comment:"Who receive transfer"`
Source *Address `bun:"rel:belongs-to"`
Destination *Address `bun:"rel:belongs-to"`
}
func (Transfer) TableName() string {
return "transfer"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type ITx interface {
storage.Table[*Tx]
ByHash(ctx context.Context, hash []byte) (Tx, error)
ByHeight(ctx context.Context, height pkgTypes.Level, limit, offset int) ([]Tx, error)
ByAddress(ctx context.Context, addressId uint64, fltrs TxFilter) ([]Tx, error)
Filter(ctx context.Context, fltrs TxFilter) ([]Tx, error)
}
type TxFilter struct {
Limit int
Offset int
Sort storage.SortOrder
Status []string
ActionTypes types.ActionTypeMask
Height uint64
TimeFrom time.Time
TimeTo time.Time
WithActions bool
}
// Tx -
type Tx struct {
bun.BaseModel `bun:"tx" comment:"Table with transactions"`
Id uint64 `bun:"id,autoincrement,pk,notnull" comment:"Unique internal id"`
Height pkgTypes.Level `bun:",notnull" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
Position int64 `bun:"position" comment:"Position in block"`
ActionsCount int64 `bun:"actions_count" comment:"Actions count in transaction"`
Status types.Status `bun:"status,type:status" comment:"Transaction status"`
Error string `bun:"error,type:text" comment:"Error string if failed"`
Codespace string `bun:"codespace,type:text" comment:"Codespace"`
SignerId uint64 `bun:"signer_id" comment:"Signer internal identity"`
ActionTypes types.Bits `bun:"action_types" comment:"Bit mask for action types contained in tx"`
Nonce uint32 `bun:"nonce" comment:"Nonce"`
Hash []byte `bun:"hash" comment:"Transaction hash"`
Signature []byte `bun:"signature" comment:"Signature"`
Actions []Action `bun:"rel:has-many,join:id=tx_id"`
Signer *Address `bun:"rel:belongs-to"`
BytesSize int64 `bun:"-"`
}
// TableName -
func (Tx) TableName() string {
return "tx"
}
// Code generated by go-enum DO NOT EDIT.
// Version: 0.5.7
// Revision: bf63e108589bbd2327b13ec2c5da532aad234029
// Build Date: 2023-07-25T23:27:55Z
// Built By: goreleaser
package types
import (
"database/sql/driver"
"errors"
"fmt"
"strings"
)
const (
// ActionTypeTransfer is a ActionType of type transfer.
ActionTypeTransfer ActionType = "transfer"
// ActionTypeRollupDataSubmission is a ActionType of type rollup_data_submission.
ActionTypeRollupDataSubmission ActionType = "rollup_data_submission"
// ActionTypeValidatorUpdate is a ActionType of type validator_update.
ActionTypeValidatorUpdate ActionType = "validator_update"
// ActionTypeSudoAddressChange is a ActionType of type sudo_address_change.
ActionTypeSudoAddressChange ActionType = "sudo_address_change"
// ActionTypeIbcRelay is a ActionType of type ibc_relay.
ActionTypeIbcRelay ActionType = "ibc_relay"
// ActionTypeIcs20Withdrawal is a ActionType of type ics20_withdrawal.
ActionTypeIcs20Withdrawal ActionType = "ics20_withdrawal"
// ActionTypeIbcRelayerChange is a ActionType of type ibc_relayer_change.
ActionTypeIbcRelayerChange ActionType = "ibc_relayer_change"
// ActionTypeFeeAssetChange is a ActionType of type fee_asset_change.
ActionTypeFeeAssetChange ActionType = "fee_asset_change"
// ActionTypeInitBridgeAccount is a ActionType of type init_bridge_account.
ActionTypeInitBridgeAccount ActionType = "init_bridge_account"
// ActionTypeBridgeLock is a ActionType of type bridge_lock.
ActionTypeBridgeLock ActionType = "bridge_lock"
// ActionTypeBridgeUnlock is a ActionType of type bridge_unlock.
ActionTypeBridgeUnlock ActionType = "bridge_unlock"
// ActionTypeBridgeSudoChangeAction is a ActionType of type bridge_sudo_change_action.
ActionTypeBridgeSudoChangeAction ActionType = "bridge_sudo_change_action"
// ActionTypeFeeChange is a ActionType of type fee_change.
ActionTypeFeeChange ActionType = "fee_change"
// ActionTypeIbcSudoChangeAction is a ActionType of type ibc_sudo_change_action.
ActionTypeIbcSudoChangeAction ActionType = "ibc_sudo_change_action"
// ActionTypeBridgeTransfer is a ActionType of type bridge_transfer.
ActionTypeBridgeTransfer ActionType = "bridge_transfer"
// ActionTypeRecoverIbcClient is a ActionType of type recover_ibc_client.
ActionTypeRecoverIbcClient ActionType = "recover_ibc_client"
// ActionTypeCurrencyPairsChange is a ActionType of type currency_pairs_change.
ActionTypeCurrencyPairsChange ActionType = "currency_pairs_change"
// ActionTypeMarketsChange is a ActionType of type markets_change.
ActionTypeMarketsChange ActionType = "markets_change"
)
var ErrInvalidActionType = fmt.Errorf("not a valid ActionType, try [%s]", strings.Join(_ActionTypeNames, ", "))
var _ActionTypeNames = []string{
string(ActionTypeTransfer),
string(ActionTypeRollupDataSubmission),
string(ActionTypeValidatorUpdate),
string(ActionTypeSudoAddressChange),
string(ActionTypeIbcRelay),
string(ActionTypeIcs20Withdrawal),
string(ActionTypeIbcRelayerChange),
string(ActionTypeFeeAssetChange),
string(ActionTypeInitBridgeAccount),
string(ActionTypeBridgeLock),
string(ActionTypeBridgeUnlock),
string(ActionTypeBridgeSudoChangeAction),
string(ActionTypeFeeChange),
string(ActionTypeIbcSudoChangeAction),
string(ActionTypeBridgeTransfer),
string(ActionTypeRecoverIbcClient),
string(ActionTypeCurrencyPairsChange),
string(ActionTypeMarketsChange),
}
// ActionTypeNames returns a list of possible string values of ActionType.
func ActionTypeNames() []string {
tmp := make([]string, len(_ActionTypeNames))
copy(tmp, _ActionTypeNames)
return tmp
}
// ActionTypeValues returns a list of the values for ActionType
func ActionTypeValues() []ActionType {
return []ActionType{
ActionTypeTransfer,
ActionTypeRollupDataSubmission,
ActionTypeValidatorUpdate,
ActionTypeSudoAddressChange,
ActionTypeIbcRelay,
ActionTypeIcs20Withdrawal,
ActionTypeIbcRelayerChange,
ActionTypeFeeAssetChange,
ActionTypeInitBridgeAccount,
ActionTypeBridgeLock,
ActionTypeBridgeUnlock,
ActionTypeBridgeSudoChangeAction,
ActionTypeFeeChange,
ActionTypeIbcSudoChangeAction,
ActionTypeBridgeTransfer,
ActionTypeRecoverIbcClient,
ActionTypeCurrencyPairsChange,
ActionTypeMarketsChange,
}
}
// String implements the Stringer interface.
func (x ActionType) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x ActionType) IsValid() bool {
_, err := ParseActionType(string(x))
return err == nil
}
var _ActionTypeValue = map[string]ActionType{
"transfer": ActionTypeTransfer,
"rollup_data_submission": ActionTypeRollupDataSubmission,
"validator_update": ActionTypeValidatorUpdate,
"sudo_address_change": ActionTypeSudoAddressChange,
"ibc_relay": ActionTypeIbcRelay,
"ics20_withdrawal": ActionTypeIcs20Withdrawal,
"ibc_relayer_change": ActionTypeIbcRelayerChange,
"fee_asset_change": ActionTypeFeeAssetChange,
"init_bridge_account": ActionTypeInitBridgeAccount,
"bridge_lock": ActionTypeBridgeLock,
"bridge_unlock": ActionTypeBridgeUnlock,
"bridge_sudo_change_action": ActionTypeBridgeSudoChangeAction,
"fee_change": ActionTypeFeeChange,
"ibc_sudo_change_action": ActionTypeIbcSudoChangeAction,
"bridge_transfer": ActionTypeBridgeTransfer,
"recover_ibc_client": ActionTypeRecoverIbcClient,
"currency_pairs_change": ActionTypeCurrencyPairsChange,
"markets_change": ActionTypeMarketsChange,
}
// ParseActionType attempts to convert a string to a ActionType.
func ParseActionType(name string) (ActionType, error) {
if x, ok := _ActionTypeValue[name]; ok {
return x, nil
}
return ActionType(""), fmt.Errorf("%s is %w", name, ErrInvalidActionType)
}
// MarshalText implements the text marshaller method.
func (x ActionType) MarshalText() ([]byte, error) {
return []byte(string(x)), nil
}
// UnmarshalText implements the text unmarshaller method.
func (x *ActionType) UnmarshalText(text []byte) error {
tmp, err := ParseActionType(string(text))
if err != nil {
return err
}
*x = tmp
return nil
}
var errActionTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *ActionType) Scan(value interface{}) (err error) {
if value == nil {
*x = ActionType("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseActionType(v)
case []byte:
*x, err = ParseActionType(string(v))
case ActionType:
*x = v
case *ActionType:
if v == nil {
return errActionTypeNilPtr
}
*x = *v
case *string:
if v == nil {
return errActionTypeNilPtr
}
*x, err = ParseActionType(*v)
default:
return errors.New("invalid type for ActionType")
}
return
}
// Value implements the driver Valuer interface.
func (x ActionType) Value() (driver.Value, error) {
return x.String(), nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package types
const (
ActionTypeTransferBits Bits = 1 << iota
ActionTypeRollupDataSubmissionBits
ActionTypeValidatorUpdateBits
ActionTypeSudoAddressChangeBits
ActionTypeIbcRelayBits
ActionTypeIcs20WithdrawalBits
ActionTypeIbcRelayerChangeBits
ActionTypeFeeAssetChangeBits
ActionTypeInitBridgeAccountBits
ActionTypeBridgeLockBits
ActionTypeBridgeUnlockBits
ActionTypeBridgeSudoChangeBits
ActionTypeFeeChangeBits
ActionTypeIbcSudoChangeBits
ActionTypeBridgeTransferBits
ActionTypeRecoverIbcClientBits
ActionTypeCurrencyPairsChangeBits
ActionTypeMarketsChangeBits
)
var (
actionTypesMap = map[ActionType]Bits{
ActionTypeIbcRelay: ActionTypeIbcRelayBits,
ActionTypeIcs20Withdrawal: ActionTypeIcs20WithdrawalBits,
ActionTypeRollupDataSubmission: ActionTypeRollupDataSubmissionBits,
ActionTypeSudoAddressChange: ActionTypeSudoAddressChangeBits,
ActionTypeTransfer: ActionTypeTransferBits,
ActionTypeValidatorUpdate: ActionTypeValidatorUpdateBits,
ActionTypeBridgeLock: ActionTypeBridgeLockBits,
ActionTypeFeeAssetChange: ActionTypeFeeAssetChangeBits,
ActionTypeInitBridgeAccount: ActionTypeInitBridgeAccountBits,
ActionTypeIbcRelayerChange: ActionTypeIbcRelayerChangeBits,
ActionTypeBridgeUnlock: ActionTypeBridgeUnlockBits,
ActionTypeBridgeSudoChangeAction: ActionTypeBridgeSudoChangeBits,
ActionTypeFeeChange: ActionTypeFeeChangeBits,
ActionTypeIbcSudoChangeAction: ActionTypeIbcSudoChangeBits,
ActionTypeBridgeTransfer: ActionTypeBridgeTransferBits,
ActionTypeRecoverIbcClient: ActionTypeRecoverIbcClientBits,
ActionTypeCurrencyPairsChange: ActionTypeCurrencyPairsChangeBits,
ActionTypeMarketsChange: ActionTypeMarketsChangeBits,
}
)
type ActionTypeMask struct {
Bits
}
func NewActionTypeMask(vals ...string) ActionTypeMask {
mask := ActionTypeMask{Bits: 0}
for i := range vals {
switch vals[i] {
case string(ActionTypeIbcRelay):
mask.Set(ActionTypeIbcRelayBits)
case string(ActionTypeIcs20Withdrawal):
mask.Set(ActionTypeIcs20WithdrawalBits)
case string(ActionTypeRollupDataSubmission):
mask.Set(ActionTypeRollupDataSubmissionBits)
case string(ActionTypeSudoAddressChange):
mask.Set(ActionTypeSudoAddressChangeBits)
case string(ActionTypeTransfer):
mask.Set(ActionTypeTransferBits)
case string(ActionTypeValidatorUpdate):
mask.Set(ActionTypeValidatorUpdateBits)
case string(ActionTypeBridgeLock):
mask.Set(ActionTypeBridgeLockBits)
case string(ActionTypeFeeAssetChange):
mask.Set(ActionTypeFeeAssetChangeBits)
case string(ActionTypeIbcRelayerChange):
mask.Set(ActionTypeIbcRelayerChangeBits)
case string(ActionTypeInitBridgeAccount):
mask.Set(ActionTypeInitBridgeAccountBits)
case string(ActionTypeBridgeUnlock):
mask.Set(ActionTypeBridgeUnlockBits)
case string(ActionTypeBridgeSudoChangeAction):
mask.Set(ActionTypeBridgeSudoChangeBits)
case string(ActionTypeFeeChange):
mask.Set(ActionTypeFeeChangeBits)
case string(ActionTypeIbcSudoChangeAction):
mask.Set(ActionTypeIbcSudoChangeBits)
case string(ActionTypeBridgeTransfer):
mask.Set(ActionTypeBridgeTransferBits)
case string(ActionTypeRecoverIbcClient):
mask.Set(ActionTypeRecoverIbcClientBits)
case string(ActionTypeCurrencyPairsChange):
mask.Set(ActionTypeCurrencyPairsChangeBits)
case string(ActionTypeMarketsChange):
mask.Set(ActionTypeMarketsChangeBits)
}
}
return mask
}
func NewActionTypeMaskBits(bits Bits) ActionTypeMask {
return ActionTypeMask{Bits: bits}
}
func (mask ActionTypeMask) Strings() []string {
if mask.Bits == 0 {
return []string{}
}
vals := make([]string, 0)
for val := ActionTypeTransferBits; val <= ActionTypeMarketsChangeBits; val <<= 1 {
if !mask.Has(val) {
continue
}
switch val {
case ActionTypeIbcRelayBits:
vals = append(vals, string(ActionTypeIbcRelay))
case ActionTypeIcs20WithdrawalBits:
vals = append(vals, string(ActionTypeIcs20Withdrawal))
case ActionTypeRollupDataSubmissionBits:
vals = append(vals, string(ActionTypeRollupDataSubmission))
case ActionTypeSudoAddressChangeBits:
vals = append(vals, string(ActionTypeSudoAddressChange))
case ActionTypeTransferBits:
vals = append(vals, string(ActionTypeTransfer))
case ActionTypeValidatorUpdateBits:
vals = append(vals, string(ActionTypeValidatorUpdate))
case ActionTypeBridgeLockBits:
vals = append(vals, string(ActionTypeBridgeLock))
case ActionTypeFeeAssetChangeBits:
vals = append(vals, string(ActionTypeFeeAssetChange))
case ActionTypeIbcRelayerChangeBits:
vals = append(vals, string(ActionTypeIbcRelayerChange))
case ActionTypeInitBridgeAccountBits:
vals = append(vals, string(ActionTypeInitBridgeAccount))
case ActionTypeBridgeSudoChangeBits:
vals = append(vals, string(ActionTypeBridgeSudoChangeAction))
case ActionTypeBridgeUnlockBits:
vals = append(vals, string(ActionTypeBridgeUnlock))
case ActionTypeFeeChangeBits:
vals = append(vals, string(ActionTypeFeeChange))
case ActionTypeIbcSudoChangeBits:
vals = append(vals, string(ActionTypeIbcSudoChangeAction))
case ActionTypeBridgeTransferBits:
vals = append(vals, string(ActionTypeBridgeTransfer))
case ActionTypeRecoverIbcClientBits:
vals = append(vals, string(ActionTypeRecoverIbcClient))
case ActionTypeCurrencyPairsChangeBits:
vals = append(vals, string(ActionTypeCurrencyPairsChange))
case ActionTypeMarketsChangeBits:
vals = append(vals, string(ActionTypeMarketsChange))
}
}
return vals
}
func (mask ActionTypeMask) Empty() bool {
return mask.Bits == 0
}
func (mask *ActionTypeMask) SetType(typ ActionType) {
value, ok := actionTypesMap[typ]
if !ok {
return
}
mask.Set(value)
}
// Code generated by go-enum DO NOT EDIT.
// Version: 0.5.7
// Revision: bf63e108589bbd2327b13ec2c5da532aad234029
// Build Date: 2023-07-25T23:27:55Z
// Built By: goreleaser
package types
import (
"database/sql/driver"
"errors"
"fmt"
"strings"
)
const (
// AppCategoryUncategorized is a AppCategory of type uncategorized.
AppCategoryUncategorized AppCategory = "uncategorized"
// AppCategoryFinance is a AppCategory of type finance.
AppCategoryFinance AppCategory = "finance"
// AppCategoryGaming is a AppCategory of type gaming.
AppCategoryGaming AppCategory = "gaming"
// AppCategoryNft is a AppCategory of type nft.
AppCategoryNft AppCategory = "nft"
// AppCategorySocial is a AppCategory of type social.
AppCategorySocial AppCategory = "social"
)
var ErrInvalidAppCategory = fmt.Errorf("not a valid AppCategory, try [%s]", strings.Join(_AppCategoryNames, ", "))
var _AppCategoryNames = []string{
string(AppCategoryUncategorized),
string(AppCategoryFinance),
string(AppCategoryGaming),
string(AppCategoryNft),
string(AppCategorySocial),
}
// AppCategoryNames returns a list of possible string values of AppCategory.
func AppCategoryNames() []string {
tmp := make([]string, len(_AppCategoryNames))
copy(tmp, _AppCategoryNames)
return tmp
}
// AppCategoryValues returns a list of the values for AppCategory
func AppCategoryValues() []AppCategory {
return []AppCategory{
AppCategoryUncategorized,
AppCategoryFinance,
AppCategoryGaming,
AppCategoryNft,
AppCategorySocial,
}
}
// String implements the Stringer interface.
func (x AppCategory) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x AppCategory) IsValid() bool {
_, err := ParseAppCategory(string(x))
return err == nil
}
var _AppCategoryValue = map[string]AppCategory{
"uncategorized": AppCategoryUncategorized,
"finance": AppCategoryFinance,
"gaming": AppCategoryGaming,
"nft": AppCategoryNft,
"social": AppCategorySocial,
}
// ParseAppCategory attempts to convert a string to a AppCategory.
func ParseAppCategory(name string) (AppCategory, error) {
if x, ok := _AppCategoryValue[name]; ok {
return x, nil
}
return AppCategory(""), fmt.Errorf("%s is %w", name, ErrInvalidAppCategory)
}
// MarshalText implements the text marshaller method.
func (x AppCategory) MarshalText() ([]byte, error) {
return []byte(string(x)), nil
}
// UnmarshalText implements the text unmarshaller method.
func (x *AppCategory) UnmarshalText(text []byte) error {
tmp, err := ParseAppCategory(string(text))
if err != nil {
return err
}
*x = tmp
return nil
}
var errAppCategoryNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *AppCategory) Scan(value interface{}) (err error) {
if value == nil {
*x = AppCategory("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseAppCategory(v)
case []byte:
*x, err = ParseAppCategory(string(v))
case AppCategory:
*x = v
case *AppCategory:
if v == nil {
return errAppCategoryNilPtr
}
*x = *v
case *string:
if v == nil {
return errAppCategoryNilPtr
}
*x, err = ParseAppCategory(*v)
default:
return errors.New("invalid type for AppCategory")
}
return
}
// Value implements the driver Valuer interface.
func (x AppCategory) Value() (driver.Value, error) {
return x.String(), nil
}
const (
// AppTypeSovereign is a AppType of type sovereign.
AppTypeSovereign AppType = "sovereign"
// AppTypeSettled is a AppType of type settled.
AppTypeSettled AppType = "settled"
)
var ErrInvalidAppType = fmt.Errorf("not a valid AppType, try [%s]", strings.Join(_AppTypeNames, ", "))
var _AppTypeNames = []string{
string(AppTypeSovereign),
string(AppTypeSettled),
}
// AppTypeNames returns a list of possible string values of AppType.
func AppTypeNames() []string {
tmp := make([]string, len(_AppTypeNames))
copy(tmp, _AppTypeNames)
return tmp
}
// AppTypeValues returns a list of the values for AppType
func AppTypeValues() []AppType {
return []AppType{
AppTypeSovereign,
AppTypeSettled,
}
}
// String implements the Stringer interface.
func (x AppType) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x AppType) IsValid() bool {
_, err := ParseAppType(string(x))
return err == nil
}
var _AppTypeValue = map[string]AppType{
"sovereign": AppTypeSovereign,
"settled": AppTypeSettled,
}
// ParseAppType attempts to convert a string to a AppType.
func ParseAppType(name string) (AppType, error) {
if x, ok := _AppTypeValue[name]; ok {
return x, nil
}
return AppType(""), fmt.Errorf("%s is %w", name, ErrInvalidAppType)
}
// MarshalText implements the text marshaller method.
func (x AppType) MarshalText() ([]byte, error) {
return []byte(string(x)), nil
}
// UnmarshalText implements the text unmarshaller method.
func (x *AppType) UnmarshalText(text []byte) error {
tmp, err := ParseAppType(string(text))
if err != nil {
return err
}
*x = tmp
return nil
}
var errAppTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *AppType) Scan(value interface{}) (err error) {
if value == nil {
*x = AppType("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseAppType(v)
case []byte:
*x, err = ParseAppType(string(v))
case AppType:
*x = v
case *AppType:
if v == nil {
return errAppTypeNilPtr
}
*x = *v
case *string:
if v == nil {
return errAppTypeNilPtr
}
*x, err = ParseAppType(*v)
default:
return errors.New("invalid type for AppType")
}
return
}
// Value implements the driver Valuer interface.
func (x AppType) Value() (driver.Value, error) {
return x.String(), nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package types
type Bits uint64
func (b *Bits) Set(flag Bits) { *b |= flag }
func (b *Bits) Clear(flag Bits) { *b &^= flag }
func (b *Bits) Toggle(flag Bits) { *b ^= flag }
func (b Bits) Has(flag Bits) bool { return b&flag != 0 }
// Code generated by go-enum DO NOT EDIT.
// Version: 0.5.7
// Revision: bf63e108589bbd2327b13ec2c5da532aad234029
// Build Date: 2023-07-25T23:27:55Z
// Built By: goreleaser
package types
import (
"database/sql/driver"
"errors"
"fmt"
)
const (
// ModuleNameBlock is a ModuleName of type block.
ModuleNameBlock ModuleName = "block"
// ModuleNameEvidence is a ModuleName of type evidence.
ModuleNameEvidence ModuleName = "evidence"
// ModuleNameValidator is a ModuleName of type validator.
ModuleNameValidator ModuleName = "validator"
// ModuleNameVersion is a ModuleName of type version.
ModuleNameVersion ModuleName = "version"
// ModuleNameGeneric is a ModuleName of type generic.
ModuleNameGeneric ModuleName = "generic"
)
var ErrInvalidModuleName = errors.New("not a valid ModuleName")
// ModuleNameValues returns a list of the values for ModuleName
func ModuleNameValues() []ModuleName {
return []ModuleName{
ModuleNameBlock,
ModuleNameEvidence,
ModuleNameValidator,
ModuleNameVersion,
ModuleNameGeneric,
}
}
// String implements the Stringer interface.
func (x ModuleName) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x ModuleName) IsValid() bool {
_, err := ParseModuleName(string(x))
return err == nil
}
var _ModuleNameValue = map[string]ModuleName{
"block": ModuleNameBlock,
"evidence": ModuleNameEvidence,
"validator": ModuleNameValidator,
"version": ModuleNameVersion,
"generic": ModuleNameGeneric,
}
// ParseModuleName attempts to convert a string to a ModuleName.
func ParseModuleName(name string) (ModuleName, error) {
if x, ok := _ModuleNameValue[name]; ok {
return x, nil
}
return ModuleName(""), fmt.Errorf("%s is %w", name, ErrInvalidModuleName)
}
// MarshalText implements the text marshaller method.
func (x ModuleName) MarshalText() ([]byte, error) {
return []byte(string(x)), nil
}
// UnmarshalText implements the text unmarshaller method.
func (x *ModuleName) UnmarshalText(text []byte) error {
tmp, err := ParseModuleName(string(text))
if err != nil {
return err
}
*x = tmp
return nil
}
var errModuleNameNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *ModuleName) Scan(value interface{}) (err error) {
if value == nil {
*x = ModuleName("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseModuleName(v)
case []byte:
*x, err = ParseModuleName(string(v))
case ModuleName:
*x = v
case *ModuleName:
if v == nil {
return errModuleNameNilPtr
}
*x = *v
case *string:
if v == nil {
return errModuleNameNilPtr
}
*x, err = ParseModuleName(*v)
default:
return errors.New("invalid type for ModuleName")
}
return
}
// Value implements the driver Valuer interface.
func (x ModuleName) Value() (driver.Value, error) {
return x.String(), nil
}
// Code generated by go-enum DO NOT EDIT.
// Version: 0.5.7
// Revision: bf63e108589bbd2327b13ec2c5da532aad234029
// Build Date: 2023-07-25T23:27:55Z
// Built By: goreleaser
package types
import (
"database/sql/driver"
"errors"
"fmt"
"strings"
)
const (
// StatusSuccess is a Status of type success.
StatusSuccess Status = "success"
// StatusFailed is a Status of type failed.
StatusFailed Status = "failed"
)
var ErrInvalidStatus = fmt.Errorf("not a valid Status, try [%s]", strings.Join(_StatusNames, ", "))
var _StatusNames = []string{
string(StatusSuccess),
string(StatusFailed),
}
// StatusNames returns a list of possible string values of Status.
func StatusNames() []string {
tmp := make([]string, len(_StatusNames))
copy(tmp, _StatusNames)
return tmp
}
// StatusValues returns a list of the values for Status
func StatusValues() []Status {
return []Status{
StatusSuccess,
StatusFailed,
}
}
// String implements the Stringer interface.
func (x Status) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x Status) IsValid() bool {
_, err := ParseStatus(string(x))
return err == nil
}
var _StatusValue = map[string]Status{
"success": StatusSuccess,
"failed": StatusFailed,
}
// ParseStatus attempts to convert a string to a Status.
func ParseStatus(name string) (Status, error) {
if x, ok := _StatusValue[name]; ok {
return x, nil
}
return Status(""), fmt.Errorf("%s is %w", name, ErrInvalidStatus)
}
// MarshalText implements the text marshaller method.
func (x Status) MarshalText() ([]byte, error) {
return []byte(string(x)), nil
}
// UnmarshalText implements the text unmarshaller method.
func (x *Status) UnmarshalText(text []byte) error {
tmp, err := ParseStatus(string(text))
if err != nil {
return err
}
*x = tmp
return nil
}
var errStatusNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *Status) Scan(value interface{}) (err error) {
if value == nil {
*x = Status("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseStatus(v)
case []byte:
*x, err = ParseStatus(string(v))
case Status:
*x = v
case *Status:
if v == nil {
return errStatusNilPtr
}
*x = *v
case *string:
if v == nil {
return errStatusNilPtr
}
*x, err = ParseStatus(*v)
default:
return errors.New("invalid type for Status")
}
return
}
// Value implements the driver Valuer interface.
func (x Status) Value() (driver.Value, error) {
return x.String(), nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IValidator interface {
sdk.Table[*Validator]
ListByPower(ctx context.Context, limit, offset int, order sdk.SortOrder) ([]Validator, error)
}
type Validator struct {
bun.BaseModel `bun:"validator" comment:"Table with validators"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Address string `bun:"address,unique:validator_address,type:text" comment:"Validator address"`
PubkeyType string `bun:"pubkey_type,type:text" comment:"Validator public key type"`
PubKey []byte `bun:"pubkey,unique:validator_pubkey" comment:"Validator public key"`
Name string `bun:"name,type:text" comment:"Human-readable name for the validator"`
Power decimal.Decimal `bun:"power,type:numeric" comment:"Validator power"`
Height pkgTypes.Level `bun:"height" comment:"Height when validator was created"`
}
func (Validator) TableName() string {
return "validator"
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package testsuite
import (
"encoding/base64"
"time"
"github.com/celenium-io/astria-indexer/pkg/types"
tmTypes "github.com/cometbft/cometbft/types"
)
func EmptyBlock() (types.BlockData, time.Time) {
return CreateTestBlock(types.ResponseDeliverTx{}, false)
}
var txs = []string{
"CiDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ==",
"EiDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ==",
"GmYKIFzfzCuQeY5A3ruKkHkUwtvLBr5FtNTSA5RaeD1h/MuuCiAuH0tPTyRhm6lcyjNE3BRnGPaHrNbdEnY6NZJ1+Q/L9wogLh9LT08kYZupXMozRNwUZxj2h6zW3RJ2OjWSdfkPy/c=",
"CkCBcBs4ojg/IV1xLhFs5RNGSMwrlPQTuNSZB2WpfR1HD8AQF72Vdr/VhCKn2ppL4KBGgiKp+FqzchZdUIqTCy8IEiD1A4vkUMma1i1j6Mq95eIjQWn290avEMhbIEaK5psMmRq7AQovL2FzdHJpYS5wcm90b2NvbC50cmFuc2FjdGlvbi52MS5UcmFuc2FjdGlvbkJvZHkShwEKEBIOYXN0cmlhLWR1c2stMTESc2JxCi8SLWFzdHJpYTF5cWRqbm5tcnA3dzV5Z3dqMGRrbGRzZ3pqaHY1dmNha3A3eWV1ORIGCICU69wDGgRucmlhIgRucmlhKioweDlkMENFQzdCRUI5NDhBYjA0NmU4YjY0RTlhYTZDYzliNzMxQTk2MTM=",
}
func CreateTestBlock(tx types.ResponseDeliverTx, withTxs bool) (types.BlockData, time.Time) {
now := time.Now()
headerBlock := types.Block{
Header: types.Header{
Time: now,
},
Data: types.Data{
Txs: make(tmTypes.Txs, 0),
},
}
var txResults = make([]*types.ResponseDeliverTx, 0)
if withTxs {
for i := 0; i < len(txs); i++ {
raw, _ := base64.StdEncoding.DecodeString(txs[i])
txResults = append(txResults, &tx)
headerBlock.Data.Txs = append(headerBlock.Data.Txs, raw)
}
}
block := types.BlockData{
ResultBlock: types.ResultBlock{
Block: &headerBlock,
},
ResultBlockResults: types.ResultBlockResults{
TxsResults: txResults,
},
}
return block, now
}
func CreateBlockWithTxs(tx types.ResponseDeliverTx, txData []byte, count int) (types.BlockData, time.Time) {
now := time.Now()
headerBlock := types.Block{
Header: types.Header{
Time: now,
},
Data: types.Data{
Txs: make(tmTypes.Txs, count),
},
}
var txResults = make([]*types.ResponseDeliverTx, count)
for i := 0; i < count; i++ {
txResults[i] = &tx
headerBlock.Data.Txs[i] = txData
}
block := types.BlockData{
ResultBlock: types.ResultBlock{
Block: &headerBlock,
},
ResultBlockResults: types.ResultBlockResults{
TxsResults: txResults,
},
}
return block, now
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package testsuite
import (
"crypto/rand"
"encoding/hex"
"github.com/celenium-io/astria-indexer/internal/astria"
)
// Ptr - returns pointer of value for testing purpose
//
// one := Ptr(1) // one is pointer to int
func Ptr[T any](t T) *T {
return &t
}
// MustHexDecode - returns decoded hex string, if it can't decode throws panic
//
// data := MustHexDecode("deadbeaf")
func MustHexDecode(s string) []byte {
data, err := hex.DecodeString(s)
if err != nil {
panic(err)
}
return data
}
// RandomHash - returns random hash with fixed size
func RandomHash(length int) []byte {
hash := make([]byte, length)
_, _ = rand.Read(hash)
return hash
}
// RandomAddress - returns random address
func RandomAddress() string {
hash := make([]byte, 20)
_, _ = rand.Read(hash)
val, _ := astria.EncodeAddress(hash)
return val
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package config
import (
"github.com/celenium-io/astria-indexer/internal/profiler"
"github.com/dipdup-net/go-lib/config"
)
type Config struct {
config.Config `yaml:",inline"`
LogLevel string `validate:"omitempty,oneof=debug trace info warn error fatal panic" yaml:"log_level"`
Indexer Indexer `yaml:"indexer"`
Profiler *profiler.Config `validate:"omitempty" yaml:"profiler"`
}
type Indexer struct {
Name string `validate:"omitempty" yaml:"name"`
ThreadsCount uint32 `validate:"omitempty,min=1" yaml:"threads_count"`
StartLevel int64 `validate:"omitempty" yaml:"start_level"`
BlockPeriod int64 `validate:"omitempty" yaml:"block_period"`
ScriptsDir string `validate:"omitempty,dir" yaml:"scripts_dir"`
}
// Substitute -
func (c *Config) Substitute() error {
if err := c.Config.Substitute(); err != nil {
return err
}
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
"encoding/base64"
"encoding/json"
"fmt"
"time"
primitive "buf.build/gen/go/astria/primitives/protocolbuffers/go/astria/primitive/v1"
astria "buf.build/gen/go/astria/protocol-apis/protocolbuffers/go/astria/protocol/transaction/v1"
v21 "buf.build/gen/go/astria/vendored/protocolbuffers/go/connect/marketmap/v2"
"github.com/celenium-io/astria-indexer/internal/currency"
"github.com/celenium-io/astria-indexer/internal/storage"
storageTypes "github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
"github.com/shopspring/decimal"
)
func parseActions(height types.Level, blockTime time.Time, from string, tx *DecodedTx, ctx *Context) ([]storage.Action, error) {
var (
rawActions = tx.UnsignedTx.GetActions()
actions = make([]storage.Action, len(rawActions))
)
for i := range rawActions {
if tx.UnsignedTx.Actions[i].Value == nil {
return nil, errors.Errorf("nil action")
}
actions[i].Height = height
actions[i].Time = blockTime
actions[i].Position = int64(i)
actions[i].Addresses = make([]*storage.AddressAction, 0)
actions[i].BalanceUpdates = make([]storage.BalanceUpdate, 0)
var (
err error
)
switch val := rawActions[i].GetValue().(type) {
case *astria.Action_Ibc:
tx.ActionTypes.Set(storageTypes.ActionTypeIbcRelayBits)
err = parseIbcAction(val, ctx, &actions[i])
case *astria.Action_Ics20Withdrawal:
tx.ActionTypes.Set(storageTypes.ActionTypeIcs20WithdrawalBits)
err = parseIcs20Withdrawal(val, from, height, ctx, &actions[i])
case *astria.Action_RollupDataSubmission:
tx.ActionTypes.Set(storageTypes.ActionTypeRollupDataSubmissionBits)
err = parseRollupDataSubmission(val, from, height, ctx, &actions[i])
case *astria.Action_SudoAddressChange:
tx.ActionTypes.Set(storageTypes.ActionTypeSudoAddressChangeBits)
err = parseSudoAddressChangeAction(val, ctx, &actions[i])
case *astria.Action_Transfer:
tx.ActionTypes.Set(storageTypes.ActionTypeTransferBits)
err = parseTransferAction(val, from, height, ctx, &actions[i])
case *astria.Action_ValidatorUpdate:
tx.ActionTypes.Set(storageTypes.ActionTypeValidatorUpdateBits)
err = parseValidatorUpdateAction(val, height, ctx, &actions[i])
case *astria.Action_BridgeLock:
tx.ActionTypes.Set(storageTypes.ActionTypeBridgeLockBits)
err = parseBridgeLock(val, from, height, ctx, &actions[i])
case *astria.Action_FeeAssetChange:
tx.ActionTypes.Set(storageTypes.ActionTypeFeeAssetChangeBits)
err = parseFeeAssetChange(val, &actions[i])
case *astria.Action_IbcRelayerChange:
tx.ActionTypes.Set(storageTypes.ActionTypeIbcRelayerChangeBits)
err = parseIbcRelayerChange(val, height, ctx, &actions[i])
case *astria.Action_InitBridgeAccount:
tx.ActionTypes.Set(storageTypes.ActionTypeInitBridgeAccountBits)
err = parseInitBridgeAccount(val, from, height, ctx, &actions[i])
case *astria.Action_BridgeSudoChange:
tx.ActionTypes.Set(storageTypes.ActionTypeBridgeSudoChangeBits)
err = parseBridgeSudoChange(val, height, ctx, &actions[i])
case *astria.Action_BridgeUnlock:
tx.ActionTypes.Set(storageTypes.ActionTypeBridgeUnlockBits)
err = parseBridgeUnlock(val, from, height, ctx, &actions[i])
case *astria.Action_FeeChange:
tx.ActionTypes.Set(storageTypes.ActionTypeFeeChangeBits)
err = parseFeeChange(val, ctx, &actions[i])
case *astria.Action_IbcSudoChange:
tx.ActionTypes.Set(storageTypes.ActionTypeIbcSudoChangeBits)
err = parseIbcSudoChangeAction(val, ctx, &actions[i])
case *astria.Action_BridgeTransfer:
tx.ActionTypes.Set(storageTypes.ActionTypeBridgeTransferBits)
err = parseBridgeTransfer(val, height, ctx, &actions[i])
case *astria.Action_RecoverIbcClient:
tx.ActionTypes.Set(storageTypes.ActionTypeRecoverIbcClientBits)
err = parseRecoverIbcClient(val, &actions[i])
case *astria.Action_CurrencyPairsChange:
tx.ActionTypes.Set(storageTypes.ActionTypeCurrencyPairsChangeBits)
err = parseCurrencyPairsChange(val, &actions[i])
case *astria.Action_MarketsChange:
tx.ActionTypes.Set(storageTypes.ActionTypeMarketsChangeBits)
err = parseMarketsChange(val, ctx, &actions[i])
default:
return nil, errors.Errorf(
"unknown action type | position = %d | block = %d: %##v",
i, height, tx.Actions[i])
}
if err != nil {
return nil, err
}
if actionFee, ok := ctx.Fees[int64(i)]; ok {
actionFee.Height = height
actionFee.Time = blockTime
actionFee.Payer = &storage.Address{
Hash: from,
}
actions[i].Fee = actionFee
fromAmount := actionFee.Amount.Neg()
addr := ctx.Addresses.Set(from, height, fromAmount, actionFee.Asset, 0, 0)
actions[i].BalanceUpdates = append(actions[i].BalanceUpdates, storage.BalanceUpdate{
Address: addr,
Height: actions[i].Height,
Currency: actionFee.Asset,
Update: fromAmount,
})
to := ctx.Addresses.Set(ctx.Proposer, height, actionFee.Amount, actionFee.Asset, 0, 0)
actions[i].BalanceUpdates = append(actions[i].BalanceUpdates, storage.BalanceUpdate{
Address: to,
Height: actions[i].Height,
Currency: actionFee.Asset,
Update: actionFee.Amount,
})
}
if deposit, ok := ctx.Deposits[int64(i)]; ok {
deposit.Height = height
deposit.Time = blockTime
actions[i].Deposit = deposit
}
}
return actions, nil
}
func parseIbcAction(body *astria.Action_Ibc, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeIbcRelay
action.Data = make(map[string]any)
if body.Ibc != nil && body.Ibc.GetRawAction() != nil {
data := body.Ibc.GetRawAction().GetValue()
typ := body.Ibc.GetRawAction().GetTypeUrl()
action.Data["raw"] = base64.StdEncoding.EncodeToString(data)
action.Data["type"] = typ
if ctx.HasWriteAckError {
return nil
}
if err := parseIbcMessages(typ, data, action, ctx); err != nil {
return errors.Wrap(err, "parse ibc message")
}
}
return nil
}
func parseIcs20Withdrawal(body *astria.Action_Ics20Withdrawal, from string, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeIcs20Withdrawal
action.Data = make(map[string]any)
if body.Ics20Withdrawal != nil {
amount := uint128ToString(body.Ics20Withdrawal.GetAmount())
asset := body.Ics20Withdrawal.GetDenom()
action.Data["amount"] = amount
action.Data["denom"] = asset
action.Data["fee_asset"] = body.Ics20Withdrawal.GetFeeAsset()
action.Data["destination_address"] = body.Ics20Withdrawal.GetDestinationChainAddress()
action.Data["return_address"] = body.Ics20Withdrawal.GetReturnAddress().GetBech32M()
action.Data["source_channel"] = body.Ics20Withdrawal.GetSourceChannel()
action.Data["use_compat_address"] = body.Ics20Withdrawal.GetUseCompatAddress()
decAmount := decimal.RequireFromString(amount)
if memo := body.Ics20Withdrawal.GetMemo(); memo != "" {
action.Data["memo"] = memo
}
if th := body.Ics20Withdrawal.GetTimeoutHeight(); th != nil {
action.Data["timeout_height"] = map[string]any{
"revision_number": th.GetRevisionNumber(),
"revision_height": th.GetRevisionHeight(),
}
}
if body.Ics20Withdrawal.GetTimeoutTime() > 0 {
action.Data["timeout_time"] = body.Ics20Withdrawal.GetTimeoutTime()
}
returnAddress := body.Ics20Withdrawal.GetReturnAddress().GetBech32M()
if bridge := body.Ics20Withdrawal.GetBridgeAddress().GetBech32M(); bridge != "" {
action.Data["bridge"] = bridge
addr := ctx.Addresses.Set(bridge, height, decAmount.Copy().Neg(), asset, 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
if returnAddress != bridge {
returnAddr := ctx.Addresses.Set(returnAddress, height, decAmount, asset, 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: returnAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
action.BalanceUpdates = append(action.BalanceUpdates, storage.BalanceUpdate{
Address: returnAddr,
Height: action.Height,
Currency: body.Ics20Withdrawal.GetDenom(),
Update: decAmount.Copy().Neg(),
})
} else {
action.BalanceUpdates = append(action.BalanceUpdates, storage.BalanceUpdate{
Address: addr,
Height: action.Height,
Currency: body.Ics20Withdrawal.GetDenom(),
Update: decAmount.Copy().Neg(),
})
}
} else {
addr := ctx.Addresses.Set(from, height, decAmount.Copy().Neg(), asset, 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
if returnAddress != from {
returnAddr := ctx.Addresses.Set(returnAddress, height, decAmount, asset, 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: returnAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
action.BalanceUpdates = append(action.BalanceUpdates, storage.BalanceUpdate{
Address: returnAddr,
Height: action.Height,
Currency: body.Ics20Withdrawal.GetDenom(),
Update: decAmount.Copy().Neg(),
})
} else {
action.BalanceUpdates = append(action.BalanceUpdates, storage.BalanceUpdate{
Address: addr,
Height: action.Height,
Currency: body.Ics20Withdrawal.GetDenom(),
Update: decAmount.Copy().Neg(),
})
}
}
}
return nil
}
func parseRollupDataSubmission(body *astria.Action_RollupDataSubmission, from string, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeRollupDataSubmission
action.Data = make(map[string]any)
if body.RollupDataSubmission != nil {
rollupId := body.RollupDataSubmission.GetRollupId().GetInner()
action.Data["rollup_id"] = rollupId
action.Data["data"] = body.RollupDataSubmission.GetData()
action.Data["fee_asset"] = body.RollupDataSubmission.GetFeeAsset()
dataSize := len(body.RollupDataSubmission.GetData())
rollup := ctx.Rollups.Set(rollupId, height, dataSize)
fromAddress := ctx.Addresses.Set(from, height, decimal.Zero, "", 1, 0)
rollupAddress := &storage.RollupAddress{
Rollup: rollup,
Address: fromAddress,
Height: height,
}
key := rollupAddress.String()
if key == "" {
return errors.Errorf("empty rollup address key")
}
if _, ok := ctx.RollupAddress[key]; !ok {
ctx.RollupAddress[key] = rollupAddress
}
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: fromAddress,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
action.RollupAction = &storage.RollupAction{
Time: action.Time,
Height: action.Height,
Size: int64(dataSize),
Action: action,
Rollup: rollup,
ActionType: action.Type,
}
ctx.DataSize += int64(dataSize)
}
return nil
}
func parseSudoAddressChangeAction(body *astria.Action_SudoAddressChange, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeSudoAddressChange
action.Data = make(map[string]any)
if body.SudoAddressChange != nil {
address := body.SudoAddressChange.GetNewAddress().GetBech32M()
action.Data["address"] = address
addr := ctx.Addresses.Set(address, action.Height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
ctx.AddGenericConstant("authority_sudo_address", address)
}
return nil
}
func parseTransferAction(body *astria.Action_Transfer, from string, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeTransfer
action.Data = make(map[string]any)
if body.Transfer != nil {
amount := uint128ToString(body.Transfer.GetAmount())
to := body.Transfer.GetTo().GetBech32M()
asset := body.Transfer.GetAsset()
action.Data["amount"] = amount
action.Data["asset"] = asset
action.Data["fee_asset"] = body.Transfer.GetFeeAsset()
action.Data["to"] = to
decAmount := decimal.RequireFromString(amount)
transfer := storage.Transfer{
Height: height,
Time: action.Time,
Asset: asset,
Amount: decAmount,
}
if from == to {
addr := ctx.Addresses.Set(from, height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
transfer.Source = addr
transfer.Destination = addr
} else {
toAddr := ctx.Addresses.Set(to, height, decAmount, asset, 1, 0)
fromAddr := ctx.Addresses.Set(from, height, decAmount.Neg(), asset, 1, 0)
action.Addresses = append(action.Addresses,
&storage.AddressAction{
Address: toAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
},
&storage.AddressAction{
Address: fromAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
action.BalanceUpdates = append(action.BalanceUpdates,
storage.BalanceUpdate{
Address: toAddr,
Height: action.Height,
Currency: asset,
Update: decAmount,
},
storage.BalanceUpdate{
Address: fromAddr,
Height: action.Height,
Currency: asset,
Update: decAmount.Copy().Neg(),
})
transfer.Source = fromAddr
transfer.Destination = toAddr
}
ctx.AddTransfer(&transfer)
}
return nil
}
func parseValidatorUpdateAction(body *astria.Action_ValidatorUpdate, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeValidatorUpdate
action.Data = make(map[string]any)
if body.ValidatorUpdate != nil {
power := body.ValidatorUpdate.GetPower()
action.Data["power"] = power
pubKey := body.ValidatorUpdate.GetPubKey().GetEd25519()
action.Data["pubkey"] = pubKey
name := body.ValidatorUpdate.GetName()
action.Data["name"] = name
address, err := AddressFromPubKey(body.ValidatorUpdate.GetPubKey().GetEd25519())
if err != nil {
return err
}
addr := ctx.Addresses.Set(address, height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
ctx.Validators.Set(pubKey, power, address, name, height)
}
return nil
}
func parseIbcRelayerChange(body *astria.Action_IbcRelayerChange, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeIbcRelayerChange
action.Data = make(map[string]any)
if body.IbcRelayerChange != nil {
if addition := body.IbcRelayerChange.GetAddition(); len(addition.GetBech32M()) > 0 {
b32m := addition.GetBech32M()
action.Data["addition"] = b32m
addr := ctx.Addresses.Set(b32m, height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
ctx.Addresses.AddIbcRelayer(b32m)
}
if removal := body.IbcRelayerChange.GetRemoval(); len(removal.GetBech32M()) > 0 {
b32m := removal.GetBech32M()
action.Data["removal"] = b32m
addr := ctx.Addresses.Set(b32m, height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
ctx.Addresses.RemoveIbcRelayer(b32m)
}
}
return nil
}
func parseInitBridgeAccount(body *astria.Action_InitBridgeAccount, from string, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeInitBridgeAccount
action.Data = make(map[string]any)
if body.InitBridgeAccount != nil {
rollupId := body.InitBridgeAccount.GetRollupId().GetInner()
rollup := ctx.Rollups.Set(rollupId, height, 0)
bridge := storage.Bridge{
InitHeight: height,
Asset: body.InitBridgeAccount.GetAsset(),
FeeAsset: body.InitBridgeAccount.GetFeeAsset(),
Address: ctx.Addresses.Set(from, height, decimal.Zero, "", 0, 0),
Rollup: rollup,
}
bridge.Address.IsBridge = true
rollup.BridgeCount += 1
action.Data["rollup_id"] = rollupId
action.Data["fee_asset"] = bridge.FeeAsset
action.Data["asset"] = bridge.Asset
if sudo := body.InitBridgeAccount.GetSudoAddress().GetBech32M(); sudo != "" {
action.Data["sudo"] = sudo
if sudo != from {
addr := ctx.Addresses.Set(sudo, height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
bridge.Sudo = addr
}
}
if bridge.Sudo == nil {
bridge.Sudo = bridge.Address
}
if withdrawer := body.InitBridgeAccount.GetWithdrawerAddress().GetBech32M(); withdrawer != "" {
action.Data["withdrawer"] = withdrawer
if withdrawer != from {
addr := ctx.Addresses.Set(withdrawer, height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
bridge.Withdrawer = addr
}
}
if bridge.Withdrawer == nil {
bridge.Withdrawer = bridge.Address
}
action.RollupAction = &storage.RollupAction{
Time: action.Time,
Height: action.Height,
Action: action,
Rollup: rollup,
ActionType: action.Type,
}
ctx.AddBridge(&bridge)
ctx.AddBridgeAsset(from, bridge.Asset)
}
return nil
}
func parseBridgeSudoChange(body *astria.Action_BridgeSudoChange, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeBridgeSudoChangeAction
action.Data = make(map[string]any)
if body.BridgeSudoChange != nil {
bridgeAddress := body.BridgeSudoChange.GetBridgeAddress().GetBech32M()
sudo := body.BridgeSudoChange.GetNewSudoAddress().GetBech32M()
withdrawer := body.BridgeSudoChange.GetNewWithdrawerAddress().GetBech32M()
feeAsset := body.BridgeSudoChange.GetFeeAsset()
action.Data["bridge"] = bridgeAddress
bridgeAddr := ctx.Addresses.Set(bridgeAddress, height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: bridgeAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
bridge := storage.Bridge{
Address: bridgeAddr,
Sudo: bridgeAddr,
Withdrawer: bridgeAddr,
}
if sudo != "" {
action.Data["sudo"] = sudo
if bridgeAddress != sudo {
addr := ctx.Addresses.Set(sudo, height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
bridge.Sudo = addr
}
}
if withdrawer != "" {
action.Data["withdrawer"] = withdrawer
actions := 1
if sudo == withdrawer || bridgeAddress == withdrawer {
actions = 0
}
addr := ctx.Addresses.Set(withdrawer, height, decimal.Zero, "", actions, 0)
bridge.Withdrawer = addr
if bridgeAddress != withdrawer && sudo != withdrawer {
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
}
}
if feeAsset != "" {
action.Data["fee_asset"] = feeAsset
bridge.FeeAsset = feeAsset
}
ctx.AddBridge(&bridge)
}
return nil
}
func parseBridgeLock(body *astria.Action_BridgeLock, from string, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeBridgeLock
action.Data = make(map[string]any)
if body.BridgeLock != nil {
amount := uint128ToString(body.BridgeLock.GetAmount())
asset := body.BridgeLock.GetAsset()
action.Data["to"] = body.BridgeLock.GetTo().GetBech32M()
action.Data["destination_chain_address"] = body.BridgeLock.GetDestinationChainAddress()
action.Data["asset"] = asset
action.Data["fee_asset"] = body.BridgeLock.GetFeeAsset()
action.Data["amount"] = amount
toAddress := body.BridgeLock.GetTo().GetBech32M()
decAmount := decimal.RequireFromString(amount)
toAddr := ctx.Addresses.Set(toAddress, height, decAmount, asset, 1, 0)
if from == toAddress {
action.Addresses = append(action.Addresses,
&storage.AddressAction{
Address: toAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
},
)
} else {
fromAddr := ctx.Addresses.Set(from, height, decAmount.Neg(), asset, 1, 0)
action.Addresses = append(action.Addresses,
&storage.AddressAction{
Address: toAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
},
&storage.AddressAction{
Address: fromAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
},
)
action.BalanceUpdates = append(action.BalanceUpdates,
storage.BalanceUpdate{
Address: toAddr,
Height: action.Height,
Currency: asset,
Update: decAmount,
},
storage.BalanceUpdate{
Address: fromAddr,
Height: action.Height,
Currency: asset,
Update: decAmount.Neg(),
},
)
}
}
return nil
}
func parseBridgeUnlock(body *astria.Action_BridgeUnlock, from string, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeBridgeUnlock
action.Data = make(map[string]any)
if body.BridgeUnlock != nil {
amount := uint128ToString(body.BridgeUnlock.GetAmount())
toAddress := body.BridgeUnlock.GetTo().GetBech32M()
bridge := body.BridgeUnlock.GetBridgeAddress().GetBech32M()
feeAsset := body.BridgeUnlock.GetFeeAsset()
action.Data["to"] = toAddress
action.Data["fee_asset"] = feeAsset
action.Data["amount"] = amount
action.Data["rollup_block_number"] = body.BridgeUnlock.GetRollupBlockNumber()
action.Data["rollup_withdrawal_event_id"] = body.BridgeUnlock.GetRollupWithdrawalEventId()
if memo := body.BridgeUnlock.GetMemo(); len(memo) > 0 {
action.Data["memo"] = memo
}
if bridge != "" {
action.Data["bridge"] = bridge
}
var (
decAmount = decimal.RequireFromString(amount)
fromAddr *storage.Address
unlockAsset string
)
if bridge == "" {
fromAddr = ctx.Addresses.Set(from, height, decAmount.Neg(), "", 1, 0)
unlockAsset = currency.DefaultCurrency
} else {
asset, ok := ctx.bridgeAssets[bridge]
if !ok {
return errors.Errorf("unknown bridge asset: %s", bridge)
}
fromAddr = ctx.Addresses.Set(bridge, height, decAmount.Neg(), asset, 1, 0)
unlockAsset = asset
}
toAddr := ctx.Addresses.Set(toAddress, height, decAmount, unlockAsset, 1, 0)
action.Addresses = append(action.Addresses,
&storage.AddressAction{
Address: toAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
},
&storage.AddressAction{
Address: fromAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
},
)
action.BalanceUpdates = append(action.BalanceUpdates,
storage.BalanceUpdate{
Address: toAddr,
Height: action.Height,
Currency: unlockAsset,
Update: decAmount,
},
storage.BalanceUpdate{
Address: fromAddr,
Height: action.Height,
Currency: unlockAsset,
Update: decAmount.Neg(),
},
)
}
return nil
}
func parseFeeAssetChange(body *astria.Action_FeeAssetChange, action *storage.Action) error {
action.Type = storageTypes.ActionTypeFeeAssetChange
action.Data = make(map[string]any)
if body.FeeAssetChange != nil {
if addition := body.FeeAssetChange.GetAddition(); len(addition) > 0 {
action.Data["addition"] = addition
}
if removal := body.FeeAssetChange.GetRemoval(); len(removal) > 0 {
action.Data["removal"] = removal
}
}
return nil
}
func parseFeeChange(body *astria.Action_FeeChange, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeFeeChange
action.Data = make(map[string]any)
if body.FeeChange != nil {
switch t := body.FeeChange.GetFeeComponents().(type) {
case *astria.FeeChange_BridgeLock:
processFeeComponent(storageTypes.ActionTypeBridgeLock.String(), t.BridgeLock.GetMultiplier(), t.BridgeLock.GetBase(), action.Data, ctx)
case *astria.FeeChange_BridgeSudoChange:
processFeeComponent("bridge_sudo_change", t.BridgeSudoChange.GetMultiplier(), t.BridgeSudoChange.GetBase(), action.Data, ctx)
case *astria.FeeChange_BridgeUnlock:
processFeeComponent(storageTypes.ActionTypeBridgeUnlock.String(), t.BridgeUnlock.GetMultiplier(), t.BridgeUnlock.GetBase(), action.Data, ctx)
case *astria.FeeChange_FeeAssetChange:
processFeeComponent(storageTypes.ActionTypeFeeAssetChange.String(), t.FeeAssetChange.GetMultiplier(), t.FeeAssetChange.GetBase(), action.Data, ctx)
case *astria.FeeChange_FeeChange:
processFeeComponent(storageTypes.ActionTypeFeeChange.String(), t.FeeChange.GetMultiplier(), t.FeeChange.GetBase(), action.Data, ctx)
case *astria.FeeChange_IbcRelay:
processFeeComponent(storageTypes.ActionTypeIbcRelay.String(), t.IbcRelay.GetMultiplier(), t.IbcRelay.GetBase(), action.Data, ctx)
case *astria.FeeChange_IbcRelayerChange:
processFeeComponent(storageTypes.ActionTypeIbcRelayerChange.String(), t.IbcRelayerChange.GetMultiplier(), t.IbcRelayerChange.GetBase(), action.Data, ctx)
case *astria.FeeChange_IbcSudoChange:
processFeeComponent(storageTypes.ActionTypeIbcSudoChangeAction.String(), t.IbcSudoChange.GetMultiplier(), t.IbcSudoChange.GetBase(), action.Data, ctx)
case *astria.FeeChange_Ics20Withdrawal:
processFeeComponent(storageTypes.ActionTypeIcs20Withdrawal.String(), t.Ics20Withdrawal.GetMultiplier(), t.Ics20Withdrawal.GetBase(), action.Data, ctx)
case *astria.FeeChange_InitBridgeAccount:
processFeeComponent(storageTypes.ActionTypeInitBridgeAccount.String(), t.InitBridgeAccount.GetMultiplier(), t.InitBridgeAccount.GetBase(), action.Data, ctx)
case *astria.FeeChange_RollupDataSubmission:
processFeeComponent(storageTypes.ActionTypeRollupDataSubmission.String(), t.RollupDataSubmission.GetMultiplier(), t.RollupDataSubmission.GetBase(), action.Data, ctx)
case *astria.FeeChange_SudoAddressChange:
processFeeComponent(storageTypes.ActionTypeSudoAddressChange.String(), t.SudoAddressChange.GetMultiplier(), t.SudoAddressChange.GetBase(), action.Data, ctx)
case *astria.FeeChange_Transfer:
processFeeComponent(storageTypes.ActionTypeTransfer.String(), t.Transfer.GetMultiplier(), t.Transfer.GetBase(), action.Data, ctx)
case *astria.FeeChange_ValidatorUpdate:
processFeeComponent(storageTypes.ActionTypeValidatorUpdate.String(), t.ValidatorUpdate.GetMultiplier(), t.ValidatorUpdate.GetBase(), action.Data, ctx)
case *astria.FeeChange_BridgeTransfer:
processFeeComponent(storageTypes.ActionTypeBridgeTransfer.String(), t.BridgeTransfer.GetMultiplier(), t.BridgeTransfer.GetBase(), action.Data, ctx)
case *astria.FeeChange_RecoverIbcClient:
processFeeComponent(storageTypes.ActionTypeRecoverIbcClient.String(), t.RecoverIbcClient.GetMultiplier(), t.RecoverIbcClient.GetBase(), action.Data, ctx)
case *astria.FeeChange_CurrencyPairsChange:
processFeeComponent(storageTypes.ActionTypeCurrencyPairsChange.String(), t.CurrencyPairsChange.GetMultiplier(), t.CurrencyPairsChange.GetBase(), action.Data, ctx)
case *astria.FeeChange_MarketsChange:
processFeeComponent(storageTypes.ActionTypeMarketsChange.String(), t.MarketsChange.GetMultiplier(), t.MarketsChange.GetBase(), action.Data, ctx)
}
}
return nil
}
func parseIbcSudoChangeAction(body *astria.Action_IbcSudoChange, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeIbcSudoChangeAction
action.Data = make(map[string]any)
if body.IbcSudoChange != nil {
address := body.IbcSudoChange.GetNewAddress().GetBech32M()
action.Data["address"] = address
addr := ctx.Addresses.Set(address, action.Height, decimal.Zero, "", 1, 0)
action.Addresses = append(action.Addresses, &storage.AddressAction{
Address: addr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
})
ctx.AddGenericConstant("ibc_sudo_address", address)
}
return nil
}
func processFeeComponent(name string, multiplier, base *primitive.Uint128, data map[string]any, ctx *Context) {
m := uint128ToString(multiplier)
mKey := fmt.Sprintf("%s_multiplier", name)
data[mKey] = m
ctx.AddGenericConstant(mKey, m)
b := uint128ToString(base)
bKey := fmt.Sprintf("%s_base", name)
data[bKey] = b
ctx.AddGenericConstant(bKey, b)
}
func parseBridgeTransfer(body *astria.Action_BridgeTransfer, height types.Level, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeBridgeTransfer
action.Data = make(map[string]any)
if body.BridgeTransfer != nil {
amount := uint128ToString(body.BridgeTransfer.GetAmount())
toAddress := body.BridgeTransfer.GetTo().GetBech32M()
bridge := body.BridgeTransfer.GetBridgeAddress().GetBech32M()
feeAsset := body.BridgeTransfer.GetFeeAsset()
action.Data["to"] = toAddress
action.Data["fee_asset"] = feeAsset
action.Data["amount"] = amount
action.Data["rollup_block_number"] = body.BridgeTransfer.GetRollupBlockNumber()
action.Data["rollup_withdrawal_event_id"] = body.BridgeTransfer.GetRollupWithdrawalEventId()
action.Data["destination_chain_address"] = body.BridgeTransfer.GetDestinationChainAddress()
if bridge != "" {
action.Data["bridge_address"] = bridge
}
decAmount := decimal.RequireFromString(amount)
asset, ok := ctx.bridgeAssets[bridge]
if !ok {
return errors.Errorf("unknown bridge asset: %s", bridge)
}
fromAddr := ctx.Addresses.Set(bridge, height, decAmount.Neg(), asset, 1, 0)
toAddr := ctx.Addresses.Set(toAddress, height, decAmount.Copy(), asset, 1, 0)
action.Addresses = append(action.Addresses,
&storage.AddressAction{
Address: fromAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
},
&storage.AddressAction{
Address: toAddr,
Action: action,
Time: action.Time,
Height: action.Height,
ActionType: action.Type,
},
)
action.BalanceUpdates = append(action.BalanceUpdates,
storage.BalanceUpdate{
Address: fromAddr,
Height: action.Height,
Currency: asset,
Update: decAmount.Neg(),
},
storage.BalanceUpdate{
Address: toAddr,
Height: action.Height,
Currency: asset,
Update: decAmount,
},
)
}
return nil
}
func parseRecoverIbcClient(body *astria.Action_RecoverIbcClient, action *storage.Action) error {
action.Type = storageTypes.ActionTypeRecoverIbcClient
action.Data = make(map[string]any)
if body.RecoverIbcClient != nil {
action.Data["client_id"] = body.RecoverIbcClient.GetClientId()
action.Data["replacement_client_id"] = body.RecoverIbcClient.GetReplacementClientId()
}
return nil
}
func parseCurrencyPairsChange(body *astria.Action_CurrencyPairsChange, action *storage.Action) error {
action.Type = storageTypes.ActionTypeCurrencyPairsChange
action.Data = make(map[string]any)
if body.CurrencyPairsChange != nil {
switch value := body.CurrencyPairsChange.GetValue().(type) {
case *astria.CurrencyPairsChange_Addition:
data, err := json.Marshal(value.Addition.GetPairs())
if err != nil {
return errors.Wrap(err, "currency pairs change addition")
}
action.Data["addition"] = json.RawMessage(data)
case *astria.CurrencyPairsChange_Removal:
data, err := json.Marshal(value.Removal.GetPairs())
if err != nil {
return errors.Wrap(err, "currency pairs change removal")
}
action.Data["removal"] = json.RawMessage(data)
}
}
return nil
}
func parseMarketsChange(body *astria.Action_MarketsChange, ctx *Context, action *storage.Action) error {
action.Type = storageTypes.ActionTypeMarketsChange
action.Data = make(map[string]any)
if body.MarketsChange != nil {
switch markets := body.MarketsChange.GetAction().(type) {
case *astria.MarketsChange_Creation:
return handleMarkets(markets.Creation.GetMarkets(), ctx, action, storage.MarketUpdateTypeCreate)
case *astria.MarketsChange_Removal:
return handleMarkets(markets.Removal.GetMarkets(), ctx, action, storage.MarketUpdateTypeRemove)
case *astria.MarketsChange_Update:
return handleMarkets(markets.Update.GetMarkets(), ctx, action, storage.MarketUpdateTypeUpdate)
}
}
return nil
}
func handleMarkets(markets []*v21.Market, ctx *Context, action *storage.Action, typ storage.MarketUpdateType) error {
data, err := json.Marshal(markets)
if err != nil {
return errors.Wrapf(err, "%s markets", typ)
}
action.Data[string(typ)] = json.RawMessage(data)
for i := range markets {
ticker := markets[i].GetTicker()
if ticker == nil {
continue
}
if pair := ticker.GetCurrencyPair(); pair != nil {
pairId := fmt.Sprintf("%s_%s", pair.GetBase(), pair.GetQuote())
ctx.AddMarket(storage.Market{
Pair: pairId,
Decimals: int(ticker.GetDecimals()),
Enabled: ticker.GetEnabled(),
MinProviderCount: int(ticker.GetMinProviderCount()),
Base: pair.GetBase(),
Quote: pair.GetQuote(),
}, typ)
providers := markets[i].GetProviderConfigs()
for j := range providers {
name := providers[j].GetName()
offChainTicker := providers[j].GetOffChainTicker()
ctx.AddMarketProvider(pairId, name, offChainTicker, typ)
}
}
}
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
"github.com/celenium-io/astria-indexer/internal/currency"
"github.com/celenium-io/astria-indexer/internal/storage"
testsuite "github.com/celenium-io/astria-indexer/internal/test_suite"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/shopspring/decimal"
)
type Addresses map[string]*storage.Address
func NewAddress() Addresses {
return make(map[string]*storage.Address)
}
func (a Addresses) Set(address string, height types.Level, change decimal.Decimal, asset string, actionCount int, signedTxCount int) *storage.Address {
if asset == "" {
asset = currency.DefaultCurrency
}
if addr, ok := a[address]; ok {
addr.ActionsCount += int64(actionCount)
addr.SignedTxCount += int64(signedTxCount)
var balanceFound bool
for i := range addr.Balance {
if addr.Balance[i].Currency == asset {
balanceFound = true
addr.Balance[i].Total = addr.Balance[i].Total.Add(change)
}
}
if !balanceFound {
addr.Balance = append(addr.Balance, &storage.Balance{
Total: change,
Currency: asset,
})
}
return addr
}
addr := &storage.Address{
Height: height,
Hash: address,
ActionsCount: int64(actionCount),
SignedTxCount: int64(signedTxCount),
Balance: []*storage.Balance{
{
Total: change,
Currency: asset,
},
},
}
a[address] = addr
return addr
}
func (a Addresses) UpdateNonce(address string, nonce uint32) {
if address, ok := a[address]; ok {
address.Nonce = nonce
}
}
func (a Addresses) Get(address string) (*storage.Address, bool) {
addr, ok := a[address]
return addr, ok
}
func (a Addresses) AddIbcRelayer(address string) {
if address, ok := a[address]; ok {
address.IsIbcRelayer = testsuite.Ptr(true)
}
}
func (a Addresses) RemoveIbcRelayer(address string) {
if address, ok := a[address]; ok {
address.IsIbcRelayer = testsuite.Ptr(false)
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
"fmt"
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
storageTypes "github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/shopspring/decimal"
)
type Context struct {
Addresses Addresses
Rollups Rollups
Validators Validators
RollupAddress map[string]*storage.RollupAddress
AddressActions map[string]*storage.AddressAction
SupplyChange decimal.Decimal
BytesInBlock int64
GasUsed int64
GasWanted int64
DataSize int64
ActionTypes storageTypes.Bits
Constants map[string]*storage.Constant
Bridges map[string]*storage.Bridge
Fees map[int64]*storage.Fee
Transfers []*storage.Transfer
Deposits map[int64]*storage.Deposit
Markets []storage.MarketUpdate
MarketProviders []storage.MarketProviderUpdate
Prices []storage.Price
HasWriteAckError bool
Proposer string
bridgeAssets map[string]string
blockTime time.Time
}
func NewContext(bridgeAssets map[string]string, blockTime time.Time) Context {
return Context{
Addresses: NewAddress(),
Rollups: NewRollups(),
RollupAddress: make(map[string]*storage.RollupAddress),
SupplyChange: decimal.Zero,
Validators: NewValidators(),
Constants: make(map[string]*storage.Constant),
Bridges: make(map[string]*storage.Bridge),
Fees: make(map[int64]*storage.Fee),
Transfers: make([]*storage.Transfer, 0),
Deposits: make(map[int64]*storage.Deposit),
Prices: make([]storage.Price, 0),
Markets: make([]storage.MarketUpdate, 0),
MarketProviders: make([]storage.MarketProviderUpdate, 0),
bridgeAssets: bridgeAssets,
blockTime: blockTime,
}
}
func (ctx *Context) AddGenericConstant(key, value string) {
k := fmt.Sprintf("%s-%s", key, storageTypes.ModuleNameGeneric)
ctx.Constants[k] = &storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: key,
Value: value,
}
}
func (ctx *Context) ConstantsArray() []*storage.Constant {
arr := make([]*storage.Constant, 0)
for _, val := range ctx.Constants {
arr = append(arr, val)
}
return arr
}
func (ctx *Context) AddBridge(b *storage.Bridge) {
ctx.Bridges[b.Address.Hash] = b
}
func (ctx *Context) BridgesArray() []*storage.Bridge {
arr := make([]*storage.Bridge, 0)
for _, val := range ctx.Bridges {
arr = append(arr, val)
}
return arr
}
func (ctx *Context) AddFee(idx int64, fee *storage.Fee) {
ctx.Fees[idx] = fee
}
func (ctx *Context) ClearTx() {
clear(ctx.Fees)
ctx.HasWriteAckError = false
}
func (ctx *Context) AddBridgeAsset(bridge, asset string) {
ctx.bridgeAssets[bridge] = asset
}
func (ctx *Context) AddTransfer(transfer *storage.Transfer) {
ctx.Transfers = append(ctx.Transfers, transfer)
}
func (ctx *Context) AddDeposit(idx int64, deposit *storage.Deposit) {
ctx.Deposits[idx] = deposit
}
func (ctx *Context) AddPrice(price storage.Price) {
price.Time = ctx.blockTime
ctx.Prices = append(ctx.Prices, price)
}
func (ctx *Context) AddMarket(market storage.Market, marketType storage.MarketUpdateType) {
ctx.Markets = append(ctx.Markets, storage.MarketUpdate{
Market: market,
Type: marketType,
})
}
func (ctx *Context) AddMarketProvider(pair, provider, offChainTicker string, typ storage.MarketUpdateType) {
ctx.MarketProviders = append(ctx.MarketProviders, storage.MarketProviderUpdate{
MarketProvider: storage.MarketProvider{
Pair: pair,
Provider: provider,
OffChainTicker: offChainTicker,
},
Type: typ,
})
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
"math/big"
v1 "buf.build/gen/go/astria/primitives/protocolbuffers/go/astria/primitive/v1"
"github.com/celenium-io/astria-indexer/internal/astria"
"github.com/cometbft/cometbft/crypto/ed25519"
)
func uint128ToString(u *v1.Uint128) string {
val := new(big.Int)
val = val.SetUint64(u.GetHi())
val = val.Lsh(val, 64)
low := new(big.Int).SetUint64(u.GetLo())
val = val.Add(val, low)
return val.Text(10)
}
func AddressFromPubKey(pk []byte) (string, error) {
return astria.EncodeAddress(ed25519.PubKey(pk).Address())
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
"fmt"
internalAstria "github.com/celenium-io/astria-indexer/internal/astria"
"github.com/celenium-io/astria-indexer/internal/storage"
clientTypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"
connectionTypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types"
channelTypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
lightTypes "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint"
"github.com/fatih/structs"
"github.com/goccy/go-json"
"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"
"github.com/shopspring/decimal"
)
type IbcTransfer struct {
Amount decimal.Decimal `json:"amount"`
Denom string `json:"denom"`
Receiver string `json:"receiver"`
Sender string `json:"sender"`
}
func parseIbcMessages(typ string, data []byte, action *storage.Action, ctx *Context) error {
switch typ {
// channel messages
case "/ibc.core.channel.v1.MsgRecvPacket":
var msg channelTypes.MsgRecvPacket
if err := handleType(&msg, data, action); err != nil {
return err
}
var transfer IbcTransfer
if err := json.Unmarshal(msg.Packet.Data, &transfer); err != nil {
return nil
}
asset := fmt.Sprintf("%s/%s/%s", msg.Packet.GetDestPort(), msg.Packet.GetDestChannel(), transfer.Denom)
if err := handleTransfer(transfer, action, ctx, asset, false); err != nil {
return errors.Wrap(err, "transfer handling")
}
case "/ibc.core.channel.v1.MsgTimeout":
var msg channelTypes.MsgTimeout
if err := handleType(&msg, data, action); err != nil {
return err
}
var transfer IbcTransfer
if err := json.Unmarshal(msg.Packet.Data, &transfer); err != nil {
return nil
}
if err := handleTransfer(transfer, action, ctx, transfer.Denom, true); err != nil {
return errors.Wrap(err, "transfer handling")
}
case "/ibc.core.channel.v1.MsgChannelOpenInit":
var msg channelTypes.MsgChannelOpenInit
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.channel.v1.MsgChannelOpenTry":
var msg channelTypes.MsgChannelOpenTry
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.channel.v1.MsgChannelOpenAck":
var msg channelTypes.MsgChannelOpenAck
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.channel.v1.MsgChannelOpenConfirm":
var msg channelTypes.MsgChannelOpenConfirm
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.channel.v1.MsgChannelCloseInit":
var msg channelTypes.MsgChannelCloseInit
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.channel.v1.MsgChannelCloseConfirm":
var msg channelTypes.MsgChannelCloseConfirm
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.channel.v1.MsgAcknowledgement":
var msg channelTypes.MsgAcknowledgement
if err := handleType(&msg, data, action); err != nil {
return err
}
// connection messages
case "/ibc.core.connection.v1.MsgConnectionOpenInit":
var msg connectionTypes.MsgConnectionOpenInit
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.connection.v1.MsgConnectionOpenTry":
var msg connectionTypes.MsgConnectionOpenTry
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.connection.v1.MsgConnectionOpenAck":
var msg connectionTypes.MsgConnectionOpenAck
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.connection.v1.MsgConnectionOpenConfirm":
var msg connectionTypes.MsgConnectionOpenConfirm
if err := handleType(&msg, data, action); err != nil {
return err
}
// clients messages
case "/ibc.core.client.v1.MsgCreateClient":
var msg clientTypes.MsgCreateClient
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.client.v1.MsgUpdateClient":
var msg clientTypes.MsgUpdateClient
if err := handleType(&msg, data, action); err != nil {
return err
}
case "/ibc.core.client.v1.MsgUpgradeClient":
var msg clientTypes.MsgUpgradeClient
if err := handleType(&msg, data, action); err != nil {
return err
}
// case "/ibc.core.client.v1.MsgSubmitMisbehaviour":
// var msg clientTypes.MsgSubmitMisbehaviour
// if err := handleType(&msg, data, action); err != nil {
// return err
// }
default:
}
return nil
}
func handleType[T proto.Message](msg T, data []byte, action *storage.Action) error {
if err := proto.Unmarshal(data, msg); err != nil {
return errors.Wrap(err, "unmarshal IBC message")
}
m := structs.Map(msg)
for key, value := range m {
if valMap, ok := value.(map[string]any); ok {
if typeUrl, ok := valMap["TypeUrl"]; ok {
switch typeUrl {
case "/ibc.lightclients.tendermint.v1.ClientState":
if data, ok := valMap["Value"]; ok {
var csMsg lightTypes.ClientState
if err := proto.Unmarshal(data.([]byte), &csMsg); err != nil {
return errors.Wrap(err, "unmarshal client state")
}
m[key] = structs.Map(csMsg)
}
case "/ibc.lightclients.tendermint.v1.ConsensusState":
if data, ok := valMap["Value"]; ok {
var csMsg lightTypes.ConsensusState
if err := proto.Unmarshal(data.([]byte), &csMsg); err != nil {
return errors.Wrap(err, "unmarshal consensus state")
}
m[key] = structs.Map(csMsg)
}
case "/ibc.lightclients.tendermint.v1.Header":
if data, ok := valMap["Value"]; ok {
var csMsg lightTypes.Header
if err := proto.Unmarshal(data.([]byte), &csMsg); err != nil {
return errors.Wrap(err, "unmarshal header")
}
m[key] = structs.Map(csMsg)
}
}
}
}
}
action.Data["msg"] = m
delete(action.Data, "raw")
return nil
}
func handleTransfer(transfer IbcTransfer, action *storage.Action, ctx *Context, asset string, isRefund bool) error {
var addr string
var amount = transfer.Amount.Copy()
switch {
case internalAstria.IsAddress(transfer.Receiver):
addr = transfer.Receiver
if isRefund {
amount = amount.Neg()
}
case internalAstria.IsCompatAddress(transfer.Receiver):
a, err := internalAstria.CompatToAstria(transfer.Receiver)
if err != nil {
return err
}
addr = a
if isRefund {
amount = amount.Neg()
}
case internalAstria.IsAddress(transfer.Sender):
addr = transfer.Sender
if !isRefund {
amount = amount.Neg()
}
case internalAstria.IsCompatAddress(transfer.Sender):
a, err := internalAstria.CompatToAstria(transfer.Sender)
if err != nil {
return err
}
addr = a
if !isRefund {
amount = amount.Neg()
}
}
if addr != "" {
address := ctx.Addresses.Set(addr, action.Height, amount, asset, 0, 0)
action.BalanceUpdates = append(action.BalanceUpdates, storage.BalanceUpdate{
Address: address,
Height: action.Height,
Currency: asset,
Update: amount,
})
}
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
"encoding/hex"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
)
type Rollups map[string]*storage.Rollup
func NewRollups() Rollups {
return make(map[string]*storage.Rollup)
}
func (r Rollups) Set(rollupId []byte, height types.Level, size int) *storage.Rollup {
sRollupId := hex.EncodeToString(rollupId)
if rollup, ok := r[sRollupId]; ok {
rollup.ActionsCount += 1
rollup.Size += int64(size)
return rollup
}
rollup := &storage.Rollup{
FirstHeight: height,
AstriaId: rollupId,
ActionsCount: 1,
Size: int64(size),
}
r[sRollupId] = rollup
return rollup
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
astria "buf.build/gen/go/astria/protocol-apis/protocolbuffers/go/astria/protocol/transaction/v1"
sequencerblockv1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1"
"github.com/celenium-io/astria-indexer/internal/storage"
storageTypes "github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
"github.com/shopspring/decimal"
"google.golang.org/protobuf/proto"
)
type DecodedTx struct {
Tx *astria.Transaction
UnsignedTx *astria.TransactionBody
Actions []storage.Action
Signer *storage.Address
ActionTypes storageTypes.Bits
IsDataItem bool
}
func Tx(b types.BlockData, index int, ctx *Context) (d DecodedTx, err error) {
raw := b.Block.Txs[index]
ctx.BytesInBlock += int64(len(raw))
d.Tx = new(astria.Transaction)
if err := proto.Unmarshal(raw, d.Tx); err != nil {
dataItem := new(sequencerblockv1.DataItem)
if err := proto.Unmarshal(raw, dataItem); err == nil {
d.IsDataItem = true
return d, nil
}
return d, errors.Wrap(err, "tx decoding")
}
body := d.Tx.GetBody()
if body == nil {
dataItem := new(sequencerblockv1.DataItem)
if err := proto.Unmarshal(raw, dataItem); err == nil {
d.IsDataItem = true
return d, nil
}
return d, errors.Wrap(err, "nil decoded tx")
}
d.UnsignedTx = new(astria.TransactionBody)
if err := proto.Unmarshal(body.GetValue(), d.UnsignedTx); err != nil {
return d, errors.Wrap(err, "tx decoding")
}
address, err := AddressFromPubKey(d.Tx.GetPublicKey())
if err != nil {
return d, errors.Wrapf(err, "decode publick key: %x", d.Tx.GetPublicKey())
}
d.Signer = ctx.Addresses.Set(address, b.Height, decimal.Zero, "", 0, 1)
ctx.Addresses.UpdateNonce(address, d.UnsignedTx.GetParams().GetNonce())
d.Actions, err = parseActions(b.Height, b.Block.Time, address, &d, ctx)
if err != nil {
return d, errors.Wrap(err, "parsing actions")
}
ctx.ActionTypes.Set(d.ActionTypes)
return
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package decode
import (
"encoding/hex"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/shopspring/decimal"
)
type Validators map[string]*storage.Validator
func NewValidators() Validators {
return make(map[string]*storage.Validator)
}
func (v Validators) Set(pubKey []byte, power int64, address, name string, height types.Level) *storage.Validator {
sPubKey := hex.EncodeToString(pubKey)
pow := decimal.NewFromInt(power)
if validator, ok := v[sPubKey]; ok {
validator.Power = pow
if name != "" {
validator.Name = name
}
return validator
}
validator := &storage.Validator{
PubKey: pubKey,
Power: pow,
Address: address,
Height: height,
Name: name,
PubkeyType: "tendermint/PubKeyEd25519",
}
v[sPubKey] = validator
return validator
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package genesis
import (
"strconv"
"strings"
"github.com/celenium-io/astria-indexer/internal/storage"
storageTypes "github.com/celenium-io/astria-indexer/internal/storage/types"
nodeTypes "github.com/celenium-io/astria-indexer/pkg/node/types"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
)
func (module *Module) parseConstants(appState nodeTypes.AppState, consensus pkgTypes.ConsensusParams, data *parsedData) {
// block
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameBlock,
Name: "block_max_bytes",
Value: strconv.FormatInt(consensus.Block.MaxBytes, 10),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameBlock,
Name: "block_max_gas",
Value: strconv.FormatInt(consensus.Block.MaxGas, 10),
})
// evidence
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameEvidence,
Name: "max_age_num_blocks",
Value: strconv.FormatInt(consensus.Evidence.MaxAgeNumBlocks, 10),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameEvidence,
Name: "max_age_duration",
Value: consensus.Evidence.MaxAgeDuration.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameEvidence,
Name: "max_bytes",
Value: strconv.FormatInt(consensus.Evidence.MaxBytes, 10),
})
// validator
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameValidator,
Name: "pub_key_types",
Value: strings.Join(consensus.Validator.PubKeyTypes, ","),
})
// version
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameVersion,
Name: "app",
Value: strconv.FormatUint(consensus.Version.AppVersion, 10),
})
// generic
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "authority_sudo_address",
Value: appState.AuthoritySudoAddress.Value,
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "native_asset_base_denomination",
Value: appState.NativeAssetBaseDenomination,
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ibc_sudo_address",
Value: appState.IbcSudoAddress.Value,
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "bridge_lock_base",
Value: appState.Fees.BridgeLock.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "bridge_lock_multiplier",
Value: appState.Fees.BridgeLock.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "bridge_unlock_base",
Value: appState.Fees.BridgeUnlock.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "bridge_unlock_multiplier",
Value: appState.Fees.BridgeUnlock.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "transfer_base",
Value: appState.Fees.Transfer.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "transfer_multiplier",
Value: appState.Fees.Transfer.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "rollup_data_submission_base",
Value: appState.Fees.RollupDataSubmission.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "rollup_data_submission_multiplier",
Value: appState.Fees.RollupDataSubmission.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ics20_withdrawal_base",
Value: appState.Fees.Ics20Withdrawal.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ics20_withdrawal_multiplier",
Value: appState.Fees.Ics20Withdrawal.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "init_bridge_account_base",
Value: appState.Fees.InitBridgeAccount.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "init_bridge_account_multiplier",
Value: appState.Fees.InitBridgeAccount.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "bridge_sudo_change_base",
Value: appState.Fees.BridgeSudoChange.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "bridge_sudo_change_multiplier",
Value: appState.Fees.BridgeSudoChange.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ibc_relay_base",
Value: appState.Fees.IbcRelay.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ibc_relay_multiplier",
Value: appState.Fees.IbcRelay.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "validator_update_base",
Value: appState.Fees.ValidatorUpdate.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "validator_update_multiplier",
Value: appState.Fees.ValidatorUpdate.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "fee_asset_change_base",
Value: appState.Fees.FeeAssetChange.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "fee_asset_change_multiplier",
Value: appState.Fees.FeeAssetChange.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "fee_change_base",
Value: appState.Fees.FeeChange.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "fee_change_multiplier",
Value: appState.Fees.FeeChange.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ibc_relayer_change_base",
Value: appState.Fees.IbcRelayerChange.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ibc_relayer_change_multiplier",
Value: appState.Fees.IbcRelayerChange.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "sudo_address_change_base",
Value: appState.Fees.SudoAddressChange.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "sudo_address_change_multiplier",
Value: appState.Fees.SudoAddressChange.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ibc_sudo_change_base",
Value: appState.Fees.IbcSudoChange.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "ibc_sudo_change_multiplier",
Value: appState.Fees.IbcSudoChange.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "bridge_transfer_base",
Value: appState.Fees.BridgeTransfer.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "bridge_transfer_multiplier",
Value: appState.Fees.BridgeTransfer.Multiplier.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "price_feed_base",
Value: appState.Fees.PriceFeed.Base.String(),
})
data.constants = append(data.constants, storage.Constant{
Module: storageTypes.ModuleNameGeneric,
Name: "price_feed_multiplier",
Value: appState.Fees.PriceFeed.Multiplier.String(),
})
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package genesis
import (
"context"
"github.com/celenium-io/astria-indexer/pkg/indexer/config"
"github.com/celenium-io/astria-indexer/pkg/node/types"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
)
// constants
const (
InputName = "block"
OutputName = "finished"
StopOutput = "stop"
)
// Module - saves received from input genesis block to storage and notify if it was success.
//
// |----------------|
// | |
// -- storage.Block -> | MODULE | -- struct{} ->
// | |
// |----------------|
type Module struct {
modules.BaseModule
storage storage.Transactable
indexerName string
}
var _ modules.Module = (*Module)(nil)
// NewModule -
func NewModule(pg storage.Transactable, cfg config.Indexer) Module {
m := Module{
BaseModule: modules.New("genesis"),
storage: pg,
indexerName: cfg.Name,
}
m.CreateInput(InputName)
m.CreateOutput(OutputName)
m.CreateOutput(StopOutput)
return m
}
// Start -
func (module *Module) Start(ctx context.Context) {
module.G.GoCtx(ctx, module.listen)
}
func (module *Module) listen(ctx context.Context) {
module.Log.Info().Msg("module started")
input := module.MustInput(InputName)
for {
select {
case <-ctx.Done():
return
case msg, ok := <-input.Listen():
if !ok {
module.Log.Warn().Msg("can't read message from input")
return
}
genesis, ok := msg.(types.Genesis)
if !ok {
module.Log.Warn().Msgf("invalid message type: %T", msg)
return
}
module.Log.Info().Msg("received genesis message")
block, err := module.parse(genesis)
if err != nil {
module.Log.Err(err).Msgf("parsing genesis block")
return
}
module.Log.Info().Msg("parsed genesis message")
if err := module.save(ctx, block); err != nil {
module.Log.Err(err).Msg("saving genesis block error")
return
}
module.Log.Info().Msg("saved genesis message")
module.MustOutput(OutputName).Push(struct{}{})
return
}
}
}
// Close -
func (module *Module) Close() error {
module.Log.Info().Msg("closing module...")
module.G.Wait()
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package genesis
import (
"github.com/celenium-io/astria-indexer/internal/astria"
"github.com/celenium-io/astria-indexer/internal/currency"
"github.com/celenium-io/astria-indexer/internal/storage"
testsuite "github.com/celenium-io/astria-indexer/internal/test_suite"
"github.com/celenium-io/astria-indexer/pkg/node/types"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
"github.com/shopspring/decimal"
)
type parsedData struct {
block storage.Block
addresses map[string]*storage.Address
balanceUpdates []storage.BalanceUpdate
constants []storage.Constant
validators []*storage.Validator
supply decimal.Decimal
}
func newParsedData() parsedData {
return parsedData{
addresses: make(map[string]*storage.Address),
balanceUpdates: make([]storage.BalanceUpdate, 0),
constants: make([]storage.Constant, 0),
validators: make([]*storage.Validator, 0),
supply: decimal.Zero,
}
}
func (module *Module) parse(genesis types.Genesis) (parsedData, error) {
data := newParsedData()
block := storage.Block{
Time: genesis.GenesisTime,
Height: pkgTypes.Level(genesis.InitialHeight - 1),
AppHash: []byte(genesis.AppHash),
ChainId: genesis.ChainID,
Txs: make([]*storage.Tx, 0),
Stats: &storage.BlockStats{
Time: genesis.GenesisTime,
Height: pkgTypes.Level(genesis.InitialHeight - 1),
Fee: decimal.Zero,
SupplyChange: decimal.Zero,
},
}
module.parseConstants(genesis.AppState, genesis.ConsensusParams, &data)
if err := module.parseAccounts(genesis.AppState.Accounts, block.Height, &data); err != nil {
return data, errors.Wrap(err, "parse genesis accounts")
}
if err := module.parseValidators(genesis.Validators, block.Height, &data); err != nil {
return data, errors.Wrap(err, "parse genesis validators")
}
if err := module.parseIbcRelayerAddresses(genesis.AppState.IbcRelayerAddresses, block.Height, &data); err != nil {
return data, errors.Wrap(err, "parse ibc relayer addresses")
}
block.Stats.SupplyChange = data.supply
data.block = block
return data, nil
}
func (module *Module) parseAccounts(accounts []types.Account, height pkgTypes.Level, data *parsedData) error {
for i := range accounts {
address := storage.Address{
Height: height,
Balance: []*storage.Balance{
{
Total: decimal.RequireFromString(accounts[i].Balance.String()),
Currency: currency.DefaultCurrency,
},
},
}
address.Hash = accounts[i].Address.Value
data.addresses[address.String()] = &address
data.supply = data.supply.Add(address.Balance[0].Total)
data.balanceUpdates = append(data.balanceUpdates, storage.BalanceUpdate{
Address: &address,
Update: address.Balance[0].Total,
Currency: address.Balance[0].Currency,
Height: 0,
})
}
return nil
}
func (module *Module) parseValidators(validators []types.Validator, height pkgTypes.Level, data *parsedData) error {
for i := range validators {
addr, err := astria.EncodeFromHex(validators[i].Address)
if err != nil {
return err
}
data.validators = append(data.validators, &storage.Validator{
Address: addr,
PubkeyType: validators[i].PubKey.Type,
PubKey: validators[i].PubKey.Value,
Name: validators[i].Name,
Power: decimal.RequireFromString(validators[i].Power),
})
if _, ok := data.addresses[addr]; !ok {
address := storage.Address{
Hash: addr,
Height: height,
Balance: []*storage.Balance{
{
Total: decimal.Zero,
Currency: currency.DefaultCurrency,
},
},
}
data.addresses[addr] = &address
}
}
return nil
}
func (module *Module) parseIbcRelayerAddresses(addresses []types.Bech32m, height pkgTypes.Level, data *parsedData) error {
for i := range addresses {
b32m := addresses[i].Value
if addr, ok := data.addresses[b32m]; ok {
addr.IsIbcRelayer = testsuite.Ptr(true)
} else {
data.addresses[b32m] = &storage.Address{
Height: height,
Balance: []*storage.Balance{
{
Total: decimal.Zero,
Currency: currency.DefaultCurrency,
},
},
IsIbcRelayer: testsuite.Ptr(true),
Hash: addresses[i].Value,
}
}
}
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package genesis
import (
"context"
"time"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
)
func (module *Module) save(ctx context.Context, data parsedData) error {
start := time.Now()
module.Log.Info().Uint64("height", uint64(data.block.Height)).Msg("saving block...")
tx, err := postgres.BeginTransaction(ctx, module.storage)
if err != nil {
return err
}
defer tx.Close(ctx)
if err := tx.SaveConstants(ctx, data.constants...); err != nil {
return tx.HandleError(ctx, err)
}
if err := tx.Add(ctx, &data.block); err != nil {
return tx.HandleError(ctx, err)
}
if err := tx.Add(ctx, data.block.Stats); err != nil {
return tx.HandleError(ctx, err)
}
if err := tx.SaveTransactions(ctx, data.block.Txs...); err != nil {
return tx.HandleError(ctx, err)
}
var totalAccounts int64
if len(data.addresses) > 0 {
entities := make([]*storage.Address, 0, len(data.addresses))
for key := range data.addresses {
entities = append(entities, data.addresses[key])
}
totalAccounts, err = tx.SaveAddresses(ctx, entities...)
if err != nil {
return tx.HandleError(ctx, err)
}
balances := make([]storage.Balance, 0)
for i := range entities {
for _, balance := range entities[i].Balance {
balances = append(balances, *balance)
}
}
if err := tx.SaveBalances(ctx, balances...); err != nil {
return tx.HandleError(ctx, err)
}
for i := range data.balanceUpdates {
if addr, ok := data.addresses[data.balanceUpdates[i].Address.String()]; ok {
data.balanceUpdates[i].AddressId = addr.Id
}
}
if err := tx.SaveBalanceUpdates(ctx, data.balanceUpdates...); err != nil {
return tx.HandleError(ctx, err)
}
}
if err := tx.SaveValidators(ctx, data.validators...); err != nil {
return tx.HandleError(ctx, err)
}
if err := tx.Add(ctx, &storage.State{
Name: module.indexerName,
LastHeight: data.block.Height,
LastTime: data.block.Time,
LastHash: data.block.Hash,
ChainId: data.block.ChainId,
TotalTx: data.block.Stats.TxCount,
TotalSupply: data.block.Stats.SupplyChange,
TotalAccounts: totalAccounts,
TotalValidators: len(data.validators),
}); err != nil {
return tx.HandleError(ctx, err)
}
if err := tx.Flush(ctx); err != nil {
return tx.HandleError(ctx, err)
}
module.Log.Info().
Uint64("height", data.block.Id).
Str("block_fee", data.block.Stats.Fee.String()).
Int64("ms", time.Since(start).Milliseconds()).
Msg("block saved")
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package indexer
import (
"context"
"github.com/dipdup-net/indexer-sdk/pkg/modules/stopper"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
sdkPg "github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
internalStorage "github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/indexer/genesis"
"github.com/celenium-io/astria-indexer/pkg/indexer/parser"
"github.com/celenium-io/astria-indexer/pkg/indexer/rollback"
"github.com/celenium-io/astria-indexer/pkg/indexer/storage"
"github.com/celenium-io/astria-indexer/pkg/node"
"github.com/celenium-io/astria-indexer/pkg/node/rpc"
"github.com/pkg/errors"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/celenium-io/astria-indexer/pkg/indexer/config"
"github.com/celenium-io/astria-indexer/pkg/indexer/receiver"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
type Indexer struct {
cfg *config.Config
api node.Api
receiver *receiver.Module
parser *parser.Module
storage *storage.Module
rollback *rollback.Module
genesis *genesis.Module
stopper modules.Module
log zerolog.Logger
states internalStorage.IState
bridges internalStorage.IBridge
}
func New(cfg *config.Config, pg *sdkPg.Storage, stopperModule modules.Module) (Indexer, error) {
states := postgres.NewState(pg)
blocks := postgres.NewBlocks(pg)
bridges := postgres.NewBridge(pg)
notificator := postgres.NewNotificator(cfg.Database, pg)
api, r, err := createReceiver(cfg)
if err != nil {
return Indexer{}, errors.Wrap(err, "while creating receiver module")
}
rb, err := createRollback(r, pg.Transactable, states, blocks, &api, cfg.Indexer)
if err != nil {
return Indexer{}, errors.Wrap(err, "while creating rollback module")
}
p, err := createParser(r, &api)
if err != nil {
return Indexer{}, errors.Wrap(err, "while creating parser module")
}
s, err := createStorage(pg.Transactable, notificator, cfg, p)
if err != nil {
return Indexer{}, errors.Wrap(err, "while creating storage module")
}
genesisModule, err := createGenesis(pg.Transactable, cfg, r)
if err != nil {
return Indexer{}, errors.Wrap(err, "while creating genesis module")
}
err = attachStopper(stopperModule, r, p, s, rb, genesisModule)
if err != nil {
return Indexer{}, errors.Wrap(err, "while creating stopper module")
}
return Indexer{
cfg: cfg,
api: &api,
receiver: r,
parser: p,
storage: s,
rollback: rb,
genesis: genesisModule,
stopper: stopperModule,
log: log.With().Str("module", "indexer").Logger(),
states: states,
bridges: bridges,
}, nil
}
func (i *Indexer) Start(ctx context.Context) {
i.log.Info().Msg("starting...")
state, err := loadState(ctx, i.states, i.cfg.Indexer.Name)
if err != nil {
log.Err(err).Msg("load state")
}
i.receiver.Init(state)
assets, err := makeBridgeAssetsMap(ctx, i.bridges)
if err != nil {
log.Err(err).Msg("make bridge asset map")
}
i.parser.Init(ctx, assets)
i.genesis.Start(ctx)
i.storage.Start(ctx)
i.parser.Start(ctx)
i.receiver.Start(ctx)
}
func (i *Indexer) Close() error {
i.log.Info().Msg("closing...")
if err := i.receiver.Close(); err != nil {
log.Err(err).Msg("closing receiver")
}
if err := i.genesis.Close(); err != nil {
log.Err(err).Msg("closing genesis")
}
if err := i.parser.Close(); err != nil {
log.Err(err).Msg("closing parser")
}
if err := i.storage.Close(); err != nil {
log.Err(err).Msg("closing storage")
}
if err := i.rollback.Close(); err != nil {
log.Err(err).Msg("closing rollback")
}
return nil
}
func createReceiver(cfg *config.Config) (rpc.API, *receiver.Module, error) {
api := rpc.NewAPI(cfg.DataSources["sequencer_rpc"])
receiverModule := receiver.NewModule(cfg.Indexer, &api)
return api, &receiverModule, nil
}
func createRollback(receiverModule modules.Module, tx sdk.Transactable, states internalStorage.IState, blocks internalStorage.IBlock, api node.Api, cfg config.Indexer) (*rollback.Module, error) {
rollbackModule := rollback.NewModule(tx, states, blocks, api, cfg)
// rollback <- listen signal -- receiver
if err := rollbackModule.AttachTo(receiverModule, receiver.RollbackOutput, rollback.InputName); err != nil {
return nil, errors.Wrap(err, "while attaching rollback to receiver")
}
// receiver <- listen state -- rollback
if err := receiverModule.AttachTo(&rollbackModule, rollback.OutputName, receiver.RollbackInput); err != nil {
return nil, errors.Wrap(err, "while attaching receiver to rollback")
}
return &rollbackModule, nil
}
func makeBridgeAssetsMap(ctx context.Context, bridges internalStorage.IBridge) (map[string]string, error) {
assets := make(map[string]string)
for end := false; !end; {
data, err := bridges.ListWithAddress(ctx, 100, len(assets))
if err != nil {
return nil, err
}
for i := range data {
assets[data[i].Address.Hash] = data[i].Asset
}
end = len(data) < 100
}
return assets, nil
}
func createParser(receiverModule modules.Module, api node.Api) (*parser.Module, error) {
parserModule := parser.NewModule(api)
if err := parserModule.AttachTo(receiverModule, receiver.BlocksOutput, parser.InputName); err != nil {
return nil, errors.Wrap(err, "while attaching parser to receiver")
}
return &parserModule, nil
}
func createStorage(tx sdk.Transactable, notificator internalStorage.Notificator, cfg *config.Config, parserModule modules.Module) (*storage.Module, error) {
storageModule := storage.NewModule(tx, notificator, cfg.Indexer)
if err := storageModule.AttachTo(parserModule, parser.OutputName, storage.InputName); err != nil {
return nil, errors.Wrap(err, "while attaching storage to parser")
}
return &storageModule, nil
}
func createGenesis(tx sdk.Transactable, cfg *config.Config, receiverModule modules.Module) (*genesis.Module, error) {
genesisModule := genesis.NewModule(tx, cfg.Indexer)
if err := genesisModule.AttachTo(receiverModule, receiver.GenesisOutput, genesis.InputName); err != nil {
return nil, errors.Wrap(err, "while attaching genesis to receiver")
}
genesisModulePtr := &genesisModule
if err := receiverModule.AttachTo(genesisModulePtr, genesis.OutputName, receiver.GenesisDoneInput); err != nil {
return nil, errors.Wrap(err, "while attaching receiver to genesis")
}
return genesisModulePtr, nil
}
func attachStopper(stopperModule modules.Module, receiverModule modules.Module, parserModule modules.Module, storageModule modules.Module, rollbackModule modules.Module, genesisModule modules.Module) error {
if err := stopperModule.AttachTo(receiverModule, receiver.StopOutput, stopper.InputName); err != nil {
return errors.Wrap(err, "while attaching stopper to receiver")
}
if err := stopperModule.AttachTo(parserModule, parser.StopOutput, stopper.InputName); err != nil {
return errors.Wrap(err, "while attaching stopper to parser")
}
if err := stopperModule.AttachTo(storageModule, storage.StopOutput, stopper.InputName); err != nil {
return errors.Wrap(err, "while attaching stopper to storage")
}
if err := stopperModule.AttachTo(rollbackModule, rollback.StopOutput, stopper.InputName); err != nil {
return errors.Wrap(err, "while attaching stopper to rollback")
}
if err := stopperModule.AttachTo(genesisModule, genesis.StopOutput, stopper.InputName); err != nil {
return errors.Wrap(err, "while attaching stopper to genesis")
}
return nil
}
func loadState(ctx context.Context, states internalStorage.IState, indexerName string) (*internalStorage.State, error) {
state, err := states.ByName(ctx, indexerName)
if err != nil {
if states.IsNoRows(err) {
return nil, nil
}
return nil, err
}
return &state, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package parser
import (
"context"
"github.com/celenium-io/astria-indexer/pkg/types"
)
func (p *Module) listen(ctx context.Context) {
p.Log.Info().Msg("module started")
input := p.MustInput(InputName)
for {
select {
case <-ctx.Done():
return
case msg, ok := <-input.Listen():
if !ok {
p.Log.Warn().Msg("can't read message from input, it was drained and closed")
p.MustOutput(StopOutput).Push(struct{}{})
return
}
block, ok := msg.(types.BlockData)
if !ok {
p.Log.Warn().Msgf("invalid message type: %T", msg)
continue
}
if err := p.parse(ctx, block); err != nil {
p.Log.Err(err).
Uint64("height", uint64(block.Height)).
Msg("block parsing error")
p.MustOutput(StopOutput).Push(struct{}{})
continue
}
}
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package parser
import (
"context"
"encoding/hex"
"strings"
"time"
"github.com/celenium-io/astria-indexer/internal/astria"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/indexer/decode"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
"github.com/shopspring/decimal"
)
func (p *Module) parse(ctx context.Context, b types.BlockData) error {
start := time.Now()
p.Log.Info().
Int64("height", b.Block.Height).
Msg("parsing block...")
proposer, err := astria.EncodeFromHex(b.Block.ProposerAddress.String())
if err != nil {
return errors.Wrap(err, "decoding block proposer address")
}
decodeCtx := decode.NewContext(p.bridgeAssets, b.Block.Time)
decodeCtx.Proposer = proposer
if err := parseEvents(ctx, b.FinalizeBlockEvents, b.Height, &decodeCtx, p.api); err != nil {
return errors.Wrap(err, "parse finalize events")
}
txs, err := parseTxs(ctx, b, &decodeCtx, p.api)
if err != nil {
return errors.Wrapf(err, "while parsing block on level=%d", b.Height)
}
block := &storage.Block{
Height: b.Height,
Time: b.Block.Time,
VersionBlock: b.Block.Version.Block,
VersionApp: b.Block.Version.App,
Hash: []byte(b.BlockID.Hash),
ParentHash: []byte(b.Block.LastBlockID.Hash),
LastCommitHash: b.Block.LastCommitHash,
DataHash: b.Block.DataHash,
ValidatorsHash: b.Block.ValidatorsHash,
NextValidatorsHash: b.Block.NextValidatorsHash,
ConsensusHash: b.Block.ConsensusHash,
AppHash: b.Block.AppHash,
LastResultsHash: b.Block.LastResultsHash,
EvidenceHash: b.Block.EvidenceHash,
ProposerAddress: proposer,
ChainId: b.Block.ChainID,
Addresses: decodeCtx.Addresses,
Rollups: decodeCtx.Rollups,
RollupAddress: decodeCtx.RollupAddress,
Validators: decodeCtx.Validators,
ActionTypes: decodeCtx.ActionTypes,
Constants: decodeCtx.ConstantsArray(),
Bridges: decodeCtx.BridgesArray(),
Transfers: decodeCtx.Transfers,
Txs: txs,
Stats: &storage.BlockStats{
Height: b.Height,
Time: b.Block.Time,
TxCount: int64(len(txs)),
Fee: decimal.Zero,
SupplyChange: decodeCtx.SupplyChange,
BytesInBlock: decodeCtx.BytesInBlock,
DataSize: decodeCtx.DataSize,
},
Prices: decodeCtx.Prices,
MarketUpdates: decodeCtx.Markets,
MarketProviders: decodeCtx.MarketProviders,
}
block.BlockSignatures = p.parseBlockSignatures(b.Block.LastCommit)
p.Log.Info().
Uint64("height", uint64(block.Height)).
Int64("ms", time.Since(start).Milliseconds()).
Msg("block parsed")
output := p.MustOutput(OutputName)
output.Push(block)
return nil
}
func (p *Module) parseBlockSignatures(commit *types.Commit) []storage.BlockSignature {
signs := make([]storage.BlockSignature, 0)
for i := range commit.Signatures {
if commit.Signatures[i].BlockIDFlag != 2 {
continue
}
signs = append(signs, storage.BlockSignature{
Height: types.Level(commit.Height),
Time: commit.Signatures[i].Timestamp,
Validator: &storage.Validator{
Address: strings.ToUpper(hex.EncodeToString(commit.Signatures[i].ValidatorAddress)),
},
})
}
return signs
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package parser
import (
"context"
"encoding/base64"
"strconv"
"strings"
"time"
astria "buf.build/gen/go/astria/protocol-apis/protocolbuffers/go/astria/protocol/asset/v1alpha1"
"github.com/celenium-io/astria-indexer/internal/currency"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/indexer/decode"
"github.com/celenium-io/astria-indexer/pkg/node"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
"github.com/shopspring/decimal"
"google.golang.org/protobuf/proto"
)
func parseEvents(ctx context.Context, events []types.Event, height types.Level, decodeCtx *decode.Context, api node.Api) error {
for i := range events {
var err error
switch events[i].Type {
case "tx.fees":
err = parseTxFees(ctx, events[i].Attributes, decodeCtx, api)
case "tx.deposit":
err = parseTxDeposit(events[i].Attributes, height, decodeCtx)
case "write_acknowledgement":
err = parseWriteAck(events[i].Attributes, decodeCtx)
case "price_update":
err = parsePriceUpdate(events[i].Attributes, decodeCtx)
default:
continue
}
if err != nil {
return errors.Wrap(err, events[i].Type)
}
}
return nil
}
var (
assets = map[string]string{
"704031c868fd3d3c84a1cfa8cb45deba4ea746b44697f7f4a6ed1b8f6c239b82": string(currency.Nria),
}
)
func getAsset(ctx context.Context, api node.Api, val string) (string, error) {
if !strings.HasPrefix(val, "ibc") {
return val, nil
}
parts := strings.Split(val, "/")
hash := parts[len(parts)-1]
if asset, ok := assets[hash]; ok {
return asset, nil
}
timeoutCtx, cancel := context.WithTimeout(ctx, time.Second*10)
defer cancel()
metadata, err := api.GetAssetInfo(timeoutCtx, hash)
if err != nil {
return "", errors.Wrap(err, val)
}
var response astria.DenomResponse
if err := proto.Unmarshal(metadata.Response.Value, &response); err != nil {
return "", errors.Wrap(err, val)
}
assets[hash] = response.GetDenom()
return response.GetDenom(), nil
}
func parseTxFees(ctx context.Context, attrs []types.EventAttribute, decodeCtx *decode.Context, api node.Api) error {
var (
fee = new(storage.Fee)
err error
idx int64
)
for i := range attrs {
switch attrs[i].Key {
case "asset":
asset, err := getAsset(ctx, api, attrs[i].Value)
if err != nil {
return err
}
fee.Asset = asset
case "feeAmount":
fee.Amount, err = decimal.NewFromString(attrs[i].Value)
if err != nil {
return err
}
case "actionName":
fee.ActionType = attrs[i].Value
case "positionInTransaction":
actionIndex, err := strconv.ParseInt(attrs[i].Value, 10, 64)
if err != nil {
return err
}
idx = actionIndex
case "sourceActionIndex":
actionIndex, err := strconv.ParseInt(attrs[i].Value, 10, 64)
if err != nil {
return err
}
idx = actionIndex
default:
}
}
decodeCtx.AddFee(idx, fee)
return nil
}
func parseTxDeposit(attrs []types.EventAttribute, height types.Level, decodeCtx *decode.Context) error {
deposit := new(storage.Deposit)
var idx int64
for i := range attrs {
switch attrs[i].Key {
case "bridgeAddress":
addr := decodeCtx.Addresses.Set(attrs[i].Value, height, decimal.Zero, currency.DefaultCurrency, 0, 0)
deposit.Bridge = &storage.Bridge{
Address: addr,
}
case "rollupId":
hash, err := base64.URLEncoding.DecodeString(attrs[i].Value)
if err != nil {
return err
}
deposit.Rollup = &storage.Rollup{
AstriaId: hash,
}
case "amount":
amount, err := decimal.NewFromString(attrs[i].Value)
if err != nil {
return err
}
deposit.Amount = amount
case "asset":
deposit.Asset = attrs[i].Value
case "destinationChainAddress":
deposit.DestinationChainAddress = attrs[i].Value
case "sourceTransactionId":
case "sourceActionIndex":
actionIndex, err := strconv.ParseInt(attrs[i].Value, 10, 64)
if err != nil {
return err
}
idx = actionIndex
}
}
decodeCtx.AddDeposit(idx, deposit)
return nil
}
func parseWriteAck(attrs []types.EventAttribute, decodeCtx *decode.Context) error {
for i := range attrs {
switch attrs[i].Key {
case "packet_ack":
decodeCtx.HasWriteAckError = strings.Contains(attrs[i].Value, "error")
default:
}
}
return nil
}
func parsePriceUpdate(attrs []types.EventAttribute, decodeCtx *decode.Context) error {
var price storage.Price
for i := range attrs {
switch attrs[i].Key {
case "currency_pair":
price.CurrencyPair = strings.ReplaceAll(attrs[i].Value, "/", "_")
case "price":
p, err := decimal.NewFromString(attrs[i].Value)
if err != nil {
return errors.Wrapf(err, "price parsing error %s", attrs[i].Value)
}
price.Price = p
default:
}
}
decodeCtx.AddPrice(price)
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package parser
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
storageTypes "github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/celenium-io/astria-indexer/pkg/indexer/decode"
"github.com/celenium-io/astria-indexer/pkg/node"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
)
func parseTxs(ctx context.Context, b types.BlockData, decodeCtx *decode.Context, api node.Api) ([]*storage.Tx, error) {
txs := make([]*storage.Tx, 0)
for i := 0; i < len(b.TxsResults); i++ {
if err := parseEvents(ctx, b.TxsResults[i].Events, b.Height, decodeCtx, api); err != nil {
return nil, errors.Wrap(err, "parse events")
}
t, err := parseTx(b, i, decodeCtx)
if err != nil {
return nil, err
}
if len(t.Hash) == 0 {
continue
}
txs = append(txs, &t)
decodeCtx.ClearTx()
}
return txs, nil
}
func parseTx(b types.BlockData, index int, ctx *decode.Context) (storage.Tx, error) {
d, err := decode.Tx(b, index, ctx)
if err != nil {
return storage.Tx{}, errors.Wrapf(err, "while parsing Tx on index %d", index)
}
if d.IsDataItem {
return storage.Tx{}, nil
}
result := b.TxsResults[index]
t := storage.Tx{
Height: b.Height,
Time: b.Block.Time,
Position: int64(index),
ActionsCount: int64(len(d.Actions)),
Status: storageTypes.StatusSuccess,
Codespace: result.Codespace,
Hash: b.Block.Txs[index].Hash(),
Signature: d.Tx.GetSignature(),
Nonce: d.UnsignedTx.GetParams().GetNonce(),
Signer: d.Signer,
ActionTypes: d.ActionTypes,
Actions: d.Actions,
BytesSize: int64(len(result.Data)),
}
if result.IsFailed() {
t.Status = storageTypes.StatusFailed
t.Error = result.Log
}
return t, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package parser
import (
"context"
"github.com/celenium-io/astria-indexer/pkg/node"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
)
type Module struct {
modules.BaseModule
api node.Api
bridgeAssets map[string]string
}
var _ modules.Module = (*Module)(nil)
const (
InputName = "blocks"
OutputName = "data"
StopOutput = "stop"
)
func NewModule(api node.Api) Module {
m := Module{
BaseModule: modules.New("parser"),
api: api,
}
m.CreateInput(InputName)
m.CreateOutput(OutputName)
m.CreateOutput(StopOutput)
return m
}
func (p *Module) Init(ctx context.Context, bridgeAssets map[string]string) {
p.bridgeAssets = bridgeAssets
}
func (p *Module) Start(ctx context.Context) {
p.Log.Info().Msg("starting parser module...")
p.G.GoCtx(ctx, p.listen)
}
func (p *Module) Close() error {
p.Log.Info().Msg("closing...")
p.G.Wait()
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package receiver
import "context"
func (r *Module) receiveGenesis(ctx context.Context) error {
r.Log.Info().Msg("receiving genesis block")
genesis, err := r.api.Genesis(ctx)
if err != nil {
return err
}
r.Log.Info().Msgf("got initial height of genesis block: %d", genesis.InitialHeight)
r.MustOutput(GenesisOutput).Push(genesis)
genesisDoneInput := r.MustInput(GenesisDoneInput)
// Wait until the genesis block will be saved
for {
select {
case <-ctx.Done():
return nil
case <-genesisDoneInput.Listen():
return nil
}
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package receiver
import (
"context"
"sync"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/indexer/config"
"github.com/celenium-io/astria-indexer/pkg/node"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-io/workerpool"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
sdkSync "github.com/dipdup-net/indexer-sdk/pkg/sync"
"github.com/rs/zerolog/log"
)
const (
BlocksOutput = "blocks"
RollbackOutput = "signal"
RollbackInput = "state"
GenesisOutput = "genesis"
GenesisDoneInput = "genesis_done"
StopOutput = "stop"
)
// Module - runs through a chain with aim ti catch-up head and identifies either block is fits in sequence or signals of rollback.
//
// |----------------|
// | | -- types.BlockData -> BlocksOutput
// | MODULE |
// | Receiver | -- struct{} -> RollbackOutput
// | | <- storage.State -- RollbackInput
// |----------------|
type Module struct {
modules.BaseModule
api node.Api
cfg config.Indexer
pool *workerpool.Pool[types.Level]
blocks chan types.BlockData
level types.Level
hash []byte
needGenesis bool
taskQueue *sdkSync.Map[types.Level, struct{}]
mx *sync.RWMutex
rollbackSync *sync.WaitGroup
cancelWorkers context.CancelFunc
cancelReadBlocks context.CancelFunc
}
var _ modules.Module = (*Module)(nil)
func NewModule(cfg config.Indexer, api node.Api) Module {
receiver := Module{
BaseModule: modules.New("receiver"),
api: api,
cfg: cfg,
blocks: make(chan types.BlockData, cfg.ThreadsCount*10),
needGenesis: true,
level: types.Level(cfg.StartLevel),
hash: []byte{},
taskQueue: sdkSync.NewMap[types.Level, struct{}](),
mx: new(sync.RWMutex),
rollbackSync: new(sync.WaitGroup),
}
receiver.CreateInput(RollbackInput)
receiver.CreateInput(GenesisDoneInput)
receiver.CreateOutput(BlocksOutput)
receiver.CreateOutput(RollbackOutput)
receiver.CreateOutput(GenesisOutput)
receiver.CreateOutput(StopOutput)
receiver.pool = workerpool.NewPool(receiver.worker, int(cfg.ThreadsCount))
return receiver
}
func (r *Module) Init(state *storage.State) {
r.needGenesis = state == nil
if state != nil {
r.level = state.LastHeight
r.hash = state.LastHash
}
}
func (r *Module) Start(ctx context.Context) {
r.Log.Info().Msg("starting receiver...")
workersCtx, cancelWorkers := context.WithCancel(ctx)
r.cancelWorkers = cancelWorkers
r.pool.Start(workersCtx)
if r.needGenesis {
if err := r.receiveGenesis(ctx); err != nil {
log.Err(err).Msg("receiving genesis error")
return
}
}
r.G.GoCtx(ctx, r.sequencer)
r.G.GoCtx(ctx, r.sync)
r.G.GoCtx(ctx, r.rollback)
}
func (r *Module) Close() error {
r.Log.Info().Msg("closing...")
r.G.Wait()
if err := r.pool.Close(); err != nil {
return err
}
close(r.blocks)
return nil
}
func (r *Module) Level() (types.Level, []byte) {
r.mx.RLock()
defer r.mx.RUnlock()
return r.level, r.hash
}
func (r *Module) setLevel(level types.Level, hash []byte) {
r.mx.Lock()
defer r.mx.Unlock()
r.level = level
r.hash = hash
}
func (r *Module) rollback(ctx context.Context) {
rollbackInput := r.MustInput(RollbackInput)
for {
select {
case <-ctx.Done():
return
case msg, ok := <-rollbackInput.Listen():
if !ok {
r.Log.Warn().Msg("can't read message from rollback input, channel is closed and drained")
continue
}
state, ok := msg.(storage.State)
if !ok {
r.Log.Warn().Msgf("invalid message type: %T", msg)
continue
}
r.taskQueue.Clear()
r.setLevel(state.LastHeight, state.LastHash)
r.Log.Info().Msgf("caught return from rollback to level=%d", state.LastHeight)
r.rollbackSync.Done()
}
}
}
func (r *Module) stopAll() {
r.MustOutput(StopOutput).Push(struct{}{})
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package receiver
import (
"bytes"
"context"
"encoding/hex"
"github.com/celenium-io/astria-indexer/pkg/types"
)
func (r *Module) sequencer(ctx context.Context) {
orderedBlocks := map[int64]types.BlockData{}
l, prevBlockHash := r.Level()
currentBlock := int64(l + 1)
for {
select {
case <-ctx.Done():
return
case block, ok := <-r.blocks:
if !ok {
r.Log.Warn().Msg("can't read message from blocks input, channel was dried and closed")
r.stopAll()
return
}
orderedBlocks[block.Block.Height] = block
b, ok := orderedBlocks[currentBlock]
for ok {
if prevBlockHash != nil {
if !bytes.Equal(b.Block.LastBlockID.Hash, prevBlockHash) {
prevBlockHash, currentBlock, orderedBlocks = r.startRollback(ctx, b, prevBlockHash)
break
}
}
r.MustOutput(BlocksOutput).Push(b)
r.setLevel(types.Level(currentBlock), b.BlockID.Hash)
r.Log.Debug().
Uint64("height", uint64(currentBlock)).
Msg("put in order block")
prevBlockHash = b.BlockID.Hash
delete(orderedBlocks, currentBlock)
currentBlock += 1
b, ok = orderedBlocks[currentBlock]
}
}
}
}
func (r *Module) startRollback(
ctx context.Context,
b types.BlockData,
prevBlockHash []byte,
) ([]byte, int64, map[int64]types.BlockData) {
r.Log.Info().
Str("current.lastBlockHash", hex.EncodeToString(b.Block.LastBlockID.Hash)).
Str("prevBlockHash", hex.EncodeToString(prevBlockHash)).
Uint64("level", uint64(b.Height)).
Msg("rollback detected")
// Pause all receiver routines
r.rollbackSync.Add(1)
// Stop readBlocks
if r.cancelReadBlocks != nil {
r.cancelReadBlocks()
}
// Stop pool workers
if r.cancelWorkers != nil {
r.cancelWorkers()
}
clearChannel(r.blocks)
// Start rollback
r.MustOutput(RollbackOutput).Push(struct{}{})
// Wait until rollback will be finished
r.rollbackSync.Wait()
// Reset empty state
level, hash := r.Level()
currentBlock := int64(level)
prevBlockHash = hash
orderedBlocks := map[int64]types.BlockData{}
// Restart workers pool that read blocks
workersCtx, cancelWorkers := context.WithCancel(ctx)
r.cancelWorkers = cancelWorkers
r.pool.Start(workersCtx)
return prevBlockHash, currentBlock, orderedBlocks
}
func clearChannel(blocks <-chan types.BlockData) {
for len(blocks) > 0 {
<-blocks
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package receiver
import (
"context"
"time"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
)
func (r *Module) sync(ctx context.Context) {
var blocksCtx context.Context
blocksCtx, r.cancelReadBlocks = context.WithCancel(ctx)
if err := r.readBlocks(blocksCtx); err != nil {
r.Log.Err(err).Msg("while reading blocks")
r.stopAll()
return
}
if ctx.Err() != nil {
return
}
ticker := time.NewTicker(time.Second * time.Duration(r.cfg.BlockPeriod))
defer ticker.Stop()
for {
r.rollbackSync.Wait()
select {
case <-ctx.Done():
return
case <-ticker.C:
blocksCtx, r.cancelReadBlocks = context.WithCancel(ctx)
if err := r.readBlocks(blocksCtx); err != nil && !errors.Is(err, context.Canceled) {
r.Log.Err(err).Msg("while reading blocks by timer")
r.stopAll()
return
}
}
}
}
func (r *Module) readBlocks(ctx context.Context) error {
for {
headLevel, err := r.headLevel(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
return nil
}
return err
}
if level, _ := r.Level(); level == headLevel {
time.Sleep(time.Second)
continue
}
r.passBlocks(ctx, headLevel)
return nil
}
}
func (r *Module) passBlocks(ctx context.Context, head types.Level) {
level, _ := r.Level()
level += 1
for ; level <= head; level++ {
select {
case <-ctx.Done():
return
default:
if _, ok := r.taskQueue.Get(level); !ok {
r.taskQueue.Set(level, struct{}{})
r.pool.AddTask(level)
}
}
}
}
func (r *Module) headLevel(ctx context.Context) (types.Level, error) {
status, err := r.api.Status(ctx)
if err != nil {
return 0, err
}
return status.SyncInfo.LatestBlockHeight, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package receiver
import (
"context"
"time"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
)
func (r *Module) worker(ctx context.Context, level types.Level) {
defer r.taskQueue.Delete(level)
start := time.Now()
var result types.BlockData
for {
select {
case <-ctx.Done():
return
default:
}
requestTimeout, cancel := context.WithTimeout(ctx, time.Minute)
block, err := r.api.BlockDataGet(requestTimeout, level)
if err != nil {
cancel()
if errors.Is(err, context.Canceled) {
return
}
r.Log.Err(err).
Uint64("height", uint64(level)).
Msg("while getting block data")
time.Sleep(time.Second)
continue
}
result = block
cancel()
break
}
r.Log.Info().
Uint64("height", uint64(result.Height)).
Int64("ms", time.Since(start).Milliseconds()).
Msg("received block")
r.blocks <- result
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rollback
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
)
func rollbackAddress(
ctx context.Context,
tx storage.Transaction,
height types.Level,
addressActions []storage.AddressAction,
txs []storage.Tx,
) (int, error) {
deletedAddresses, err := tx.RollbackAddresses(ctx, height)
if err != nil {
return 0, err
}
if err := rollbackBalances(ctx, tx, deletedAddresses, height); err != nil {
return 0, err
}
addresses := make(map[uint64]*storage.Address, 0)
for i := range addressActions {
if addr, ok := addresses[addressActions[i].AddressId]; ok {
addr.ActionsCount -= 1
} else {
nonce, err := tx.LastNonce(ctx, addressActions[i].AddressId)
if err != nil {
return 0, err
}
addresses[addressActions[i].AddressId] = &storage.Address{
Id: addressActions[i].AddressId,
ActionsCount: -1,
Nonce: nonce,
}
}
}
for i := range txs {
if addr, ok := addresses[txs[i].SignerId]; ok {
addr.SignedTxCount -= 1
addr.ActionsCount -= 1
} else {
addresses[addressActions[i].AddressId] = &storage.Address{
Id: txs[i].SignerId,
SignedTxCount: -1,
ActionsCount: -1,
}
}
}
arr := make([]*storage.Address, 0)
for i := range addresses {
arr = append(arr, addresses[i])
}
if err := tx.UpdateAddresses(ctx, arr...); err != nil {
return 0, err
}
return len(deletedAddresses), nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rollback
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
)
func rollbackBalances(
ctx context.Context,
tx storage.Transaction,
deletedAddresses []storage.Address,
height types.Level,
) error {
ids := make([]uint64, len(deletedAddresses))
for i := range deletedAddresses {
ids[i] = deletedAddresses[i].Id
}
if err := tx.RollbackBalances(ctx, ids); err != nil {
return err
}
if err := getBalanceUpdates(ctx, tx, height); err != nil {
return err
}
return nil
}
func getBalanceUpdates(
ctx context.Context,
tx storage.Transaction,
height types.Level,
) error {
balances := make(map[uint64]*storage.Balance)
updates, err := tx.RollbackBalanceUpdates(ctx, height)
if err != nil {
return err
}
if len(updates) == 0 {
return nil
}
for i := range updates {
updateBalances(balances, updates[i])
}
arr := make([]storage.Balance, 0)
for _, b := range balances {
arr = append(arr, *b)
}
return tx.SaveBalances(ctx, arr...)
}
func updateBalances(m map[uint64]*storage.Balance, update storage.BalanceUpdate) {
if addr, ok := m[update.AddressId]; ok {
addr.Total = addr.Total.Sub(update.Update)
} else {
m[update.AddressId] = &storage.Balance{
Total: update.Update.Neg(),
Id: update.AddressId,
Currency: update.Currency,
}
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rollback
import (
"bytes"
"context"
"github.com/celenium-io/astria-indexer/pkg/node"
"github.com/celenium-io/astria-indexer/pkg/indexer/config"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
const (
InputName = "signal"
OutputName = "state"
StopOutput = "stop"
)
// Module - executes rollback on signal from input and notify all subscribers about new state after rollback operation.
//
// |----------------|
// | |
// -- struct{} -> | MODULE | -- storage.State ->
// | |
// |----------------|
type Module struct {
modules.BaseModule
tx sdk.Transactable
state storage.IState
blocks storage.IBlock
node node.Api
indexName string
}
var _ modules.Module = (*Module)(nil)
func NewModule(
tx sdk.Transactable,
state storage.IState,
blocks storage.IBlock,
node node.Api,
cfg config.Indexer,
) Module {
module := Module{
BaseModule: modules.New("rollback"),
tx: tx,
state: state,
blocks: blocks,
node: node,
indexName: cfg.Name,
}
module.CreateInput(InputName)
module.CreateOutput(OutputName)
module.CreateOutput(StopOutput)
return module
}
// Start -
func (module *Module) Start(ctx context.Context) {
module.G.GoCtx(ctx, module.listen)
}
func (module *Module) listen(ctx context.Context) {
module.Log.Info().Msg("module started")
input := module.MustInput(InputName)
for {
select {
case <-ctx.Done():
return
case _, ok := <-input.Listen():
if !ok {
module.Log.Warn().Msg("can't read message from input, channel was dried and closed")
module.MustOutput(StopOutput).Push(struct{}{})
return
}
if err := module.rollback(ctx); err != nil {
module.Log.Err(err).Msgf("error occurred")
}
}
}
}
// Close -
func (module *Module) Close() error {
module.Log.Info().Msg("closing module...")
module.G.Wait()
return nil
}
func (module *Module) rollback(ctx context.Context) error {
for {
select {
case <-ctx.Done():
default:
lastBlock, err := module.blocks.Last(ctx)
if err != nil {
return errors.Wrap(err, "receive last block from database")
}
nodeBlock, err := module.node.Block(ctx, lastBlock.Height)
if err != nil {
return errors.Wrapf(err, "receive block from node by height: %d", lastBlock.Height)
}
log.Debug().
Uint64("height", uint64(lastBlock.Height)).
Hex("db_block_hash", lastBlock.Hash).
Hex("node_block_hash", nodeBlock.BlockID.Hash).
Msg("comparing hash...")
if bytes.Equal(lastBlock.Hash, nodeBlock.BlockID.Hash) {
return module.finish(ctx)
}
log.Warn().
Uint64("height", uint64(lastBlock.Height)).
Hex("db_block_hash", lastBlock.Hash).
Hex("node_block_hash", nodeBlock.BlockID.Hash).
Msg("need rollback")
if err := module.rollbackBlock(ctx, lastBlock.Height); err != nil {
return errors.Wrapf(err, "rollback block: %d", lastBlock.Height)
}
}
}
}
func (module *Module) finish(ctx context.Context) error {
newState, err := module.state.ByName(ctx, module.indexName)
if err != nil {
return err
}
module.MustOutput(OutputName).Push(newState)
log.Info().
Uint64("new_height", uint64(newState.LastHeight)).
Msg("roll backed to new height")
return nil
}
func (module *Module) rollbackBlock(ctx context.Context, height types.Level) error {
tx, err := postgres.BeginTransaction(ctx, module.tx)
if err != nil {
return err
}
defer tx.Close(ctx)
if err := rollbackBlock(ctx, tx, height, module.indexName); err != nil {
return tx.HandleError(ctx, err)
}
return nil
}
func rollbackBlock(ctx context.Context, tx storage.Transaction, height types.Level, indexName string) error {
if err := tx.RollbackBlock(ctx, height); err != nil {
return err
}
blockStats, err := tx.RollbackBlockStats(ctx, height)
if err != nil {
return err
}
txs, err := tx.RollbackTxs(ctx, height)
if err != nil {
return err
}
actions, err := tx.RollbackActions(ctx, height)
if err != nil {
return err
}
addressActions, err := tx.RollbackAddressActions(ctx, height)
if err != nil {
return err
}
countDeletedAddresses, err := rollbackAddress(ctx, tx, height, addressActions, txs)
if err != nil {
return errors.Wrap(err, "address")
}
countDeletedRollups, err := rollbackRollups(ctx, tx, height, actions)
if err != nil {
return errors.Wrap(err, "rollups")
}
if err := tx.RollbackValidators(ctx, height); err != nil {
return err
}
if err := tx.RollbackFees(ctx, height); err != nil {
return err
}
if err := tx.RollbackDeposits(ctx, height); err != nil {
return err
}
if err := tx.RollbackTransfers(ctx, height); err != nil {
return err
}
if err := tx.RollbackBlockSignatures(ctx, height); err != nil {
return err
}
deletedBridges, err := tx.RollbackBridges(ctx, height)
if err != nil {
return errors.Wrap(err, "bridges")
}
newBlock, err := tx.LastBlock(ctx)
if err != nil {
return err
}
state, err := tx.State(ctx, indexName)
if err != nil {
return err
}
state.LastHeight = newBlock.Height
state.LastHash = newBlock.Hash
state.LastTime = newBlock.Time
state.TotalTx -= blockStats.TxCount
state.TotalAccounts -= int64(countDeletedAddresses)
state.TotalRollups -= countDeletedRollups
state.TotalSupply = state.TotalSupply.Sub(blockStats.SupplyChange)
state.TotalBridges -= int64(deletedBridges)
if err := tx.Update(ctx, &state); err != nil {
return err
}
return tx.Flush(ctx)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rollback
import (
"context"
"encoding/base64"
"github.com/celenium-io/astria-indexer/internal/storage"
storageTypes "github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
)
func rollbackRollups(
ctx context.Context,
tx storage.Transaction,
height types.Level,
actions []storage.Action,
) (int64, error) {
rollups, err := tx.RollbackRollups(ctx, height)
if err != nil {
return 0, err
}
rollbackActions, err := tx.RollbackRollupActions(ctx, height)
if err != nil {
return 0, err
}
if err := tx.RollbackRollupAddresses(ctx, height); err != nil {
return 0, err
}
m := make(map[uint64]*storage.Rollup)
for i := range rollups {
m[rollups[i].Id] = &rollups[i]
}
mapActions := make(map[uint64]storage.Action)
for i := range actions {
mapActions[actions[i].Id] = actions[i]
}
updates := make(map[uint64]*storage.Rollup)
for i := range rollbackActions {
if _, ok := m[rollbackActions[i].RollupId]; ok {
continue
}
action, ok := mapActions[rollbackActions[i].ActionId]
if !ok {
return 0, errors.Errorf("can't find action with id: %d", rollbackActions[i].ActionId)
}
if err := updateRollups(updates, rollbackActions[i].RollupId, action); err != nil {
return 0, err
}
}
arr := make([]*storage.Rollup, 0)
for i := range updates {
arr = append(arr, updates[i])
}
if err := tx.UpdateRollups(ctx, arr...); err != nil {
return 0, err
}
return int64(len(rollups)), nil
}
func updateRollups(updates map[uint64]*storage.Rollup, rollupId uint64, action storage.Action) error {
if action.Type != storageTypes.ActionTypeRollupDataSubmission {
return errors.Errorf("invalid action type: %s", action.Type)
}
size, err := getActionSize(action)
if err != nil {
return err
}
if update, ok := updates[rollupId]; ok {
update.ActionsCount -= 1
update.Size -= size
} else {
updates[rollupId] = &storage.Rollup{
Id: rollupId,
Size: -size,
ActionsCount: -1,
}
}
return nil
}
func getActionSize(action storage.Action) (int64, error) {
data, ok := action.Data["data"]
if !ok {
return 0, errors.Errorf("can't find 'data' in (%d) %##v", action.Id, action.Data)
}
str, ok := data.(string)
if !ok {
return 0, errors.Errorf("invalid 'data' type in (%d) %##v", action.Id, action.Data)
}
bytes, err := base64.StdEncoding.DecodeString(str)
if err != nil {
return 0, err
}
return int64(len(bytes)), nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/pkg/errors"
)
func saveAction(
ctx context.Context,
tx storage.Transaction,
actions []*storage.Action,
addrToId map[string]uint64,
) error {
if len(actions) == 0 {
return nil
}
if err := tx.SaveActions(ctx, actions...); err != nil {
return err
}
var (
rollupActions = make([]*storage.RollupAction, 0)
addrActions = make([]*storage.AddressAction, 0)
balanceUpdates = make([]storage.BalanceUpdate, 0)
fees = make([]*storage.Fee, 0)
deposits = make([]*storage.Deposit, 0)
)
for i := range actions {
if actions[i].RollupAction != nil {
actions[i].RollupAction.ActionId = actions[i].Id
actions[i].RollupAction.RollupId = actions[i].RollupAction.Rollup.Id
actions[i].RollupAction.TxId = actions[i].TxId
rollupActions = append(rollupActions, actions[i].RollupAction)
}
for j := range actions[i].Addresses {
actions[i].Addresses[j].ActionId = actions[i].Id
actions[i].Addresses[j].AddressId = actions[i].Addresses[j].Address.Id
actions[i].Addresses[j].TxId = actions[i].TxId
}
addrActions = append(addrActions, actions[i].Addresses...)
for j := range actions[i].BalanceUpdates {
actions[i].BalanceUpdates[j].AddressId = actions[i].BalanceUpdates[j].Address.Id
}
balanceUpdates = append(balanceUpdates, actions[i].BalanceUpdates...)
if actions[i].Fee != nil {
actions[i].Fee.ActionId = actions[i].Id
actions[i].Fee.TxId = actions[i].TxId
if payerId, ok := addrToId[actions[i].Fee.Payer.Hash]; ok {
actions[i].Fee.PayerId = payerId
} else {
return errors.Errorf("unknown payer id: %s", actions[i].Fee.Payer.Hash)
}
fees = append(fees, actions[i].Fee)
}
if actions[i].Deposit != nil {
actions[i].Deposit.ActionId = actions[i].Id
actions[i].Deposit.TxId = actions[i].TxId
addrId, ok := addrToId[actions[i].Deposit.Bridge.Address.Hash]
if !ok {
id, err := tx.GetAddressId(ctx, actions[i].Deposit.Bridge.Address.Hash)
if err != nil {
return errors.Wrapf(err, "receiving deposit bridge address: %s", actions[i].Deposit.Bridge.Address.Hash)
}
addrId = id
}
bridgeId, err := tx.GetBridgeIdByAddressId(ctx, addrId)
if err != nil {
return errors.Wrap(err, "receiving deposit bridge id")
}
actions[i].Deposit.BridgeId = bridgeId
rollup, err := tx.GetRollup(ctx, actions[i].Deposit.Rollup.AstriaId)
if err != nil {
return errors.Errorf("unknown deposit rollup id: %x", actions[i].Deposit.Rollup.AstriaId)
}
actions[i].Deposit.RollupId = rollup.Id
deposits = append(deposits, actions[i].Deposit)
}
}
if err := tx.SaveRollupActions(ctx, rollupActions...); err != nil {
return err
}
if err := tx.SaveAddressActions(ctx, addrActions...); err != nil {
return err
}
if err := tx.SaveBalanceUpdates(ctx, balanceUpdates...); err != nil {
return err
}
if err := tx.SaveFees(ctx, fees...); err != nil {
return err
}
if err := tx.SaveDeposits(ctx, deposits...); err != nil {
return err
}
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
)
func saveAddresses(
ctx context.Context,
tx storage.Transaction,
addresses map[string]*storage.Address,
) (map[string]uint64, int64, error) {
if len(addresses) == 0 {
return nil, 0, nil
}
data := make([]*storage.Address, 0, len(addresses))
for key := range addresses {
data = append(data, addresses[key])
}
totalAccounts, err := tx.SaveAddresses(ctx, data...)
if err != nil {
return nil, 0, err
}
addToId := make(map[string]uint64)
balances := make([]storage.Balance, 0)
for i := range data {
addToId[data[i].String()] = data[i].Id
for j := range data[i].Balance {
data[i].Balance[j].Id = data[i].Id
balances = append(balances, *data[i].Balance[j])
}
}
err = tx.SaveBalances(ctx, balances...)
return addToId, totalAccounts, err
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/astria"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
"github.com/pkg/errors"
)
const (
countOfStoringSignsInLevels = 1_000
)
func (module *Module) saveBlockSignatures(
ctx context.Context,
tx storage.Transaction,
signs []storage.BlockSignature,
height types.Level,
) error {
retentionLevel := height - countOfStoringSignsInLevels
if retentionLevel > 0 && retentionLevel%100 == 0 {
if err := tx.RetentionBlockSignatures(ctx, retentionLevel); err != nil {
return err
}
}
if len(signs) == 0 {
return nil
}
if len(module.validators) == 0 {
validators, err := tx.Validators(ctx)
if err != nil {
return err
}
module.validators = make(map[string]uint64)
for i := range validators {
module.validators[validators[i].Address] = validators[i].Id
}
}
for i := range signs {
if signs[i].Validator == nil {
return errors.New("nil validator of block signature")
}
val, err := astria.EncodeFromHex(signs[i].Validator.Address)
if err != nil {
return err
}
if id, ok := module.validators[val]; ok {
signs[i].ValidatorId = id
} else {
return errors.Errorf("unknown validator: %s", val)
}
}
return tx.SaveBlockSignatures(ctx, signs...)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/pkg/errors"
)
func saveBridges(
ctx context.Context,
tx storage.Transaction,
addrToId map[string]uint64,
bridges []*storage.Bridge,
) (int64, error) {
if len(bridges) == 0 {
return 0, nil
}
for i := range bridges {
if id, ok := addrToId[bridges[i].Address.Hash]; ok {
bridges[i].AddressId = id
} else {
return 0, errors.Errorf("unknown bridge address: %s", bridges[i].Address.Hash)
}
if bridges[i].Sudo != nil {
if id, ok := addrToId[bridges[i].Sudo.Hash]; ok {
bridges[i].SudoId = id
} else {
return 0, errors.Errorf("unknown sudo bridge address: %s", bridges[i].Sudo.Hash)
}
}
if bridges[i].Withdrawer != nil {
if id, ok := addrToId[bridges[i].Withdrawer.Hash]; ok {
bridges[i].WithdrawerId = id
} else {
return 0, errors.Errorf("unknown withdrawer bridge address: %s", bridges[i].Withdrawer.Hash)
}
}
if bridges[i].Rollup != nil {
if bridges[i].Rollup.Id == 0 {
rollup, err := tx.GetRollup(ctx, bridges[i].Rollup.AstriaId)
if err != nil {
return 0, err
}
bridges[i].RollupId = rollup.Id
} else {
bridges[i].RollupId = bridges[i].Rollup.Id
}
}
}
return tx.SaveBridges(ctx, bridges...)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
)
func (module *Module) saveRollup(
ctx context.Context,
tx storage.Transaction,
rollups map[string]*storage.Rollup,
rollupAddress map[string]*storage.RollupAddress,
) (int64, int64, error) {
if len(rollups) == 0 {
return 0, 0, nil
}
var totalSize int64
data := make([]*storage.Rollup, 0)
for _, value := range rollups {
data = append(data, value)
totalSize += value.Size
}
count, err := tx.SaveRollups(ctx, data...)
if err != nil {
return count, totalSize, err
}
ra := make([]*storage.RollupAddress, 0)
for _, value := range rollupAddress {
value.RollupId = value.Rollup.Id
value.AddressId = value.Address.Id
ra = append(ra, value)
}
if err := tx.SaveRollupAddresses(ctx, ra...); err != nil {
return 0, 0, err
}
return count, totalSize, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/pkg/types"
)
func updateState(block *storage.Block, totalAccounts, totalRollups, totalBridges, totalBytes int64, state *storage.State) {
if types.Level(block.Id) <= state.LastHeight {
return
}
state.LastHeight = block.Height
state.LastHash = block.Hash
state.LastTime = block.Time
state.TotalTx += block.Stats.TxCount
state.TotalAccounts += totalAccounts
state.TotalRollups += totalRollups
state.TotalBridges += totalBridges
state.TotalBytes += totalBytes
state.TotalSupply = state.TotalSupply.Add(block.Stats.SupplyChange)
state.ChainId = block.ChainId
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"encoding/json"
"strconv"
"time"
"github.com/celenium-io/astria-indexer/pkg/indexer/config"
"github.com/pkg/errors"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/celenium-io/astria-indexer/internal/storage/postgres"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
)
const (
InputName = "data"
StopOutput = "stop"
)
// Module - saves received from input block to storage.
//
// |----------------|
// | |
// -- storage.Block -> | MODULE |
// | |
// |----------------|
type Module struct {
modules.BaseModule
storage sdk.Transactable
notificator storage.Notificator
indexerName string
validators map[string]uint64
}
var _ modules.Module = (*Module)(nil)
// NewModule -
func NewModule(
storage sdk.Transactable,
notificator storage.Notificator,
cfg config.Indexer,
) Module {
m := Module{
BaseModule: modules.New("storage"),
storage: storage,
indexerName: cfg.Name,
notificator: notificator,
validators: make(map[string]uint64),
}
m.CreateInputWithCapacity(InputName, 16)
m.CreateOutput(StopOutput)
return m
}
// Start -
func (module *Module) Start(ctx context.Context) {
module.G.GoCtx(ctx, module.listen)
}
func (module *Module) listen(ctx context.Context) {
module.Log.Info().Msg("module started")
input := module.MustInput(InputName)
for {
select {
case <-ctx.Done():
return
case msg, ok := <-input.Listen():
if !ok {
module.Log.Warn().Msg("can't read message from input")
module.MustOutput(StopOutput).Push(struct{}{})
continue
}
block, ok := msg.(*storage.Block)
if !ok {
module.Log.Warn().Msgf("invalid message type: %T", msg)
continue
}
state, err := module.saveBlock(ctx, block)
if err != nil {
module.Log.Err(err).
Uint64("height", uint64(block.Height)).
Msg("block saving error")
module.MustOutput(StopOutput).Push(struct{}{})
continue
}
if err := module.notify(ctx, state, block); err != nil {
module.Log.Err(err).Msg("block notification error")
}
}
}
}
// Close -
func (module *Module) Close() error {
module.Log.Info().Msg("closing module...")
module.G.Wait()
return nil
}
func (module *Module) saveBlock(ctx context.Context, block *storage.Block) (storage.State, error) {
start := time.Now()
module.Log.Info().Uint64("height", uint64(block.Height)).Msg("saving block...")
tx, err := postgres.BeginTransaction(ctx, module.storage)
if err != nil {
return storage.State{}, err
}
defer tx.Close(ctx)
state, err := module.processBlockInTransaction(ctx, tx, block)
if err != nil {
return state, tx.HandleError(ctx, err)
}
if err := tx.Flush(ctx); err != nil {
return state, tx.HandleError(ctx, err)
}
module.Log.Info().
Uint64("height", uint64(block.Height)).
Time("block_time", block.Time).
Int64("ms", time.Since(start).Milliseconds()).
Int("tx_count", len(block.Txs)).
Msg("block saved")
return state, nil
}
func (module *Module) processBlockInTransaction(ctx context.Context, tx storage.Transaction, block *storage.Block) (storage.State, error) {
state, err := tx.State(ctx, module.indexerName)
if err != nil {
return state, err
}
block.Stats.BlockTime = uint64(block.Time.Sub(state.LastTime).Milliseconds())
if len(module.validators) > 0 {
if id, ok := module.validators[block.ProposerAddress]; ok {
block.ProposerId = id
} else {
return state, errors.Errorf("unknown block proposer: %s", block.ProposerAddress)
}
} else {
proposerId, err := tx.GetProposerId(ctx, block.ProposerAddress)
if err != nil {
return state, errors.Wrap(err, "can't find block proposer")
}
block.ProposerId = proposerId
}
if err := tx.Add(ctx, block); err != nil {
return state, err
}
if err := tx.Add(ctx, block.Stats); err != nil {
return state, err
}
if err := tx.UpdateConstants(ctx, block.Constants...); err != nil {
return state, err
}
if err := tx.SaveMarkets(ctx, block.MarketUpdates...); err != nil {
return state, errors.Wrap(err, "can't save market updates")
}
if err := tx.SaveMarketProviders(ctx, block.MarketProviders...); err != nil {
return state, errors.Wrap(err, "can't save market provider updates")
}
if err := tx.SavePrices(ctx, block.Prices...); err != nil {
return state, errors.Wrap(err, "can't save prices")
}
addrToId, totalAccounts, err := saveAddresses(ctx, tx, block.Addresses)
if err != nil {
return state, err
}
if err := module.saveTransactions(ctx, tx, addrToId, block.Txs...); err != nil {
return state, err
}
totalRollups, totalBytes, err := module.saveRollup(ctx, tx, block.Rollups, block.RollupAddress)
if err != nil {
return state, err
}
totalBridges, err := saveBridges(ctx, tx, addrToId, block.Bridges)
if err != nil {
return state, err
}
if err := saveTransfers(ctx, tx, block.Transfers, addrToId); err != nil {
return state, err
}
var actions = make([]*storage.Action, 0)
for i := range block.Txs {
for j := range block.Txs[i].Actions {
block.Txs[i].Actions[j].TxId = block.Txs[i].Id
actions = append(actions, &block.Txs[i].Actions[j])
}
}
if err := saveAction(ctx, tx, actions, addrToId); err != nil {
return state, err
}
if err := module.saveBlockSignatures(ctx, tx, block.BlockSignatures, block.Height); err != nil {
return state, err
}
if err := module.saveValidators(ctx, tx, block.Validators); err != nil {
return state, err
}
updateState(block, totalAccounts, totalRollups, totalBridges, totalBytes, &state)
if err := tx.Update(ctx, &state); err != nil {
return state, err
}
return state, nil
}
func (module *Module) notify(ctx context.Context, state storage.State, block *storage.Block) error {
if time.Since(block.Time) > time.Hour {
// do not notify all about events if initial indexing is in progress
return nil
}
rawState, err := json.Marshal(state)
if err != nil {
return err
}
if err := module.notificator.Notify(ctx, storage.ChannelHead, string(rawState)); err != nil {
return err
}
blockId := strconv.FormatUint(block.Id, 10)
if err := module.notificator.Notify(ctx, storage.ChannelBlock, blockId); err != nil {
return err
}
for i := range block.Constants {
raw, err := json.Marshal(block.Constants[i])
if err != nil {
return err
}
if err := module.notificator.Notify(ctx, storage.ChannelConstant, string(raw)); err != nil {
return err
}
}
return nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
)
func saveTransfers(
ctx context.Context,
tx storage.Transaction,
transfers []*storage.Transfer,
addrToId map[string]uint64,
) error {
for i := range transfers {
if transfers[i].Source != nil {
if id, ok := addrToId[transfers[i].Source.Hash]; ok {
transfers[i].SourceId = id
}
}
if transfers[i].Destination != nil {
if id, ok := addrToId[transfers[i].Destination.Hash]; ok {
transfers[i].DestinationId = id
}
}
}
return tx.SaveTransfers(ctx, transfers...)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
"github.com/pkg/errors"
)
func (module *Module) saveTransactions(
ctx context.Context,
tx storage.Transaction,
addrToId map[string]uint64,
txs ...*storage.Tx,
) error {
if len(txs) == 0 {
return nil
}
for i := range txs {
if signerId, ok := addrToId[txs[i].Signer.String()]; ok {
txs[i].SignerId = signerId
} else {
return errors.Errorf("unknown signer id")
}
}
return tx.SaveTransactions(ctx, txs...)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/astria-indexer/internal/storage"
)
func (module *Module) saveValidators(
ctx context.Context,
tx storage.Transaction,
validators map[string]*storage.Validator,
) error {
if len(validators) == 0 {
return nil
}
vals := make([]*storage.Validator, 0)
for _, val := range validators {
vals = append(vals, val)
}
if err := tx.SaveValidators(ctx, vals...); err != nil {
return err
}
for i := range vals {
if _, ok := module.validators[vals[i].Address]; !ok {
module.validators[vals[i].Address] = vals[i].Id
}
}
return nil
}
// Code generated by MockGen. DO NOT EDIT.
// Source: api.go
//
// Generated by this command:
//
// mockgen -source=api.go -destination=mock/api.go -package=mock -typed
//
// Package mock is a generated GoMock package.
package mock
import (
context "context"
reflect "reflect"
types "github.com/celenium-io/astria-indexer/pkg/node/types"
types0 "github.com/celenium-io/astria-indexer/pkg/types"
gomock "go.uber.org/mock/gomock"
)
// MockApi is a mock of Api interface.
type MockApi struct {
ctrl *gomock.Controller
recorder *MockApiMockRecorder
}
// MockApiMockRecorder is the mock recorder for MockApi.
type MockApiMockRecorder struct {
mock *MockApi
}
// NewMockApi creates a new mock instance.
func NewMockApi(ctrl *gomock.Controller) *MockApi {
mock := &MockApi{ctrl: ctrl}
mock.recorder = &MockApiMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockApi) EXPECT() *MockApiMockRecorder {
return m.recorder
}
// Block mocks base method.
func (m *MockApi) Block(ctx context.Context, level types0.Level) (types0.ResultBlock, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Block", ctx, level)
ret0, _ := ret[0].(types0.ResultBlock)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Block indicates an expected call of Block.
func (mr *MockApiMockRecorder) Block(ctx, level any) *MockApiBlockCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Block", reflect.TypeOf((*MockApi)(nil).Block), ctx, level)
return &MockApiBlockCall{Call: call}
}
// MockApiBlockCall wrap *gomock.Call
type MockApiBlockCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockApiBlockCall) Return(arg0 types0.ResultBlock, arg1 error) *MockApiBlockCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockApiBlockCall) Do(f func(context.Context, types0.Level) (types0.ResultBlock, error)) *MockApiBlockCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockApiBlockCall) DoAndReturn(f func(context.Context, types0.Level) (types0.ResultBlock, error)) *MockApiBlockCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// BlockData mocks base method.
func (m *MockApi) BlockData(ctx context.Context, level types0.Level) (types0.BlockData, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BlockData", ctx, level)
ret0, _ := ret[0].(types0.BlockData)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// BlockData indicates an expected call of BlockData.
func (mr *MockApiMockRecorder) BlockData(ctx, level any) *MockApiBlockDataCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockData", reflect.TypeOf((*MockApi)(nil).BlockData), ctx, level)
return &MockApiBlockDataCall{Call: call}
}
// MockApiBlockDataCall wrap *gomock.Call
type MockApiBlockDataCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockApiBlockDataCall) Return(arg0 types0.BlockData, arg1 error) *MockApiBlockDataCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockApiBlockDataCall) Do(f func(context.Context, types0.Level) (types0.BlockData, error)) *MockApiBlockDataCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockApiBlockDataCall) DoAndReturn(f func(context.Context, types0.Level) (types0.BlockData, error)) *MockApiBlockDataCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// BlockDataGet mocks base method.
func (m *MockApi) BlockDataGet(ctx context.Context, level types0.Level) (types0.BlockData, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BlockDataGet", ctx, level)
ret0, _ := ret[0].(types0.BlockData)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// BlockDataGet indicates an expected call of BlockDataGet.
func (mr *MockApiMockRecorder) BlockDataGet(ctx, level any) *MockApiBlockDataGetCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockDataGet", reflect.TypeOf((*MockApi)(nil).BlockDataGet), ctx, level)
return &MockApiBlockDataGetCall{Call: call}
}
// MockApiBlockDataGetCall wrap *gomock.Call
type MockApiBlockDataGetCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockApiBlockDataGetCall) Return(arg0 types0.BlockData, arg1 error) *MockApiBlockDataGetCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockApiBlockDataGetCall) Do(f func(context.Context, types0.Level) (types0.BlockData, error)) *MockApiBlockDataGetCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockApiBlockDataGetCall) DoAndReturn(f func(context.Context, types0.Level) (types0.BlockData, error)) *MockApiBlockDataGetCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// BlockResults mocks base method.
func (m *MockApi) BlockResults(ctx context.Context, level types0.Level) (types0.ResultBlockResults, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BlockResults", ctx, level)
ret0, _ := ret[0].(types0.ResultBlockResults)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// BlockResults indicates an expected call of BlockResults.
func (mr *MockApiMockRecorder) BlockResults(ctx, level any) *MockApiBlockResultsCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockResults", reflect.TypeOf((*MockApi)(nil).BlockResults), ctx, level)
return &MockApiBlockResultsCall{Call: call}
}
// MockApiBlockResultsCall wrap *gomock.Call
type MockApiBlockResultsCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockApiBlockResultsCall) Return(arg0 types0.ResultBlockResults, arg1 error) *MockApiBlockResultsCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockApiBlockResultsCall) Do(f func(context.Context, types0.Level) (types0.ResultBlockResults, error)) *MockApiBlockResultsCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockApiBlockResultsCall) DoAndReturn(f func(context.Context, types0.Level) (types0.ResultBlockResults, error)) *MockApiBlockResultsCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Genesis mocks base method.
func (m *MockApi) Genesis(ctx context.Context) (types.Genesis, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Genesis", ctx)
ret0, _ := ret[0].(types.Genesis)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Genesis indicates an expected call of Genesis.
func (mr *MockApiMockRecorder) Genesis(ctx any) *MockApiGenesisCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Genesis", reflect.TypeOf((*MockApi)(nil).Genesis), ctx)
return &MockApiGenesisCall{Call: call}
}
// MockApiGenesisCall wrap *gomock.Call
type MockApiGenesisCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockApiGenesisCall) Return(arg0 types.Genesis, arg1 error) *MockApiGenesisCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockApiGenesisCall) Do(f func(context.Context) (types.Genesis, error)) *MockApiGenesisCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockApiGenesisCall) DoAndReturn(f func(context.Context) (types.Genesis, error)) *MockApiGenesisCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// GetAssetInfo mocks base method.
func (m *MockApi) GetAssetInfo(ctx context.Context, asset string) (types.DenomMetadataResponse, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAssetInfo", ctx, asset)
ret0, _ := ret[0].(types.DenomMetadataResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetAssetInfo indicates an expected call of GetAssetInfo.
func (mr *MockApiMockRecorder) GetAssetInfo(ctx, asset any) *MockApiGetAssetInfoCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAssetInfo", reflect.TypeOf((*MockApi)(nil).GetAssetInfo), ctx, asset)
return &MockApiGetAssetInfoCall{Call: call}
}
// MockApiGetAssetInfoCall wrap *gomock.Call
type MockApiGetAssetInfoCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockApiGetAssetInfoCall) Return(arg0 types.DenomMetadataResponse, arg1 error) *MockApiGetAssetInfoCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockApiGetAssetInfoCall) Do(f func(context.Context, string) (types.DenomMetadataResponse, error)) *MockApiGetAssetInfoCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockApiGetAssetInfoCall) DoAndReturn(f func(context.Context, string) (types.DenomMetadataResponse, error)) *MockApiGetAssetInfoCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Head mocks base method.
func (m *MockApi) Head(ctx context.Context) (types0.ResultBlock, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Head", ctx)
ret0, _ := ret[0].(types0.ResultBlock)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Head indicates an expected call of Head.
func (mr *MockApiMockRecorder) Head(ctx any) *MockApiHeadCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Head", reflect.TypeOf((*MockApi)(nil).Head), ctx)
return &MockApiHeadCall{Call: call}
}
// MockApiHeadCall wrap *gomock.Call
type MockApiHeadCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockApiHeadCall) Return(arg0 types0.ResultBlock, arg1 error) *MockApiHeadCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockApiHeadCall) Do(f func(context.Context) (types0.ResultBlock, error)) *MockApiHeadCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockApiHeadCall) DoAndReturn(f func(context.Context) (types0.ResultBlock, error)) *MockApiHeadCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Status mocks base method.
func (m *MockApi) Status(ctx context.Context) (types.Status, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Status", ctx)
ret0, _ := ret[0].(types.Status)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Status indicates an expected call of Status.
func (mr *MockApiMockRecorder) Status(ctx any) *MockApiStatusCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Status", reflect.TypeOf((*MockApi)(nil).Status), ctx)
return &MockApiStatusCall{Call: call}
}
// MockApiStatusCall wrap *gomock.Call
type MockApiStatusCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockApiStatusCall) Return(arg0 types.Status, arg1 error) *MockApiStatusCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockApiStatusCall) Do(f func(context.Context) (types.Status, error)) *MockApiStatusCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockApiStatusCall) DoAndReturn(f func(context.Context) (types.Status, error)) *MockApiStatusCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rpc
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"time"
"github.com/celenium-io/astria-indexer/pkg/node/types"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/dipdup-net/go-lib/config"
"github.com/rs/zerolog/log"
"golang.org/x/time/rate"
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary
const (
userAgent = "Astria Indexer"
)
type API struct {
client *http.Client
cfg config.DataSource
rps int
rateLimit *rate.Limiter
log zerolog.Logger
}
func NewAPI(cfg config.DataSource) API {
rps := cfg.RequestsPerSecond
if cfg.RequestsPerSecond < 1 || cfg.RequestsPerSecond > 100 {
rps = 10
}
t := http.DefaultTransport.(*http.Transport).Clone()
t.MaxIdleConns = rps
t.MaxConnsPerHost = rps
t.MaxIdleConnsPerHost = rps
return API{
client: &http.Client{
Transport: t,
},
cfg: cfg,
rps: rps,
rateLimit: rate.NewLimiter(rate.Every(time.Second/time.Duration(rps)), rps),
log: log.With().Str("module", "node rpc").Logger(),
}
}
func (api *API) get(ctx context.Context, path string, args map[string]string, output any) error {
u, err := url.Parse(api.cfg.URL)
if err != nil {
return err
}
u.Path, err = url.JoinPath(u.Path, path)
if err != nil {
return err
}
values := u.Query()
for key, value := range args {
values.Add(key, value)
}
u.RawQuery = values.Encode()
if api.rateLimit != nil {
if err := api.rateLimit.Wait(ctx); err != nil {
return err
}
}
start := time.Now()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
if err != nil {
return err
}
req.Header.Set("User-Agent", userAgent)
response, err := api.client.Do(req)
if err != nil {
return err
}
defer closeWithLogError(response.Body, api.log)
api.log.Trace().
Int64("ms", time.Since(start).Milliseconds()).
Str("url", u.String()).
Msg("request")
if response.StatusCode != http.StatusOK {
return errors.Errorf("invalid status: %d", response.StatusCode)
}
err = json.NewDecoder(response.Body).Decode(output)
return err
}
func (api *API) post(ctx context.Context, requests []types.Request, output any) error {
u, err := url.Parse(api.cfg.URL)
if err != nil {
return err
}
body := new(bytes.Buffer)
if err := json.NewEncoder(body).Encode(requests); err != nil {
return errors.Wrap(err, "invalid bulk post request")
}
if api.rateLimit != nil {
if err := api.rateLimit.Wait(ctx); err != nil {
return err
}
}
start := time.Now()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, u.String(), body)
if err != nil {
return err
}
req.Header.Set("User-Agent", userAgent)
response, err := api.client.Do(req)
if err != nil {
return err
}
defer closeWithLogError(response.Body, api.log)
api.log.Trace().
Int64("ms", time.Since(start).Milliseconds()).
Str("url", u.String()).
Msg("post request")
if response.StatusCode != http.StatusOK {
return errors.Errorf("invalid status: %d", response.StatusCode)
}
err = json.NewDecoder(response.Body).Decode(output)
return err
}
func closeWithLogError(stream io.ReadCloser, log zerolog.Logger) {
if _, err := io.Copy(io.Discard, stream); err != nil {
log.Err(err).Msg("api copy GET body response to discard")
}
if err := stream.Close(); err != nil {
log.Err(err).Msg("api close GET body request")
}
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rpc
import (
"context"
"fmt"
"github.com/celenium-io/astria-indexer/pkg/node/types"
"github.com/pkg/errors"
)
const pathAbciQuery = "abci_query"
func (api *API) GetAssetInfo(ctx context.Context, asset string) (types.DenomMetadataResponse, error) {
args := make(map[string]string)
args["path"] = fmt.Sprintf(`"asset/denom/%s"`, asset)
var gbr types.Response[types.DenomMetadataResponse]
if err := api.get(ctx, pathAbciQuery, args, &gbr); err != nil {
return gbr.Result, errors.Wrap(err, "api.get")
}
if gbr.Error != nil {
return gbr.Result, errors.Wrapf(types.ErrRequest, "request %d error: %s", gbr.Id, gbr.Error.Error())
}
return gbr.Result, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rpc
import (
"context"
"strconv"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/celenium-io/astria-indexer/pkg/node/types"
"github.com/pkg/errors"
)
const pathBlock = "block"
func (api *API) Block(ctx context.Context, level pkgTypes.Level) (pkgTypes.ResultBlock, error) {
args := make(map[string]string)
if level != 0 {
args["height"] = strconv.FormatUint(uint64(level), 10)
}
var gbr types.Response[pkgTypes.ResultBlock]
if err := api.get(ctx, pathBlock, args, &gbr); err != nil {
return gbr.Result, errors.Wrap(err, "api.get")
}
if gbr.Error != nil {
return gbr.Result, errors.Wrapf(types.ErrRequest, "request %d error: %s", gbr.Id, gbr.Error.Error())
}
return gbr.Result, nil
}
func (api *API) BlockData(ctx context.Context, level pkgTypes.Level) (pkgTypes.BlockData, error) {
block := types.Response[pkgTypes.ResultBlock]{}
results := types.Response[pkgTypes.ResultBlockResults]{}
responses := []any{
&block,
&results,
}
levelString := level.String()
requests := []types.Request{
{
Method: pathBlock,
JsonRpc: "2.0",
Id: -1,
Params: []any{
levelString,
},
}, {
Method: pathBlockResults,
JsonRpc: "2.0",
Id: -1,
Params: []any{
levelString,
},
},
}
var blockData pkgTypes.BlockData
if err := api.post(ctx, requests, &responses); err != nil {
return blockData, errors.Wrap(err, "api.post")
}
if block.Error != nil {
return blockData, errors.Wrapf(types.ErrRequest, "request error: %s", block.Error.Error())
}
if results.Error != nil {
return blockData, errors.Wrapf(types.ErrRequest, "request error: %s", results.Error.Error())
}
blockData.ResultBlock = block.Result
blockData.ResultBlockResults = results.Result
return blockData, nil
}
func (api *API) BlockDataGet(ctx context.Context, level pkgTypes.Level) (pkgTypes.BlockData, error) {
var blockData pkgTypes.BlockData
block, err := api.Block(ctx, level)
if err != nil {
return blockData, errors.Wrapf(types.ErrRequest, "request error: %s", err.Error())
}
results, err := api.BlockResults(ctx, level)
if err != nil {
return blockData, errors.Wrapf(types.ErrRequest, "request error: %s", err.Error())
}
blockData.ResultBlock = block
blockData.ResultBlockResults = results
return blockData, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rpc
import (
"context"
"strconv"
"github.com/celenium-io/astria-indexer/pkg/node/types"
"github.com/pkg/errors"
)
type GenesisChunk struct {
Chunk int64 `json:"chunk,string"`
Total int64 `json:"total,string"`
Data []byte `json:"data"`
}
func (api *API) Genesis(ctx context.Context) (types.Genesis, error) {
path := "genesis_chunked"
genesisData := make([]byte, 0)
var chunk int64
var total int64
for chunk == 0 || chunk < total {
args := map[string]string{
"chunk": strconv.FormatInt(chunk, 10),
}
var gr types.Response[GenesisChunk]
if err := api.get(ctx, path, args, &gr); err != nil {
return types.Genesis{}, errors.Wrap(err, "genesis block request")
}
if gr.Error != nil {
return types.Genesis{}, errors.Wrapf(types.ErrRequest, "request %d error: %s", gr.Id, gr.Error.Error())
}
chunk += 1
total = gr.Result.Total
genesisData = append(genesisData, gr.Result.Data...)
}
var genesis types.Genesis
err := json.Unmarshal(genesisData, &genesis)
return genesis, err
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rpc
import (
"context"
"strconv"
pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/celenium-io/astria-indexer/pkg/node/types"
"github.com/pkg/errors"
)
const pathBlockResults = "block_results"
func (api *API) BlockResults(ctx context.Context, level pkgTypes.Level) (pkgTypes.ResultBlockResults, error) {
args := make(map[string]string)
if level != 0 {
args["height"] = strconv.FormatUint(uint64(level), 10)
}
var gbr types.Response[pkgTypes.ResultBlockResults]
if err := api.get(ctx, pathBlockResults, args, &gbr); err != nil {
return gbr.Result, errors.Wrap(err, "api.get")
}
if gbr.Error != nil {
return gbr.Result, errors.Wrapf(types.ErrRequest, "request %d error: %s", gbr.Id, gbr.Error.Error())
}
return gbr.Result, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rpc
import (
"context"
"github.com/celenium-io/astria-indexer/pkg/types"
)
func (api *API) Head(ctx context.Context) (types.ResultBlock, error) {
return api.Block(ctx, 0)
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package rpc
import (
"context"
"github.com/celenium-io/astria-indexer/pkg/node/types"
"github.com/pkg/errors"
)
const pathStatus = "status"
func (api *API) Status(ctx context.Context) (types.Status, error) {
var sr types.Response[types.Status]
if err := api.get(ctx, pathStatus, nil, &sr); err != nil {
return sr.Result, errors.Wrap(err, "api.get")
}
if sr.Error != nil {
return sr.Result, errors.Wrapf(types.ErrRequest, "status request %d error: %s", sr.Id, sr.Error.Error())
}
return sr.Result, nil
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package types
import (
"math/big"
"time"
"github.com/celenium-io/astria-indexer/pkg/types"
)
type Genesis struct {
GenesisTime time.Time `json:"genesis_time"`
ChainID string `json:"chain_id"`
InitialHeight int64 `json:"initial_height,string"`
ConsensusParams types.ConsensusParams `json:"consensus_params"`
AppHash types.Hex `json:"app_hash"`
AppState AppState `json:"app_state"`
Validators []Validator `json:"validators"`
}
type Validator struct {
Address string `json:"address"`
PubKey PubKey `json:"pub_key"`
Power string `json:"power"`
Name string `json:"name"`
}
type AppState struct {
Accounts []Account `json:"accounts"`
AddressesPrefixes Prefixes `json:"address_prefixes"`
AuthoritySudoAddress Bech32m `json:"authority_sudo_address"`
IbcSudoAddress Bech32m `json:"ibc_sudo_address"`
IbcRelayerAddresses []Bech32m `json:"ibc_relayer_addresses"`
NativeAssetBaseDenomination string `json:"native_asset_base_denomination"`
Fees Fees `json:"fees"`
AllowedFeeAssets []string `json:"allowed_fee_assets"`
}
type Account struct {
Address Bech32m `json:"address"`
Balance UInt128 `json:"balance"`
}
type Bech32m struct {
Value string `json:"bech32m"`
}
type Prefixes struct {
Base string `json:"base"`
}
type Fees struct {
Transfer Fee `json:"transfer"`
RollupDataSubmission Fee `json:"rollup_data_submission"`
Ics20Withdrawal Fee `json:"ics20_withdrawal"`
InitBridgeAccount Fee `json:"init_bridge_account"`
BridgeLock Fee `json:"bridge_lock"`
BridgeUnlock Fee `json:"bridge_unlock"`
BridgeSudoChange Fee `json:"bridge_sudo_change"`
BridgeTransfer Fee `json:"bridge_transfer"`
IbcRelay Fee `json:"ibc_relay"`
ValidatorUpdate Fee `json:"validator_update"`
FeeAssetChange Fee `json:"fee_asset_change"`
FeeChange Fee `json:"fee_change"`
IbcRelayerChange Fee `json:"ibc_relayer_change"`
SudoAddressChange Fee `json:"sudo_address_change"`
IbcSudoChange Fee `json:"ibc_sudo_change"`
PriceFeed Fee `json:"price_feed"`
}
type Fee struct {
Base UInt128 `json:"base"`
Multiplier UInt128 `json:"multiplier"`
}
type UInt128 struct {
Low uint64 `json:"lo"`
High uint64 `json:"hi"`
}
func (bi UInt128) String() string {
b := new(big.Int)
b = b.SetUint64(bi.High)
b = b.Lsh(b, 64)
lo := new(big.Int)
lo = lo.SetUint64(bi.Low)
b = b.Xor(b, lo)
return b.String()
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package types
import (
"encoding/json"
"fmt"
)
type Request struct {
Method string `json:"method"`
Params []any `json:"params"`
Id int64 `json:"id"`
JsonRpc string `json:"jsonrpc"`
}
type Response[T any] struct {
Id int64 `json:"id"`
JsonRpc string `json:"jsonrpc"`
Error *Error `json:"error,omitempty"`
Result T `json:"result"`
}
// Error -
type Error struct {
Code int64 `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data"`
}
// Error -
func (e Error) Error() string {
return fmt.Sprintf("code=%d message=%s data=%s", e.Code, e.Message, string(e.Data))
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package types
import (
"encoding/json"
"time"
)
// ResultBlockResults is an ABCI results from a block
type ResultBlockResults struct {
Height Level `json:"height,string"`
TxsResults []*ResponseDeliverTx `json:"txs_results"`
BeginBlockEvents []Event `json:"begin_block_events"`
FinalizeBlockEvents []Event `json:"finalize_block_events"`
ValidatorUpdates []ValidatorUpdate `json:"validator_updates"`
ConsensusParamUpdates *ConsensusParams `json:"consensus_param_updates"`
}
type ResponseDeliverTx struct {
Code uint32 `json:"code,omitempty" protobuf:"varint,1,opt,name=code,proto3"`
Data json.RawMessage `json:"data,omitempty" protobuf:"bytes,2,opt,name=data,proto3"`
Log string `json:"log,omitempty" protobuf:"bytes,3,opt,name=log,proto3"`
Info string `json:"info,omitempty" protobuf:"bytes,4,opt,name=info,proto3"`
Events []Event `json:"events,omitempty" protobuf:"bytes,7,rep,name=events,proto3"`
Codespace string `json:"codespace,omitempty" protobuf:"bytes,8,opt,name=codespace,proto3"`
}
func (tx *ResponseDeliverTx) IsFailed() bool {
return tx.Code != 0
}
// Event allows application developers to attach additional information to
// ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx.
// Later transactions may be queried using these events.
type Event struct {
Type string `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,proto3"`
Attributes []EventAttribute `json:"attributes,omitempty" protobuf:"bytes,2,rep,name=attributes,proto3"`
}
// EventAttribute is a single key-value pair, associated with an event.
type EventAttribute struct {
Key string `json:"key,omitempty" protobuf:"bytes,1,opt,name=key,proto3"`
Value string `json:"value,omitempty" protobuf:"bytes,2,opt,name=value,proto3"`
Index bool `json:"index,omitempty" protobuf:"varint,3,opt,name=index,proto3"`
}
// ValidatorUpdate
type ValidatorUpdate struct {
// PubKey any `json:"pub_key" protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3"` // crypto.PublicKey
Power int64 `json:"power,omitempty,string" protobuf:"varint,2,opt,name=power,proto3"`
}
// ConsensusParams contains all consensus-relevant parameters
// that can be adjusted by the abci app
type ConsensusParams struct {
Block *BlockParams `json:"block" protobuf:"bytes,1,opt,name=block,proto3"`
Evidence *EvidenceParams `json:"evidence" protobuf:"bytes,2,opt,name=evidence,proto3"`
Validator *ValidatorParams `json:"validator" protobuf:"bytes,3,opt,name=validator,proto3"`
Version *VersionParams `json:"version" protobuf:"bytes,4,opt,name=version,proto3"`
}
// BlockParams contains limits on the block size.
type BlockParams struct {
// Note: must be greater than 0
MaxBytes int64 `json:"max_bytes,omitempty,string" protobuf:"varint,1,opt,name=max_bytes,json=maxBytes,proto3"`
// Note: must be greater or equal to -1
MaxGas int64 `json:"max_gas,omitempty,string" protobuf:"varint,2,opt,name=max_gas,json=maxGas,proto3"`
}
// EvidenceParams determine how we handle evidence of malfeasance.
type EvidenceParams struct {
// Max age of evidence, in blocks.
//
// The basic formula for calculating this is: MaxAgeDuration / {average block
// time}.
MaxAgeNumBlocks int64 `json:"max_age_num_blocks,omitempty,string" protobuf:"varint,1,opt,name=max_age_num_blocks,json=maxAgeNumBlocks,proto3"`
// Max age of evidence, in time.
//
// It should correspond with an app's "unbonding period" or other similar
// mechanism for handling [Nothing-At-Stake
// attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed).
MaxAgeDuration time.Duration `json:"max_age_duration,string" protobuf:"bytes,2,opt,name=max_age_duration,json=maxAgeDuration,proto3,stdduration"`
// This sets the maximum size of total evidence in bytes that can be committed in a single block.
// And should fall comfortably under the max block bytes.
// Default is 1048576 or 1MB
MaxBytes int64 `json:"max_bytes,omitempty,string" protobuf:"varint,3,opt,name=max_bytes,json=maxBytes,proto3"`
}
// ValidatorParams restrict the public key types validators can use.
// NOTE: uses ABCI pubkey naming, not Amino names.
type ValidatorParams struct {
PubKeyTypes []string `json:"pub_key_types,omitempty" protobuf:"bytes,1,rep,name=pub_key_types,json=pubKeyTypes,proto3"`
}
// VersionParams contains the ABCI application version.
type VersionParams struct {
AppVersion uint64 `json:"app_version,omitempty,string" protobuf:"varint,1,opt,name=app_version,json=appVersion,proto3"`
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package types
import (
"bytes"
"database/sql/driver"
"encoding/hex"
"strconv"
"strings"
"github.com/pkg/errors"
)
type Hex []byte
var nullBytes = "null"
func HexFromString(s string) (Hex, error) {
data, err := hex.DecodeString(s)
if err != nil {
return nil, err
}
return Hex(data), nil
}
func (h *Hex) UnmarshalJSON(data []byte) error {
if h == nil {
return nil
}
if nullBytes == string(data) {
*h = nil
return nil
}
length := len(data)
if length%2 == 1 {
return errors.Errorf("odd hex length: %d %v", length, data)
}
if data[0] != '"' || data[length-1] != '"' {
return errors.Errorf("hex should be quotted string: got=%s", data)
}
data = bytes.Trim(data, `"`)
*h = make(Hex, hex.DecodedLen(length-1))
if length-1 == 0 {
return nil
}
_, err := hex.Decode(*h, data)
return err
}
func (h Hex) MarshalJSON() ([]byte, error) {
if h == nil {
return []byte(nullBytes), nil
}
return []byte(strconv.Quote(h.String())), nil
}
func (h *Hex) Scan(src interface{}) (err error) {
switch val := src.(type) {
case []byte:
*h = make(Hex, len(val))
_ = copy(*h, val)
case nil:
*h = make(Hex, 0)
default:
return errors.Errorf("unknown hex database type: %T", src)
}
return nil
}
var _ driver.Valuer = (*Hex)(nil)
func (h Hex) Value() (driver.Value, error) {
return []byte(h), nil
}
func (h Hex) Bytes() []byte {
return []byte(h)
}
func (h Hex) String() string {
return strings.ToUpper(hex.EncodeToString([]byte(h)))
}
// SPDX-FileCopyrightText: 2025 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package types
import "fmt"
type Level int64
func (l Level) String() string {
return fmt.Sprintf("%d", l)
}