commons

package
v0.0.0-...-6bb07a5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HARDHAT         = 31337
	PURPOSE_INDEX   = 44
	COIN_TYPE_INDEX = 60
)
View Source
const DefaultPaginationLimit = 1000
View Source
const LATEST_TAG = "nightly"
View Source
const TimeoutInSeconds = 10
View Source
const WINDOWS = "windows"
View Source
const X86_64 = "amd64"

Variables

View Source
var ErrInvalidCursor = errors.New("invalid pagination cursor")
View Source
var ErrInvalidLimit = errors.New("limit cannot be negative")
View Source
var ErrMixedPagination = errors.New(
	"cannot mix forward pagination (first, after) with backward pagination (last, before)")

Functions

func ComputePage

func ComputePage(
	first *int, last *int, after *string, before *string, total int,
) (offset int, limit int, err error)

Compute the pagination parameters given the GraphQL connection parameters.

func ConfigureLog

func ConfigureLog(level slog.Leveler)

func ConvertStatusStringToCompletionStatus

func ConvertStatusStringToCompletionStatus(status string) model.CompletionStatus

Status on schema could be: 'NONE', 'ACCEPTED', 'REJECTED', 'EXCEPTION', 'MACHINE_HALTED', 'CYCLE_LIMIT_EXCEEDED', 'TIME_LIMIT_EXCEEDED', 'PAYLOAD_LENGTH_LIMIT_EXCEEDED'

func DecodeCursor

func DecodeCursor(base64Cursor string, total int) (int, error)

Decode the integer offset from a base64 string.

func EncodeCursor

func EncodeCursor(offset int) string

Encode the integer offset into a base64 string.

func ExtractSigAndData

func ExtractSigAndData(raw string) (common.Address, apitypes.TypedData, []byte, error)

func ExtractTarGz

func ExtractTarGz(archive []byte, destDir string) error

Extract a tar.gz archive to a destination directory

func ExtractZip

func ExtractZip(archive []byte, destDir string) error

Extract a zip archive to a destination directory

func HandleReleaseExecution

func HandleReleaseExecution(stdCtx context.Context, release HandleRelease) (string, error)

Install release

func HashEIP712Message

func HashEIP712Message(data apitypes.TypedData) ([]byte, error)

Implement the hashing function based on EIP-712 requirements

func IsPortInUse

func IsPortInUse(port int) bool

func NewCartesiDomain

func NewCartesiDomain(chainId *math.HexOrDecimal256) apitypes.TypedDataDomain

func RunCommandOnce

func RunCommandOnce(stdCtx context.Context, cmd *exec.Cmd) ([]byte, error)

func SignMessage

func SignMessage(hash []byte, privateKey *ecdsa.PrivateKey) ([]byte, error)

Sign the hash with the private key

Types

type AnvilConfig

type AnvilConfig struct {
	AssetAnvil  ReleaseAsset `json:"asset_anvil"`
	LatestCheck string       `json:"latest_check"`
}

type AnvilRelease

type AnvilRelease struct {
	Namespace      string
	Repository     string
	ConfigFilename string
	Client         *github.Client
}

Anvil implementation from HandleRelease

type DbFactory

type DbFactory struct {
	TempDir string
	Timeout time.Duration
}

func NewDbFactory

func NewDbFactory() *DbFactory

func (*DbFactory) Cleanup

func (d *DbFactory) Cleanup()

func (*DbFactory) CreateDb

func (d *DbFactory) CreateDb(sqliteFileName string) *sqlx.DB

func (*DbFactory) CreateDbCtx

func (d *DbFactory) CreateDbCtx(ctx context.Context, sqliteFileName string) (*sqlx.DB, error)

type HandleRelease

type HandleRelease interface {
	// Name basead on version, arch, os with prefix
	FormatNameRelease(prefix, goos, goarch, version string) string
	// Check if the platform is compatible with the library and return the name of the release
	PlatformCompatible() (string, error)
	// List all releases from the repository
	ListRelease(ctx context.Context) ([]ReleaseAsset, error)
	// Get the latest release compatible with the platform
	GetLatestReleaseCompatible(ctx context.Context) (*ReleaseAsset, error)
	// Check prerequisites for the library
	Prerequisites(ctx context.Context) error
	// Download the asset from the release
	DownloadAsset(ctx context.Context, release *ReleaseAsset) (string, error)
	// Extract the asset from the archive
	ExtractAsset(archive []byte, filename string, destDir string) error
}

Interface for handle libraries on GitHub

type PageResult

type PageResult[T any] struct {
	Total  uint64
	Offset uint64
	Rows   []T
}

type ReleaseAsset

type ReleaseAsset struct {
	Tag      string `json:"tag"`
	AssetId  int64  `json:"asset_id"`
	Filename string `json:"filename"`
	Url      string `json:"url"`
	Path     string `json:"path"`
}

ReleaseAsset represents a release asset from GitHub

func GetAssetsFromLastReleaseGitHub

func GetAssetsFromLastReleaseGitHub(ctx context.Context, client *github.Client, namespace, repository string, tag string) ([]ReleaseAsset, error)

Get assets of latest release or prerelease from GitHub

type SigAndData

type SigAndData struct {
	Signature string `json:"signature"`
	TypedData string `json:"typedData"`
}

Jump to

Keyboard shortcuts

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