decoder

package
v0.0.0-...-965f9eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	GetString(ctx context.Context, key string) (string, error)
	SetString(ctx context.Context, key string, value string, expiration time.Duration) error
}

Cache interface for storing and retrieving values

type DecodedCall

type DecodedCall struct {
	Function string                 `json:"function"`
	Params   map[string]interface{} `json:"params"`
}

DecodedCall represents a decoded transaction call

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder handles transaction decoding using ABI signatures

func NewDecoder

func NewDecoder(cache Cache, chainID string) *Decoder

NewDecoder creates a new transaction decoder

func (*Decoder) DecodeTransaction

func (d *Decoder) DecodeTransaction(ctx context.Context, tx *blockchain.Transaction) error

DecodeTransaction attempts to decode a transaction using cached ABI signatures

type FilterRule

type FilterRule struct {
	Field    string `json:"field"`    // Field to filter on (e.g., "to", "value", "method")
	Operator string `json:"operator"` // eq, neq, gt, lt, contains
	Value    string `json:"value"`    // Value to compare against
}

FilterRule defines a rule for filtering transactions

type MemoryCache

type MemoryCache struct {
	// contains filtered or unexported fields
}

MemoryCache implements an in-memory cache with TTL

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache creates a new in-memory cache

func (*MemoryCache) GetString

func (c *MemoryCache) GetString(ctx context.Context, key string) (string, error)

GetString retrieves a value from memory cache

func (*MemoryCache) SetString

func (c *MemoryCache) SetString(ctx context.Context, key string, value string, expiration time.Duration) error

SetString stores a value in memory cache with specified TTL

type RedisAdapter

type RedisAdapter struct {
	// contains filtered or unexported fields
}

RedisAdapter implements both Cache and RedisClient interfaces

func NewRedisAdapter

func NewRedisAdapter(client RedisClient) *RedisAdapter

NewRedisAdapter creates a new Redis adapter

func (*RedisAdapter) Close

func (c *RedisAdapter) Close() error

Close closes the Redis connection

func (*RedisAdapter) Get

func (c *RedisAdapter) Get(ctx context.Context, key string) *redis.StringCmd

Get implements both Cache.Get and RedisClient.Get

func (*RedisAdapter) GetString

func (c *RedisAdapter) GetString(ctx context.Context, key string) (string, error)

GetString implements Cache.Get by returning the string value

func (*RedisAdapter) Set

func (c *RedisAdapter) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd

Set implements both Cache.Set and RedisClient.Set

func (*RedisAdapter) SetClient

func (c *RedisAdapter) SetClient(client RedisClient)

SetClient sets the Redis client - used for testing

func (*RedisAdapter) SetString

func (c *RedisAdapter) SetString(ctx context.Context, key string, value string, expiration time.Duration) error

SetString implements Cache.Set by returning just the error

type RedisClient

type RedisClient interface {
	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Close() error
}

RedisClient is an interface for Redis operations

type RedisClientAdapter

type RedisClientAdapter struct {
	// contains filtered or unexported fields
}

RedisClientAdapter adapts redis.Client to RedisClient interface

func NewRedisClientAdapter

func NewRedisClientAdapter(client *redis.Client) *RedisClientAdapter

NewRedisClientAdapter creates a new Redis client adapter

func (*RedisClientAdapter) Close

func (c *RedisClientAdapter) Close() error

Close implements RedisClient.Close

func (*RedisClientAdapter) Get

func (c *RedisClientAdapter) Get(ctx context.Context, key string) *redis.StringCmd

Get implements RedisClient.Get

func (*RedisClientAdapter) GetCmd

func (c *RedisClientAdapter) GetCmd(ctx context.Context, key string) *redis.StringCmd

GetCmd implements RedisClient.GetCmd

func (*RedisClientAdapter) Set

func (c *RedisClientAdapter) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd

Set implements RedisClient.Set

func (*RedisClientAdapter) SetCmd

func (c *RedisClientAdapter) SetCmd(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd

SetCmd implements RedisClient.SetCmd

type SelectorCache

type SelectorCache struct {
	// contains filtered or unexported fields
}

SelectorCache provides fast access to ABI method selectors

func NewSelectorCache

func NewSelectorCache(redis RedisClient, chainID string) *SelectorCache

NewSelectorCache creates a new selector cache

func (*SelectorCache) Clear

func (c *SelectorCache) Clear()

Clear clears the in-memory cache

func (*SelectorCache) GetSelector

func (c *SelectorCache) GetSelector(ctx context.Context, selector string) (*SelectorEntry, error)

GetSelector retrieves a selector entry from cache or Redis

func (*SelectorCache) GetSelectorByAddress

func (c *SelectorCache) GetSelectorByAddress(ctx context.Context, address, selector string) (*SelectorEntry, error)

GetSelectorByAddress tries to get a selector specific to an address

func (*SelectorCache) SetTemplate

func (c *SelectorCache) SetTemplate(t *Template)

SetTemplate sets the current template for decoding

type SelectorEntry

type SelectorEntry struct {
	Name   string         `json:"name"`
	Inputs []abi.Argument `json:"inputs"`
	Method *abi.Method    `json:"-"`
}

SelectorEntry represents a cached ABI selector

type SignatureEntry

type SignatureEntry struct {
	Name   string         `json:"name"`
	Inputs []abi.Argument `json:"inputs"`
}

SignatureEntry represents an ABI function signature

type Template

type Template struct {
	Name      string       `json:"name"`
	ABI       string       `json:"abi"`
	Selectors []string     `json:"selectors"`
	Methods   []abi.Method `json:"methods"`
	Filters   []FilterRule `json:"filters"`
}

Template represents a transaction decoding template

type TemplateManager

type TemplateManager struct {
	// contains filtered or unexported fields
}

TemplateManager manages transaction decoding templates

func NewTemplateManager

func NewTemplateManager(redis RedisClient) *TemplateManager

NewTemplateManager creates a new template manager

func (*TemplateManager) ApplyTemplate

func (tm *TemplateManager) ApplyTemplate(tx map[string]interface{}, template *Template) bool

ApplyTemplate applies a template's filters to a transaction

func (*TemplateManager) GetTemplate

func (tm *TemplateManager) GetTemplate(ctx context.Context, name string) (*Template, error)

GetTemplate retrieves a template by name

func (*TemplateManager) SaveTemplate

func (tm *TemplateManager) SaveTemplate(ctx context.Context, template *Template) error

SaveTemplate saves a template to Redis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL