indexer

package
v0.0.0-...-8ae4d99 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SignatureHeader is the header that contains the signature of the request
	SignatureHeader = "X-Signature"
	// AddressHeader is the header that contains the address of the sender
	AddressHeader = "X-Address"
	// AppVersionHeader is the header that contains the app version of the sender
	AppVersionHeader = "X-App-Version"
)
View Source
const ImplementationStorageSlotKey = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
View Source
const PushMessageAnonymousBody = "%s %s received"
View Source
const PushMessageAnonymousDescriptionBody = "%s"
View Source
const PushMessageAnonymousDescriptionTitle = "%s %s (%s) received"

success

View Source
const PushMessageAnonymousTitle = "%s"
View Source
const PushMessageBody = "%s %s received from %s"
View Source
const PushMessageSendingAnonymousBody = "Receiving %s %s..."
View Source
const PushMessageSendingAnonymousDescriptionBody = "%s"
View Source
const PushMessageSendingAnonymousDescriptionTitle = "Receiving %s %s (%s)..."

sending

View Source
const PushMessageSendingAnonymousTitle = "%s"
View Source
const PushMessageTitle = "%s - %s"

Variables

This section is empty.

Functions

func GenerateHexPrivateKey

func GenerateHexPrivateKey() (string, error)

generate a new private key

func GeneratePrivateKey

func GeneratePrivateKey() (*ecdsa.PrivateKey, error)

generate a new private key

func GetAddressFromContext

func GetAddressFromContext(ctx context.Context) (string, bool)

get address from context if exists

func RandomString

func RandomString(length int) string

func StringWithCharset

func StringWithCharset(length int, charset string) string

Types

type Community

type Community struct {
	Name         string `json:"name"`
	Description  string `json:"description"`
	URL          string `json:"url"`
	Alias        string `json:"alias"`
	Hidden       bool   `json:"hidden,omitempty"`
	CustomDomain string `json:"custom_domain,omitempty"`
	Theme        *Theme `json:"theme,omitempty"`
}

type CommunityConfig

type CommunityConfig struct {
	Community Community         `json:"community"`
	Scan      CommunityScan     `json:"scan"`
	Indexer   CommunityIndexer  `json:"indexer"`
	IPFS      CommunityIPFS     `json:"ipfs"`
	Node      CommunityNode     `json:"node"`
	ERC4337   CommunityERC4337  `json:"erc4337"`
	Token     CommunityToken    `json:"token"`
	Profile   CommunityProfile  `json:"profile"`
	Plugins   []CommunityPlugin `json:"plugins,omitempty"`
	Version   int               `json:"version"`
}

type CommunityERC4337

type CommunityERC4337 struct {
	RPCURL                string `json:"rpc_url"`
	PaymasterAddress      string `json:"paymaster_address"`
	EntrypointAddress     string `json:"entrypoint_address"`
	AccountFactoryAddress string `json:"account_factory_address"`
	PaymasterRPCURL       string `json:"paymaster_rpc_url"`
	PaymasterType         string `json:"paymaster_type"`
}

type CommunityIPFS

type CommunityIPFS struct {
	URL string `json:"url"`
}

type CommunityIndexer

type CommunityIndexer struct {
	URL     string `json:"url"`
	IPFSURL string `json:"ipfs_url"`
	Key     string `json:"key"`
}

type CommunityNode

type CommunityNode struct {
	ChainID int    `json:"chain_id"`
	URL     string `json:"url"`
	WSURL   string `json:"ws_url"`
}

type CommunityPlugin

type CommunityPlugin struct {
	Name string `json:"name"`
	Icon string `json:"icon"`
	URL  string `json:"url"`
}

type CommunityProfile

type CommunityProfile struct {
	Address string `json:"address"`
}

type CommunityScan

type CommunityScan struct {
	URL  string `json:"url"`
	Name string `json:"name"`
}

type CommunityToken

