burrow: github.com/hyperledger/burrow/deploy/compile Index | Files

package compile

import "github.com/hyperledger/burrow/deploy/compile"


Package Files


func GetDeployCodeHash Uses

func GetDeployCodeHash(code []byte, address crypto.Address) []byte

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.

func PrintResponse Uses

func PrintResponse(resp Response, cli bool, logger *logging.Logger)

type ContractCode Uses

type ContractCode struct {
    Object         string
    LinkReferences json.RawMessage

type Metadata Uses

type Metadata struct {
    ContractName    string
    SourceFile      string
    CompilerVersion string
    Abi             json.RawMessage

type MetadataMap Uses

type MetadataMap struct {
    DeployedBytecode ContractCode
    Metadata         Metadata

type Response Uses

type Response struct {
    Objects []ResponseItem `json:"objects"`
    Warning string         `json:"warning"`
    Version string         `json:"version"`
    Error   string         `json:"error"`

func EVM Uses

func EVM(file string, optimize bool, workDir string, libraries map[string]string, logger *logging.Logger) (*Response, error)

func WASM Uses

func WASM(file string, workDir string, logger *logging.Logger) (*Response, error)

type ResponseItem Uses

type ResponseItem struct {
    Filename   string           `json:"filename"`
    Objectname string           `json:"objectname"`
    Contract   SolidityContract `json:"binary"`

Compile response object

type SolidityContract Uses

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 Uses

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 Uses

func (contract *SolidityContract) Code() (code string)

func (*SolidityContract) GetMetadata Uses

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 (contract *SolidityContract) Link(libraries map[string]string) error

Link will replace the unresolved references with the libraries provided

func (*SolidityContract) Save Uses

func (contract *SolidityContract) Save(dir, file string) error

Save persists the contract in its json form to disk

type SolidityInput Uses

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 Uses

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 Uses

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 Uses

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

Package compile imports 14 packages (graph) and is imported by 20 packages. Updated 2020-05-03. Refresh now. Tools for package owners.