deployer

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 15 Imported by: 8

Documentation

Overview

Package deployer contains utilities for deploying test contracts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDeployer

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

BaseDeployer is a basic deployment contract. It contains several utility functions including: - RecursiveDependencies: can be used to return dependents of dependents (since Dependencies should return all dependents: direct and indirect) - DeploySimpleContract: can be used to deploy contracts that don't have to be initialized.

func NewSimpleDeployer

func NewSimpleDeployer(registry GetOnlyContractRegistry, backend backends.SimulatedTestBackend, contractType contracts.ContractType) *BaseDeployer

NewSimpleDeployer creates a new base deployer.

func (BaseDeployer) Backend

Backend gets the backend of the current deployer instance.

func (BaseDeployer) ContractType

func (n BaseDeployer) ContractType() contracts.ContractType

ContractType returns the contract type.

func (BaseDeployer) Dependencies

func (n BaseDeployer) Dependencies() []contracts.ContractType

Dependencies returns dependencies for the contract - this should be overridden by base classes if there are dependencies.

func (BaseDeployer) Deploy

Deploy is a placeholder to ensure function inheritance. Calling this directly will panic.

func (BaseDeployer) DeploySimpleContract

func (n BaseDeployer) DeploySimpleContract(ctx context.Context, deployFunction DeployFunc, handleFunction HandleFunc) (contracts.DeployedContract, error)

DeploySimpleContract handles no dependency contract deployments. All others must be handled in inheriting structs.

func (BaseDeployer) RecursiveDependencies

func (n BaseDeployer) RecursiveDependencies(dependencies []contracts.ContractType) (res []contracts.ContractType)

RecursiveDependencies recursively get dependencies.

func (BaseDeployer) Registry

Registry gets the registry.

type ContractDeployer

type ContractDeployer interface {
	// Deploy deploys the contract and returns an error if it cannot be deployed
	Deploy(ctx context.Context) (contracts.DeployedContract, error)
	// ContractType gets the type of the deployed contract
	ContractType() contracts.ContractType
	// Dependencies gets the dependencies of this contract
	Dependencies() []contracts.ContractType
}

ContractDeployer is a contract deployer for a single contract type.

type ContractRegistry

type ContractRegistry interface {
	GetOnlyContractRegistry
	// Deploy deploys the contract type, but does not register it
	Deploy(ctx context.Context, contractType contracts.ContractType) contracts.DeployedContract
	// Register registers the contract with the contract registry. If you use Get() this isn't
	// required. This method is idempotent and will overwrite any contracts deployed
	Register(contractType contracts.ContractType, contract contracts.DeployedContract)
	// RegisterContractDeployer registers contract types that can be used for deployment. This allows extensibility by
	// non-synapse libraries. This will overwrite previous contract deployers with the same type
	RegisterContractDeployer(deployers ...ContractDeployer)
	// IsContractDeployed checks if a contract is deplyoed yet
	IsContractDeployed(contractType contracts.ContractType) bool
	// RegisteredDeployers gets all deployers registered
	RegisteredDeployers() []ContractDeployer
}

ContractRegistry handles contract deployment/storage for a specific chain.

func NewContractRegistry

func NewContractRegistry(tb testing.TB, backend backends.SimulatedTestBackend) ContractRegistry

NewContractRegistry creates a new contract registry.

type DeployFunc

type DeployFunc func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error)

DeployFunc is the deploy function.

type DeployedContract

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

DeployedContract represents a deployed contract. It is returned by a deployer after a successful deployment.

func NewDeployedContract

func NewDeployedContract(tb testing.TB, handle vm.ContractRef, deployTx *types.Transaction) DeployedContract

NewDeployedContract creates a new deployed contract. We take some shortcuts by making some assumptions: namely, that tx sender is owner.

func (DeployedContract) Address

func (d DeployedContract) Address() common.Address

Address gets the address of the deployed contract.

func (DeployedContract) ChainID

func (d DeployedContract) ChainID() *big.Int

ChainID is the chain id of the deployed contract.

func (DeployedContract) ContractHandle

func (d DeployedContract) ContractHandle() interface{}

ContractHandle is the contract handle of the deployed ocontract.

func (DeployedContract) DeployTx

func (d DeployedContract) DeployTx() *types.Transaction

DeployTx gets the deploy transaction.

func (DeployedContract) Owner

func (d DeployedContract) Owner() common.Address

Owner gets the contract owner.

func (DeployedContract) OwnerPtr

func (d DeployedContract) OwnerPtr() *common.Address

OwnerPtr returns a pointer to the owner (useful for GetTxContext() operations).

type GetOnlyContractRegistry

type GetOnlyContractRegistry interface {
	// Get gets a contract by type. If the contract is not deployed, a new contract of type is deployed.
	// In cases where an error is present, this error is triggered via the test object in the constructor
	Get(ctx context.Context, contractType contracts.ContractType) contracts.DeployedContract
	// GetRegisteredDeployer gets the deployer for a given contract, returs nil if it doesn't exist
	GetRegisteredDeployer(contractType contracts.ContractType) ContractDeployer
}

GetOnlyContractRegistry is a contract registry that only allows gets.

type HandleFunc

type HandleFunc func(address common.Address, backend bind.ContractBackend) (interface{}, error)

HandleFunc gets the ref function.

Jump to

Keyboard shortcuts

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