Documentation ¶
Overview ¶
The code generator for the plugin for the Google protocol buffer compiler. It generates Solidity code from the protocol buffer description files read by the main routine.
Index ¶
Constants ¶
const ExtName = "soltype"
ExtName is the extension name to google.protobuf.FieldOptions its type must be string. Valid string values are keys in SolTypeMap (we don't use enum to avoid having solidity knowledge in chain.proto)
const ProtoSol = `` /* 6117-byte string literal not displayed */
ProtoSol is the full proto library, appended in the end of generated .sol file
const SolVer = "^0.5.0;"
SolVer is the compatible solidity/solc version in pragma solidity
const WireLendel = "Bytes"
const WireVarint = "Varint"
string const for proto wire types
Variables ¶
var PassTypeMap = map[string]string{ "uint32": WireVarint, "uint64": WireVarint, "bool": WireVarint, "bytes": WireLendel, "string": WireLendel, }
PassTypeMap is a map of proto types with native solidity support (aka. same type keyword in proto and solidity) to its wire type. keys are values from pbType2Str map below. currently we only support 2 wire types: varint and length-delimited.
var SolTypeMap = map[string]string{
"uint8": "uint32",
"address": "bytes",
"address payable": "bytes",
"bytes32": "bytes",
"uint256": "bytes",
"uint": "uint64",
}
SolTypeMap is a map of solidity types as valid soltype option value to required proto primitive type. eg. a field can have (soltype) = "address payable", it must be defined as proto bytes
Functions ¶
Types ¶
type Generator ¶
type Generator struct { *bytes.Buffer // cache .P() output Request *plugin.CodeGeneratorRequest // The input. Response *plugin.CodeGeneratorResponse // The output. // contains filtered or unexported fields }
Generator is the type whose methods generate the output, stored in the associated response structure.
func New ¶
func New() *Generator
New creates a new generator and allocates the request and response protobufs.
func (*Generator) GenerateAllFiles ¶
func (g *Generator) GenerateAllFiles()
GenerateAllFiles generates the output for all the files we're outputting.
func (*Generator) In ¶
func (g *Generator) In()
In indents the output 4 spaces stop. per solidity style guide
func (*Generator) ParseParams ¶
func (g *Generator) ParseParams()
func (*Generator) Preprocess ¶
func (g *Generator) Preprocess()
When we want to support multiple .proto and imports, need preprocess to get all definition relationships