common

package
v0.0.0-...-7a1e3be Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const CardManagerABI = `` /* 2731-byte string literal not displayed */

Variables

View Source
var (
	ErrInvalidCalldata = errors.New("invalid calldata")
	ErrNotTransfer     = errors.New("not a transfer")
)

Functions

func Body

func Body(w http.ResponseWriter, body any, meta any) error

func BodyMultiple

func BodyMultiple(w http.ResponseWriter, body any, meta any) error

func ChecksumAddress

func ChecksumAddress(addr string) string

func Decrypt

func Decrypt(encryptedValue string, key string) (string, error)

Decrypt takes an encrypted value and a key, decrypts the value using AES-CFB, and returns the decrypted value as a string.

Parameters:

  • encryptedValue: The hex-encoded string of the encrypted value
  • key: The decryption key as a hex-encoded string

Returns:

  • The decrypted string
  • An error if decryption fails

func Encrypt

func Encrypt(secretValue string, key string) (string, error)

Encrypt takes a secret value and a key, encrypts the value using AES-CFB, and returns the encrypted value as a hex-encoded string.

Parameters:

  • secretValue: The string to be encrypted
  • key: The encryption key as a hex-encoded string

Returns:

  • A hex-encoded string of the encrypted value
  • An error if encryption fails

func Filter

func Filter[T any](slice []T, f func(T) bool) []T

func GenerateKey

func GenerateKey() ([]byte, error)

func GetContextAddress

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

GetContextAddress returns the indexer.ContextKeyAddress from the context

func HexToBigInt

func HexToBigInt(hex string) *big.Int

func HexToPrivateKey

func HexToPrivateKey(privateKeyHex string) (*ecdsa.PrivateKey, error)

func IsSameHexAddress

func IsSameHexAddress(a, b string) bool

func JSONRPCBody

func JSONRPCBody(w http.ResponseWriter, id any, body any, meta any, err error) error

func JSONRPCMultiBody

func JSONRPCMultiBody(w http.ResponseWriter, ids []any, bodies []any, meta any, errs []error) error

func ParseDestinationFromCallData

func ParseDestinationFromCallData(calldata []byte) (common.Address, error)

func ParseERC20Transfer

func ParseERC20Transfer(calldata []byte, evm engine.EVMRequester) (common.Address, common.Address, common.Address, *big.Int, error)

ParseERC20Transfer parses the calldata of an ERC20 transfer from a smart contract Execute function

func Remove

func Remove[T any](slice []T, index int) []T

func ShortenName

func ShortenName(s string, length int) string

func StreamedBody

func StreamedBody(w http.ResponseWriter, body string) error

Types

type AddressResponse

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

type ImageFormat

type ImageFormat string
const (
	JPG  ImageFormat = "jpg"
	JPEG ImageFormat = "jpeg"
	PNG  ImageFormat = "png"
	GIF  ImageFormat = "gif"
	WEBP ImageFormat = "webp"
)

type Nonce

type Nonce struct {
	Seq uint64
	Key *big.Int
}

func NewNonce

func NewNonce() (*Nonce, error)

GenerateNonce generates a nonce which is a unique number that can only be used once. This nonce is a uint256 composed of a uint64 and a uint192. The uin192 contains an epoch timestamp in the last 10 digits

func ParseNonce

func ParseNonce(nonce *big.Int) *Nonce

ParseNonce parses a nonce from a big.Int containing a uint256 with the first 64 bits being the key and the last 192 bits being the seq.

func (*Nonce) BigInt

func (n *Nonce) BigInt() *big.Int

func (*Nonce) String

func (n *Nonce) String() string

type Pagination

type Pagination struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
	Total  int `json:"total"`
}

type Response

type Response struct {
	// The response type
	// in: body
	ResponseType ResponseType `json:"response_type"`
	Object       any          `json:"object,omitempty"`
	Array        any          `json:"array,omitempty"`
	Meta         any          `json:"meta,omitempty"`
}

Response is the default response object swagger:response defaultResponse

type ResponseType

type ResponseType string
const (
	ResponseTypeObject ResponseType = "object"
	ResponseTypeArray  ResponseType = "array"
	ResponseTypeSecure ResponseType = "secure"
)

type SizedImages

type SizedImages struct {
	Big    []byte
	Medium []byte
	Small  []byte
}

func ParseImage

func ParseImage(file multipart.File) (*SizedImages, error)

Jump to

Keyboard shortcuts

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