Home Reference Source Repository
public class | source

Examples

Examples class is meant to deploy some of the tests defined in FincontractMarketplace as well as assign Gateways to global values. It's solely for testing purposes and should be removed once the project is released.

Constructor Summary

Public Constructor
public

constructor(marketplace: FincontractMarketplace, gatewaybool: Gateway, gatewayint: Gateway, web3: Web3)

Constucts the Examples object that allows for deployment of predefined tests

Method Summary

Public Methods
public

deploy(name: String, args: String, filter: TransactionFilter, callback: Function): Promise<String, Error>

Sends a transaction with proper name and arguments and starts watching for an event to happen, which is defined by filter and then triggers the the callback.

public

Sends a transaction with proper name and arguments and starts listening to CreatedBy event with callback that returns the id of newly created Fincontract.

public

Runs a predefined function on the blockchain.

public

Runs setGatewayI and setGatewayB FincontractMarketplace functions with specified parameters as addresses to these gateways.

Public Constructors

public constructor(marketplace: FincontractMarketplace, gatewaybool: Gateway, gatewayint: Gateway, web3: Web3) source

Constucts the Examples object that allows for deployment of predefined tests

Params:

NameTypeAttributeDescription
marketplace FincontractMarketplace

a Fincontracts smart contract instance

gatewaybool Gateway

a connected GatewayBool instance

gatewayint Gateway

a connected GatewayInteger instance

web3 Web3

a web3 instance connected to Ethereum node

Public Methods

public deploy(name: String, args: String, filter: TransactionFilter, callback: Function): Promise<String, Error> source

Sends a transaction with proper name and arguments and starts watching for an event to happen, which is defined by filter and then triggers the the callback.

Params:

NameTypeAttributeDescription
name String

name of the transaction

args String

arguments of the transaction

filter TransactionFilter

a filter object to listen for events

callback Function

a callback to be executed once event was triggered

Return:

Promise<String, Error>

promise that resolves to the value returned by the callback

public deployExample(name: String, args: Array): Promise<String, Error> source

Sends a transaction with proper name and arguments and starts listening to CreatedBy event with callback that returns the id of newly created Fincontract. (See Examples#deploy for more details)

Params:

NameTypeAttributeDescription
name String

name of the transaction

args Array

arguments of the transaction

Return:

Promise<String, Error>

promise that resolves to id of the newly created fincontract or reject with an Error if it has failed

public runExample(name: String): Promise<String, Error> source

Runs a predefined function on the blockchain. See FincontractMarketplace for more details.

Params:

NameTypeAttributeDescription
name String

name of the test to be dpeloyed

Return:

Promise<String, Error>

promise that resolves to fincontract ID or nothing in case of setting/resetting gateways or it rejects with an Error in case the transaction has failed

public setGateways(gwint: String, gwbool: String): Promise<String, Error> source

Runs setGatewayI and setGatewayB FincontractMarketplace functions with specified parameters as addresses to these gateways.

Params:

NameTypeAttributeDescription
gwint String

address of GatewayI

gwbool String

address of GatewayB

Return:

Promise<String, Error>

promise that resolve to nothing or rejects with an Error in case transaction has failed