Documentation
      ¶
    
    
  
    
  
    Index ¶
- func GetDeployCodeHash(code []byte, address crypto.Address) []byte
 - func PrintResponse(resp Response, cli bool, logger *logging.Logger)
 - type ContractCode
 - type Metadata
 - type MetadataMap
 - type Response
 - type ResponseItem
 - type SolidityContract
 - type SolidityInput
 - type SolidityInputSource
 - type SolidityMetadata
 - type SolidityOutput
 
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDeployCodeHash ¶ added in v0.28.0
GetDeployCodeHash deals with the issue described in https://github.com/ethereum/solidity/issues/7101 When a library contract (one declared with "libary { }" rather than "contract { }"), the deployed code will not match what the solidity compiler said it would be. This is done to implement "call protection"; library contracts are only supposed to be called from our solidity contracts, not directly. To prevent this, the library deployed code compares the callee address with the contract address itself. If it equal, it calls revert. The library contract address is only known post-deploy so this issue can only be handled post-deploy. This is why this is not dealt with during deploy time.
Types ¶
type ContractCode ¶ added in v0.28.0
type ContractCode struct {
	Object         string
	LinkReferences json.RawMessage
}
    type Metadata ¶ added in v0.28.0
type Metadata struct {
	ContractName    string
	SourceFile      string
	CompilerVersion string
	Abi             json.RawMessage
}
    type MetadataMap ¶ added in v0.28.0
type MetadataMap struct {
	DeployedBytecode ContractCode
	Metadata         Metadata
}
    type Response ¶
type Response struct {
	Objects []ResponseItem `json:"objects"`
	Warning string         `json:"warning"`
	Version string         `json:"version"`
	Error   string         `json:"error"`
}
    type ResponseItem ¶
type ResponseItem struct {
	Filename   string           `json:"filename"`
	Objectname string           `json:"objectname"`
	Contract   SolidityContract `json:"binary"`
}
    Compile response object
type SolidityContract ¶ added in v0.23.0
type SolidityContract struct {
	Abi json.RawMessage
	Evm struct {
		Bytecode         ContractCode
		DeployedBytecode ContractCode
	}
	EWasm struct {
		Wasm string
	}
	Devdoc   json.RawMessage
	Userdoc  json.RawMessage
	Metadata string
	// This is not present in the solidity output, but we add it ourselves
	// This is map from DeployedBytecode to Metadata. A Solidity contract can create any number
	// of contracts, which have distinct metadata. This is a map for the deployed code to metdata,
	// including the first contract itself.
	MetadataMap []MetadataMap `json:",omitempty"`
}
    SolidityContract is defined for each contract defined in the solidity source code
func LoadSolidityContract ¶ added in v0.23.0
func LoadSolidityContract(file string) (*SolidityContract, error)
LoadSolidityContract is the opposite of the .Save() method. This expects the input file to be in the Solidity json output format
func (*SolidityContract) Code ¶ added in v0.27.0
func (contract *SolidityContract) Code() (code string)
func (*SolidityContract) GetMetadata ¶ added in v0.28.0
func (contract *SolidityContract) GetMetadata(logger *logging.Logger) (map[acmstate.CodeHash]string, error)
GetMetadata get the CodeHashes + Abis for the generated Code. So, we have a map for all the possible contracts codes hashes to abis
func (*SolidityContract) Link ¶ added in v0.23.0
func (contract *SolidityContract) Link(libraries map[string]string) error
Link will replace the unresolved references with the libraries provided
func (*SolidityContract) Save ¶ added in v0.23.0
func (contract *SolidityContract) Save(dir, file string) error
Save persists the contract in its json form to disk
type SolidityInput ¶
type SolidityInput struct {
	Language string                         `json:"language"`
	Sources  map[string]SolidityInputSource `json:"sources"`
	Settings struct {
		Libraries map[string]map[string]string `json:"libraries"`
		Optimizer struct {
			Enabled bool `json:"enabled"`
		} `json:"optimizer"`
		OutputSelection struct {
			File struct {
				OutputType []string `json:"*"`
			} `json:"*"`
		} `json:"outputSelection"`
	} `json:"settings"`
}
    SolidityInput is a structure for the solidity compiler input json form, see: https://solidity.readthedocs.io/en/v0.5.9/using-the-compiler.html#compiler-input-and-output-json-description
type SolidityInputSource ¶
type SolidityInputSource struct {
	Content string   `json:"content,omitempty"`
	Urls    []string `json:"urls,omitempty"`
}
    SolidityInputSource should be set for each solidity input source file in SolidityInput
type SolidityMetadata ¶ added in v0.28.0
type SolidityMetadata struct {
	Version string
	// The solidity compiler needs to tell us it compiles solidity
	Language string
	Compiler struct {
		Version   string
		Keccak256 string
	}
	Sources map[string]struct {
		Keccak256 string
		Content   string
		Urls      []string
	}
}
    SolidityMetadata is the json field metadata
type SolidityOutput ¶
type SolidityOutput struct {
	Contracts map[string]map[string]SolidityContract
	Errors    []struct {
		Component        string
		FormattedMessage string
		Message          string
		Severity         string
		Type             string
	}
}
    SolidityOutput is a structure for the output of the solidity json output form