type CommunityToken struct {
	Standard string `json:"standard"`
	Address  string `json:"address"`
	Name     string `json:"name"`
	Symbol   string `json:"symbol"`
	Decimals int    `json:"decimals"`
}

type ContextKey

type ContextKey string
const (
	ContextKeyAddress   ContextKey = AddressHeader
	ContextKeySignature ContextKey = SignatureHeader
)

type EVMRequester

type EVMRequester interface {
	Context() context.Context
	Backend() bind.ContractBackend

	CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
	NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
	BaseFee() (*big.Int, error)
	EstimateGasPrice() (*big.Int, error)
	EstimateGasLimit(msg ethereum.CallMsg) (uint64, error)
	NewTx(nonce uint64, from, to common.Address, data []byte, extraGas bool) (*types.Transaction, error)
	SendTransaction(tx *types.Transaction) error
	StorageAt(addr common.Address, slot common.Hash) ([]byte, error)

	ChainID() (*big.Int, error)
	LatestBlock() (*big.Int, error)
	FilterLogs(q ethereum.FilterQuery) ([]types.Log, error)
	BlockTime(number *big.Int) (uint64, error)
	ListenForLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) error

	WaitForTx(tx *types.Transaction, timeout int) error

	Close()
}

type EVMType

type EVMType string
const (
	EVMTypeEthereum EVMType = "ethereum"
	EVMTypeOptimism EVMType = "optimism"
	EVMTypeCelo     EVMType = "celo"
)

type Event

type Event struct {
	Contract   string     `json:"contract"`
	State      EventState `json:"state"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	StartBlock int64      `json:"start_block"`
	LastBlock  int64      `json:"last_block"`
	Standard   Standard   `json:"standard"`
	Name       string     `json:"name"`
	Symbol     string     `json:"symbol"`
	Decimals   int64      `json:"decimals"`
}

type EventState

type EventState string
const (
	EventStateQueued   EventState = "queued"
	EventStateIndexing EventState = "indexing"
	EventStateIndexed  EventState = "indexed"
)

type JSONRPCError

type JSONRPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data"`
}

type JsonRPCRequest

type JsonRPCRequest struct {
	Version string          `json:"jsonrpc"`
	ID      int             `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"`
}

type JsonRPCResponse

type JsonRPCResponse struct {
	Version string        `json:"jsonrpc"`
	ID      int           `json:"id"`
	Result  any           `json:"result"`
	Error   *JSONRPCError `json:"error,omitempty"`
}

type Message

type Message struct {
	ID         string
	CreatedAt  time.Time
	RetryCount int
	Message    any
}

func NewTxMessage

func NewTxMessage(pm, entrypoint common.Address, chainId *big.Int, userop UserOp, txdata *TransferData) *Message

type Profile

