Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyTemplate(t *template.Template, c *Context, output string) error
- func GetTxNames(n ast.Node) ([]string, error)
- func ParseTemplate(path string) (*template.Template, error)
- func ParseTransactions() (*ast.File, error)
- type Context
- type DefinitionFinder
- type Field
- type Transaction
Constants ¶
const TxIDs = "TxIDs"
TxIDs is the name of the transaction IDs map
Variables ¶
var ( // ExamplesPath is the path to the generated examples ExamplesPath string // TransactionPath is the path to the transaction definition file TransactionPath string // ConstructorsTemplatePath is the path to the Constructors template ConstructorsTemplatePath string // ConstructorsOutputPath is the path to the Constructors output file ConstructorsOutputPath string // JSONLiteralsTemplatePath is the path to the JSON literals template JSONLiteralsTemplatePath string // JSONLiteralsOutputPath is the path to the JSON literals output file JSONLiteralsOutputPath string // JSTestTemplatePath is the path to the JS test template JSTestTemplatePath string // JSTestOutputPath is the path to the JS test output file JSTestOutputPath string // MaketestsTemplatePath is the path to the template which makes the binary which makes the tests MaketestsTemplatePath string // MaketestsOutputPath is the path to the Maketests output file MaketestsOutputPath string // SignableBytesTemplatePath is the path to the SignableBytes template SignableBytesTemplatePath string // SignableBytesOutputPath is the path to the SignableBytes output file SignableBytesOutputPath string // SignableBytesTestTemplatePath is the path to the SignableBytes tests template SignableBytesTestTemplatePath string // SignableBytesTestOutputPath is the path to the SignableBytes tests output file SignableBytesTestOutputPath string )
Functions ¶
func ApplyTemplate ¶
ApplyTemplate applies the template to the transaction
func GetTxNames ¶
GetTxNames gets the names of the transactions from the TxIDs map
func ParseTemplate ¶
ParseTemplate parses the template definition
func ParseTransactions ¶
ParseTransactions parses the transaction definition file
Types ¶
type Context ¶
type Context struct {
Transactions []Transaction
}
Context defines all the info the template needs
func MakeContext ¶
MakeContext makes a context object from ndau transactions
func MakeContextWithExamples ¶
MakeContextWithExamples makes a context object from ndau transactions
In addition to constructing the AST-based context, when provided with a list of instantiated transactions, it will match them and inject them appropriately into the context. This allows, for example, writing tests which include auto- generated SignableBytes calls
type DefinitionFinder ¶
type DefinitionFinder struct { Name string Root ast.Node DefinitionType string Definition ast.Expr }
DefinitionFinder finds definitions of variables by name within a node
func FindDefinition ¶
func FindDefinition(node ast.Node, name string) *DefinitionFinder
FindDefinition finds the definition of a named variable or constant
The returned struct will be nil if the definition was not found, or a struct locating the definition of the value otherwise
type Field ¶
type Field struct { Name string Type string Transaction *Transaction FallibleLiteral bool PointerLiteral bool Length func(string) string Bytes func(string) string FallibleBytes bool // contains filtered or unexported fields }
Field stores metadata about a field
func NewField ¶
func NewField(name, nativeType string, tx *Transaction) Field
NewField creates a new Field struct
func ParseField ¶
func ParseField(f *ast.Field, tx *Transaction) ([]Field, error)
ParseField parses the given node of the AST as if it were a Field
Because an AST field might define multiple logical fields, this may return multiple values
func (*Field) IsSignature ¶
IsSignature is true if the field is a signature field
func (Field) Literal ¶
Literal returns an appropriate literal for this field
If the transaction has an example, the example's value is used. Otherwise, a newly-generated value is used.
func (*Field) LiteralName ¶
LiteralName returns an appropriate literal name for an instance of this field
type Transaction ¶
Transaction stores metadata about a transaction
func ParseTransaction ¶
func ParseTransaction(name string, node ast.Node, examplesMap map[string]metatx.Transactable) (out Transaction, err error)
ParseTransaction parses the given node of the AST as if it were a Transaction
func (Transaction) HasField ¶
func (t Transaction) HasField(name string) bool
HasField is true if the transaction has a field with the specified name
func (Transaction) JSON ¶
func (t Transaction) JSON() string
JSON returns the JSON form of this transaction's example
func (Transaction) Multisig ¶
func (t Transaction) Multisig() bool
Multisig is true if this transaction supports multiple signatures