Home Reference Source Repository
public class | source

GatewayVisitor

Extends:

VisitorCollectingVisitor → GatewayVisitor

GatewayVisitor performs the actual Gateway update by traversing the FincNode description tree. It extends CollectingVisitor, in order to receive a list of Promises that resolve when Gateways are updated.

Constructor Summary

Public Constructor
public

constructor(web3: Web3, gateway: Gateway)

Constructs the GatewayVisitor object with a web3 instance connected to an Ethereum node and a Gateway smart contract instance not connected to any address

Method Summary

Public Methods
public

Called during preorder traversal when processing FincIfNode.

public

Called during preorder traversal when processing FincScaleObsNode.

public

Updates a single Gateway.

Inherited Summary

From class Visitor
public abstract

Called when processing FincAndNode.

public abstract

Called when processing FincGiveNode.

public abstract

Called when processing FincIfNode.

public abstract

Called when processing FincOneNode.

public abstract

Called when processing FincOrNode.

public abstract

Called when processing FincScaleNode.

public abstract

Called when processing FincScaleObsNode.

public abstract

Called when processing FincTimeboundNode.

public abstract

Called when processing FincZeroNode.

public

Visits current node.

From class CollectingVisitor
public

processAndNode(node: FincNode, left: Object, right: Object): Array

Called during preorder traversal when processing FincAndNode.

public

Called during preorder traversal when processing FincGiveNode.

public

processIfNode(node: FincNode, left: Object, right: Object): Array

Called during preorder traversal when processing FincIfNode.

public

Called during preorder traversal when processing FincOneNode.

public

processOrNode(node: FincNode, left: Object, right: Object): Array

Called during preorder traversal when processing FincOrNode.

public

Called during preorder traversal when processing FincScaleNode.

public

Called during preorder traversal when processing FincScaleObsNode.

public

Called during preorder traversal when processing FincTimeboundNode.

public

Called during preorder traversal when processing FincZeroNode.

Public Constructors

public constructor(web3: Web3, gateway: Gateway) source

Constructs the GatewayVisitor object with a web3 instance connected to an Ethereum node and a Gateway smart contract instance not connected to any address

Params:

NameTypeAttributeDescription
web3 Web3

a web3 instance connected to an Ethereum node

gateway Gateway

a gateway instance not connected to any address

Public Methods

public processIfNode(node: FincNode, left: Array<Promise>, right: Array<Promise>): Array source

Called during preorder traversal when processing FincIfNode. Updates the current node's Gateway and returns a Promise list to the parent node.

Override:

CollectingVisitor#processIfNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

left Array<Promise>

an Array of Promises containing Gateway updates from processing left child (first subtree) of the current node

right Array<Promise>

an Array of Promises containing Gateway updates from processing right child (second subtree) of the current node

Return:

Array

an Array of Promises containing the Promise that updates Gateway of the current node concatenated with the Promise lists of its children

public processScaleObsNode(node: FincNode, child: Array<Promise>): Array source

Called during preorder traversal when processing FincScaleObsNode. Updates the current node's Gateway and returns a Promise list to the parent node.

Override:

CollectingVisitor#processScaleObsNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

child Array<Promise>

an Array of Promises containing Gateway updates from processing its only child (its subtree)

Return:

Array

an Array of Promises containing the Promise that updates Gateway of the current node concatenated with the Promise list of its child

public updateGateway(address: String, type: String): Promise<null, Error> source

Updates a single Gateway. Gateway must conform to Gateway interface defined in FincontractMarketplace

Params:

NameTypeAttributeDescription
address String

32-byte address of a Gateway to be updated

type String

type of a Gateway: If or ScaleObs for logging purposes

Return:

Promise<null, Error>

promise which resolve to nothing if the Gateway was correctly update or rejects with an Error if the address was 0x0

Throw:

Error

If address is 0x0