type Profile struct {
	Account     string `json:"account"`
	Username    string `json:"username"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Image       string `json:"image"`
	ImageMedium string `json:"image_medium"`
	ImageSmall  string `json:"image_small"`
}

type PushMessage

type PushMessage struct {
	Tokens []*PushToken
	Title  string
	Body   string
	Data   []byte
	Silent bool
}

func NewAnonymousPushMessage

func NewAnonymousPushMessage(token []*PushToken, community, amount, symbol string, tx *Transfer) *PushMessage

func NewPushMessage

func NewPushMessage(token []*PushToken, community, name, amount, symbol, username string) *PushMessage

func NewSilentPushMessage

func NewSilentPushMessage(token []*PushToken, tx *Transfer) *PushMessage

type PushToken

type PushToken struct {
	Token   string
	Account string
}

type RPCHandlerFunc

type RPCHandlerFunc func(r *http.Request) (any, int)
type Sponsor struct {
	Contract   string `json:"contract"`
	PrivateKey string `json:"private_key"`
	CreatedAt  string `json:"created_at"`
	UpdatedAt  string `json:"updated_at"`
}

type Standard

type Standard string
const (
	ERC20   Standard = "ERC20"
	ERC721  Standard = "ERC721"
	ERC1155 Standard = "ERC1155"
)

type Theme

type Theme struct {
	PrimaryColor string `json:"primaryColor"`
}

type Transfer

type Transfer struct {
	Hash      string         `json:"hash"`
	TxHash    string         `json:"tx_hash"`
	TokenID   int64          `json:"token_id"`
	CreatedAt time.Time      `json:"created_at"`
	FromTo    string         `json:"-"`
	From      string         `json:"from"`
	To        string         `json:"to"`
	Nonce     int64          `json:"nonce"`
	Value     *big.Int       `json:"value"`
	Data      *TransferData  `json:"data"`
	Status    TransferStatus `json:"status"`
}

func (*Transfer) CombineFromTo

func (t *Transfer) CombineFromTo() string

func (*Transfer) GenerateUniqueHash

func (t *Transfer) GenerateUniqueHash() string

generate hash for transfer using a provided index, from, to and the tx hash

func (*Transfer) ToRounded

func (t *Transfer) ToRounded(decimals int64) float64

func (*Transfer) Update

func (t *Transfer) Update(tx *Transfer)

Update updates the transfer using the given transfer

type TransferData

type TransferData struct {
	Description string `json:"description"`
}

func (*TransferData) Scan

func (td *TransferData) Scan(value interface{}) error

TransferData implements the sql.Scanner interface

func (TransferData) Value

func (td TransferData) Value() (driver.Value, error)

TransferData implements the driver.Valuer interface

type TransferStatus

type TransferStatus string
const (
	TransferStatusUnknown TransferStatus = ""
	TransferStatusSending TransferStatus = "sending"
	TransferStatusPending TransferStatus = "pending"
	TransferStatusSuccess TransferStatus = "success"
	TransferStatusFail    TransferStatus = "fail"

	TEMP_HASH_PREFIX = "TEMP_HASH"
)

func TransferStatusFromString

func TransferStatusFromString(s string) (TransferStatus, error)

type UserOp

type UserOp struct {
	Sender               common.Address `json:"sender"               mapstructure:"sender"               validate:"required"`
	Nonce                *big.Int       `json:"nonce"                mapstructure:"nonce"                validate:"required"`
	InitCode             []byte         `json:"initCode"             mapstructure:"initCode"             validate:"required"`
	CallData             []byte         `json:"callData"             mapstructure:"callData"             validate:"required"`
	CallGasLimit         *big.Int       `json:"callGasLimit"         mapstructure:"callGasLimit"         validate:"required"`
	VerificationGasLimit *big.Int       `json:"verificationGasLimit" mapstructure:"verificationGasLimit" validate:"required"`
	PreVerificationGas   *big.Int       `json:"preVerificationGas"   mapstructure:"preVerificationGas"   validate:"required"`
	MaxFeePerGas         *big.Int       `json:"maxFeePerGas"         mapstructure:"maxFeePerGas"         validate:"required"`
	MaxPriorityFeePerGas *big.Int       `json:"maxPriorityFeePerGas" mapstructure:"maxPriorityFeePerGas" validate:"required"`
	PaymasterAndData     []byte         `json:"paymasterAndData"     mapstructure:"paymasterAndData"     validate:"required"`
	Signature            []byte         `json:"signature"            mapstructure:"signature"            validate:"required"`
}

func (*UserOp) Copy

func (u *UserOp) Copy() UserOp

func (*UserOp) MarshalJSON

func (op *UserOp) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON encoding of the UserOperation.

func (*UserOp) UnmarshalJSON

func (op *UserOp) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a JSON encoding of the UserOperation.

type UserOpMessage

type UserOpMessage struct {
	Paymaster  common.Address
	EntryPoint common.Address
	ChainId    *big.Int
	UserOp     UserOp
	ExtraData  any
}

type WebhookMessager

type WebhookMessager interface {
	Notify(ctx context.Context, message string) error
	NotifyWarning(ctx context.Context, errorMessage error) error
	NotifyError(ctx context.Context, errorMessage error) error
}

Jump to

Keyboard shortcuts

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