devnet

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnvilDefaultAddress = "127.0.0.1"
	AnvilDefaultPort    = 8545
)

Default port for the Ethereum node.

View Source
const ApplicationAddress = "0x75135d8ADb7180640d29d822D9AD59E83E8695b2"

Application address in devnet. nonodo

View Source
const ApplicationContractName = "Application"
View Source
const GasLimit = 30_000_000

Gas limit when sending transactions.

View Source
const InputBoxAddress = "0xB6b39Fb3dD926A9e3FBc7A129540eEbeA3016a6c"

Input box address in devnet. v2.0.0-rc.17

View Source
const LATEST_TAG = "nightly"
View Source
const STABLE_TAG = "stable"
View Source
const SenderAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"

Account that sends the transactions.

View Source
const SenderPrivateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

Private key of the sender.

View Source
const TestMnemonic = "test test test test test test test test test test test junk"

Foundry test mnemonic.

View Source
const WINDOWS = "windows"
View Source
const X86_64 = "amd64"

Variables

This section is empty.

Functions

func AddInput

func AddInput(ctx context.Context, rpcUrl string, payload []byte, applicationAddress string) error

AddInput sends an input to Ethereum using the devnet sender. This function should be used in the devnet environment.

func CheckAnvilAndInstall

func CheckAnvilAndInstall(ctx context.Context) (string, error)

For while, we dont check if anvil is already installed. We always install anvil.

func DefaultTxOpts

func DefaultTxOpts(ctx context.Context, client *ethclient.Client) (*bind.TransactOpts, 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 GetAnvilVersion

func GetAnvilVersion(anvilExec string) (string, error)

func GetInputAdded

func GetInputAdded(ctx context.Context, rpcUrl string) ([]*contracts.InputBoxInputAdded, error)

GetInputAdded gets all input added events from the input box.

func HandleReleaseExecution

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

Install release

func InstallAnvil

func InstallAnvil(ctx context.Context) (string, error)

Try to install anvil

func RunCommandOnce

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

func ShowAddresses

func ShowAddresses(writer io.WriteCloser) error

func WithFiles

func WithFiles(content string) testcontainers.CustomizeRequestOption

Types

type AnvilConfig

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

func LoadAnvilConfig

func LoadAnvilConfig(path string) (*AnvilConfig, error)

func NewAnvilConfig

func NewAnvilConfig(ra ReleaseAsset) *AnvilConfig

func (*AnvilConfig) SaveAnvilConfig

func (a *AnvilConfig) SaveAnvilConfig(path string) error

type AnvilRelease

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

Anvil implementation from HandleRelease

func (*AnvilRelease) DownloadAsset

func (a *AnvilRelease) DownloadAsset(ctx context.Context, release *ReleaseAsset) (string, error)

DownloadAsset implements HandleRelease.

func (*AnvilRelease) ExtractAsset

func (a *AnvilRelease) ExtractAsset(archive []byte, filename string, destDir string) error

func (AnvilRelease) FormatNameRelease

func (a AnvilRelease) FormatNameRelease(prefix, goos, goarch, _ string) string

FormatNameRelease implements HandleRelease.

func (*AnvilRelease) GetLatestReleaseCompatible

func (a *AnvilRelease) GetLatestReleaseCompatible(ctx context.Context) (*ReleaseAsset, error)

GetLatestReleaseCompatible implements HandleRelease.

func (AnvilRelease) GetPrefix added in v0.0.2

func (a AnvilRelease) GetPrefix() string

func (*AnvilRelease) GetVersion

func (a *AnvilRelease) GetVersion(ctx context.Context) (string, error)

GetVersion implements HandleRelease.

func (*AnvilRelease) ListRelease

func (a *AnvilRelease) ListRelease(ctx context.Context) ([]ReleaseAsset, error)

ListRelease implements HandleRelease.

func (AnvilRelease) PlatformCompatible

func (a AnvilRelease) PlatformCompatible() (string, error)

PlatformCompatible implements HandleRelease.

func (*AnvilRelease) Prerequisites

func (a *AnvilRelease) Prerequisites(ctx context.Context) error

Prerequisites implements HandleRelease.

func (AnvilRelease) SaveConfigOnDefaultLocation

func (a AnvilRelease) SaveConfigOnDefaultLocation(config *AnvilConfig) error

func (AnvilRelease) TryLoadConfig

func (a AnvilRelease) TryLoadConfig() (*AnvilConfig, error)

type AnvilWorker

type AnvilWorker struct {
	Address        string
	Port           int
	Verbose        bool
	AnvilCmd       string
	AnvilBlockTime time.Duration
}

Start the anvil process in the host machine.

func (AnvilWorker) Start

func (w AnvilWorker) Start(ctx context.Context, ready chan<- struct{}) error

func (AnvilWorker) String

func (w AnvilWorker) String() string

type ContractInfo

type ContractInfo struct {
	ContractName string `json:"contractName"`
	Address      string `json:"address"`
}

Define a struct to represent the structure of your JSON data

func GetContractInfo

func GetContractInfo() ([]ContractInfo, error)

type FoundryContainer

type FoundryContainer struct {
	testcontainers.Container
	// contains filtered or unexported fields
}

func RunFoundry

func RunFoundry(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*FoundryContainer, error)

func SetupFoundryNightly

func SetupFoundryNightly(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*FoundryContainer, error)

func SetupFoundryStable

func SetupFoundryStable(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*FoundryContainer, error)

func SetupFoundryV1

func SetupFoundryV1(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*FoundryContainer, error)

func (*FoundryContainer) URI

func (f *FoundryContainer) URI(ctx context.Context) (string, error)

type FoundryOption

type FoundryOption func(*FoundryOptions) error

func WithStateContent

func WithStateContent(content []byte) FoundryOption

func (FoundryOption) Customize

func (f FoundryOption) Customize(req *testcontainers.GenericContainerRequest) error

Customize implements testcontainers.ContainerCustomizer.

type FoundryOptions

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

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
	GetVersion(ctx context.Context) (string, error)
}

Interface for handle libraries on GitHub

func NewAnvilRelease

func NewAnvilRelease() HandleRelease

type RPCRequest

type RPCRequest struct {
	Version string   `json:"jsonrpc"`
	Method  string   `json:"method"`
	Params  []string `json:"params"`
	Id      int      `json:"id"`
}

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

Directories

Path Synopsis
This program gets the devnet state from the devnet Docker image.
This program gets the devnet state from the devnet Docker image.

Jump to

Keyboard shortcuts

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