Home Reference Source Repository
public class | source

Fetcher

Fetcher class is used for fetching blockchain deployed Fincontracts, by calling appropriate functions (see getFincontractInfo and getDescriptionInfo from FincontractMarketplace). It recursively traverses the deployed Fincontract and constructs it's copy for further processing in memory.

Constructor Summary

Public Constructor
public

Constructs the Fetcher object with Fincontracts smart contract instance

Method Summary

Public Methods
public

constructNode(descInfo: Array, childrenIds: Array): FincNode

Constructs a current FincNode given it's description, which uniquely specifies the type of node to be constructed as well as its already constructed sub-nodes (childrenIds) and returns the currentNode. Due to lack of direct support for Timebound and Scale nodes by FincontractMarketplace, they are inferred from the description.

  • FincScaleNode - Scale node is constructed if description contains scale factor not equal to 1
  • FincTimeboundNode - Timebound node is constructed if description contains lower bound not equal to 0
In both cases, nodes are constructed above the current node and the top node is returned from the function

public

Fetches the blockchain deployed Fincontract description given its 32-byte address.

public

Fetches the blockchain deployed Fincontract info given its 32-byte address.

public

async pullDescription(descID: String): FincNode

Performs a recursive description fetch, given a root 32-byte address of the blockchain deployed Fincontract description

public

Fetches Fincontract from blockchain given its 32-byte address, by recursively fetching nodes and it's children and constructing the FincNode description tree (see Fetcher#pullDescription)

Public Constructors

public constructor(marketplace: FincontractMarketplace) source

Constructs the Fetcher object with Fincontracts smart contract instance

Params:

NameTypeAttributeDescription
marketplace FincontractMarketplace

a Fincontracts smart contract instance

Public Methods

public constructNode(descInfo: Array, childrenIds: Array): FincNode source

Constructs a current FincNode given it's description, which uniquely specifies the type of node to be constructed as well as its already constructed sub-nodes (childrenIds) and returns the currentNode. Due to lack of direct support for Timebound and Scale nodes by FincontractMarketplace, they are inferred from the description.

  • FincScaleNode - Scale node is constructed if description contains scale factor not equal to 1
  • FincTimeboundNode - Timebound node is constructed if description contains lower bound not equal to 0
In both cases, nodes are constructed above the current node and the top node is returned from the function

Params:

NameTypeAttributeDescription
descInfo Array

array containing description, as defined by getDescriptionInfo from FincontractMarketplace

childrenIds Array

array containing FincNode children of the current node

Return:

FincNode

newly constructed node

public getDescriptionInfo(descID: String): Promise<String, Error> source

Fetches the blockchain deployed Fincontract description given its 32-byte address. Returns a promise, that resolves to the Fincontract description as defined by getDescriptionInfo function in FincontractMarketplace or rejects with an Error if the whole description was empty.

Params:

NameTypeAttributeDescription
descID String

32-byte address of the blockchain deployed Fincontract description

Return:

Promise<String, Error>

promise, that resolves with the description or rejects with an Error if the description was empty.

public getFincontractInfo(fctID: String): Promise<String, Error> source

Fetches the blockchain deployed Fincontract info given its 32-byte address. Returns a promise, that resolves to the Fincontract info as defined by getFincontractInfo function in FincontractMarketplace or rejects with an Error if the Fincontract was not found.

Params:

NameTypeAttributeDescription
fctID String

32-byte address of the blockchain deployed Fincontract

Return:

Promise<String, Error>

promise, that resolves with the info or rejects with an Error if the Fincontract was not found.

public async pullDescription(descID: String): FincNode source

Performs a recursive description fetch, given a root 32-byte address of the blockchain deployed Fincontract description

Params:

NameTypeAttributeDescription
descID String

32-byte address of a blockchain deployed Fincontract's description

Return:

FincNode

fetched FincNode description tree

public async pullFincontract(fctID: String): Fincontract source

Fetches Fincontract from blockchain given its 32-byte address, by recursively fetching nodes and it's children and constructing the FincNode description tree (see Fetcher#pullDescription)

Params:

NameTypeAttributeDescription
fctID String

32-byte address of a blockchain deployed Fincontract

Return:

Fincontract

fetched Fincontract instance