Skip to content
UrsZeidler edited this page Oct 16, 2016 · 11 revisions

Generated JS Code

In the preferences you can activate the generation of js code:

For each contract package Two files are generated a [package.name/]Web3.js and a [package.name/]-main.js

While the [package.name/]Web3.js contains only the abi for each contract in a variable [aClass.name/]Contract the [package.name/]-main.js file defines a lot of js objects for each contract.

  • function [aClass.name/]Model(contract) - A model element which simply wrapped the contract.
  • function [aClass.name/]GuiFactory() - Creates a gui for the contract
    • this.placeDefaultGui=function(e) - Places the gui in the given element e, or document.getElementById(this.prefix+'[aClass.name/]_gui')
    • this.createDefaultGui=function() - creates the default gui
    • this.createAttributesGui=function() - create the attributes
    • for each public contract function a function this.create[op.functionName()/]Gui=function()
    • for each struc a function this.create[p.name/]StructGui=function()
  • function [aClass.name/]Controller() - A class to update the gui with the contract data
    • this.bindGui=function() - Binds the wigets to onClick
    • this.setAddress=function() - Set the address and the contract instance
    • this._updateAttributes=function ()- Update the attribute values of the gui
    • for each public contract method a function to get the values from the gui and a call to the contact function with these values is created
  • function [aClass.name/]Manager(prefix,contract) - For the contract the guifactory and the Controller are used together.
    • this.addGui = function(e) - Add a gui for the contract at e or document.getElementById(this.prefix + 'GuiContainer')
    • this.clearGui = function(e) - Clears the element e or document.getElementById(this.prefix + 'GuiContainer')
    • this.updateGui = function() - Update the attributes
  • function [aClass.name/]GuiMananger(guiId) - Manages a set of contracts
    • this.addManager = function(contract) - add a contract to the guimanager
    • this.clearGui = function(e) - Clears the element e or document.getElementById(this.prefix)
    • this.displayGui = function(e) - add to e or document.getElementById(this.prefix) for each contract the gui
    • this.updateGui = function() - update all attributes
  • function [aClass.name/]Deployment(guiId)

And for the package a

  • function [aPackage.name.toUpperFirst()/]Page(prefix)

A simple html file is also written, including the [package.name/]-main.js and some basic elements.

testCode for the contracts

The generated test code is a file [package.name/]-test.jsand a [package.name/]-tests.html for each contract the test.js contains a simple wrapper([aClass.name]Model) and a Test[aClass.name] is generated. The Test[aClass.name] contains a test function for each public contract function.

The generated html will execute the allTests() function on each contract.

Clone this wiki locally