Documentation ¶
Overview ¶
Package deployer contains utilities for deploying test contracts
Index ¶
- type BaseDeployer
- func (n BaseDeployer) Backend() backends.SimulatedTestBackend
- func (n BaseDeployer) ContractType() contracts.ContractType
- func (n BaseDeployer) Dependencies() []contracts.ContractType
- func (n BaseDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
- func (n BaseDeployer) DeploySimpleContract(ctx context.Context, deployFunction DeployFunc, handleFunction HandleFunc) (contracts.DeployedContract, error)
- func (n BaseDeployer) RecursiveDependencies(dependencies []contracts.ContractType) (res []contracts.ContractType)
- func (n BaseDeployer) Registry() GetOnlyContractRegistry
- type ContractDeployer
- type ContractRegistry
- type DeployFunc
- type DeployedContract
- func (d DeployedContract) Address() common.Address
- func (d DeployedContract) ChainID() *big.Int
- func (d DeployedContract) ContractHandle() interface{}
- func (d DeployedContract) DeployTx() *types.Transaction
- func (d DeployedContract) Owner() common.Address
- func (d DeployedContract) OwnerPtr() *common.Address
- func (d DeployedContract) String() string
- type DeployerFunc
- type FunctionalDeployFunc
- type FunctionalDeployerdeprecated
- type GetOnlyContractRegistry
- type HandleFunc
- type IFunctionalDeployer
- type WrapFunc
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 ¶
func (n BaseDeployer) Backend() backends.SimulatedTestBackend
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 ¶
func (n BaseDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
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 ¶
func (n BaseDeployer) Registry() GetOnlyContractRegistry
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(handle vm.ContractRef, deployTx *types.Transaction) (DeployedContract, error)
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).
func (DeployedContract) String ¶ added in v0.0.131
func (d DeployedContract) String() string
String returns a string representation of the contract metadata.
type DeployerFunc ¶ added in v0.2.0
type DeployerFunc func(registry GetOnlyContractRegistry, backend backends.SimulatedTestBackend) ContractDeployer
DeployerFunc defines a deployer we can use. nolint: golint, revive
func NewFunctionalDeployer ¶ added in v0.2.0
func NewFunctionalDeployer(contractType contracts.ContractType, deployFunc FunctionalDeployFunc, wrapFunc WrapFunc, autoRecursedDeps []contracts.ContractType) DeployerFunc
NewFunctionalDeployer creates a new functional deployer. Experimental.
type FunctionalDeployFunc ¶ added in v0.2.0
type FunctionalDeployFunc func(ctx context.Context, helpers IFunctionalDeployer, transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error)
FunctionalDeployFunc is a function that deploys a contract.
type FunctionalDeployer
deprecated
added in
v0.2.0
type FunctionalDeployer struct { *BaseDeployer // contains filtered or unexported fields }
FunctionalDeployer is a new functional deployer.
It is currently experimental and seeks to succeed SimpleDeployer. It has the advantage of being pureley functional and not requiring the user to create a struct. It currently extends BaseDeployer.
Deprecated: TODO remove this, it looks terrible.
func (*FunctionalDeployer) Dependencies ¶ added in v0.2.0
func (f *FunctionalDeployer) Dependencies() []contracts.ContractType
Dependencies returns the dependencies of the functional deployer.
func (*FunctionalDeployer) Deploy ¶ added in v0.2.0
func (f *FunctionalDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
Deploy deploys the contract.
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 // GetDeployedContracts gets all deployed contracts in the registry. GetDeployedContracts() (res map[int]contracts.DeployedContract) }
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.
type IFunctionalDeployer ¶ added in v0.2.0
type IFunctionalDeployer interface { Registry() GetOnlyContractRegistry Backend() backends.SimulatedTestBackend ContractType() contracts.ContractType }
IFunctionalDeployer is an interface for a functional deployer.