Home Reference Source Test
public class | source

Simbachain

Extends:

SimbaBase → Simbachain

libsimba API Interaction for Simbachain.com

Constructor Summary

Public Constructor
public

constructor(endpoint: string, wallet: Wallet)

libsimba API Interaction for Simbachain.com

Member Summary

Public Members
public

Method Summary

Public Methods
public

async addFunds(): Promise<Object>

public

async callMethod(method: string, parameters: Object): Promise

public

async callMethodWithFile(method: string, parameters-: Object, files: Array<Blob|File>): Promise<Object>

public
public

async getBundleForTransaction(transactionIdOrHash: string): Promise<ReadableStream|Blob>

public

async getBundleMetadataForTransaction(transactionIdOrHash: string): Promise<Object>

public

async getFileFromBundleByNameForTransaction(transactionIdOrHash: string, fileName: string, stream: boolean): Promise<ReadableStream|Blob>

public

async getFileFromBundleForTransaction(transactionIdOrHash: string, fileIdx: number, stream: boolean): Promise<ReadableStream|Blob>

public

async getMethodTransactions(method: string, parameters: Object): Promise<PagedResponse>

public

async getTransaction(transactionIdOrHash: string): Promise<Object>

public
public
Protected Methods
protected
Private Methods
private
private
private
private

async initialize()

private

async sendMethodRequest(url: string, formdata: object): Promise<Response>

private

async submitTxn(txnId: string, signed: string): Promise<Response>

Inherited Summary

From class SimbaBase
public

apiKey: *

public
public
public

metadata: {}

public

wallet: *

public abstract
public abstract

callMethod(method: string, parameters: Object): Promise

public abstract

callMethodWithFile(method: string, parameters: Object, files: Array<Blob|File>): Promise<Object>

public abstract
public abstract
public abstract

getBundleForTransaction(transactionIdOrHash: string, stream: boolean): Promise<ReadableStream|Blob>

public abstract
public abstract

getFileFromBundleByNameForTransaction(transactionIdOrHash: string, fileName: string, stream: boolean): Promise<ReadableStream|Blob>

public abstract

getFileFromBundleForTransaction(transactionIdOrHash: string, fileIdx: number, stream: boolean): Promise<ReadableStream|Blob>

public abstract

getMethodTransactions(method: string, parameters: Object)

public abstract

getTransaction(transactionIdOrHash: string): Promise<Object>

public abstract
public abstract
public abstract
public abstract
public

setApiKey(apiKey: string)

Set the API Key to authenticate calls

public

setManagementKey(managementKey: string)

Set the API Key to authenticate management calls

public

setWallet(wallet: Wallet)

Set the wallet

public

waitForSuccessOrError(txnId: string, pollInterval: number): *

Returns an object with 'future' and 'cancel' keys.

private

apiAuthHeaders(): {APIKEY: *, "Content-Type": string}

private abstract
private abstract
private

managementAuthHeaders(): {APIKEY: *, "Content-Type": string}

private
private

validateCall(methodName: string, parameters: Object, files: Array): boolean

private

validateGetCall(methodName: string, parameters: Object): boolean

Public Constructors

public constructor(endpoint: string, wallet: Wallet) source

libsimba API Interaction for Simbachain.com

Override:

SimbaBase#constructor

Params:

NameTypeAttributeDescription
endpoint string

The endpoint of the API

wallet Wallet
  • optional

an optional Wallet instance

Public Members

public metadata: * source

Override:

SimbaBase#metadata

Public Methods

public async addFunds(): Promise<Object> source

Override:

SimbaBase#addFunds

Return:

Promise<Object>

details of the txn

public async callMethod(method: string, parameters: Object): Promise source

Override:

SimbaBase#callMethod

Params:

NameTypeAttributeDescription
method string

the method to call

parameters Object

the parameters for the method

Return:

Promise

a promise resolving with the transaction details

public async callMethodWithFile(method: string, parameters-: Object, files: Array<Blob|File>): Promise<Object> source

Override:

SimbaBase#callMethodWithFile

Params:

NameTypeAttributeDescription
method string

the method to call

parameters- Object

the parameters for the method

files Array<Blob|File>

the files

Return:

Promise<Object>

a promise resolving with the transaction details

public async getBalance(): Promise<Object> source

Override:

SimbaBase#getBalance

Return:

Promise<Object>

the balance

public async getBundleForTransaction(transactionIdOrHash: string): Promise<ReadableStream|Blob> source

Override:

SimbaBase#getBundleForTransaction

Params:

NameTypeAttributeDescription
transactionIdOrHash string

Either a transaction ID or a transaction hash

Return:

Promise<ReadableStream|Blob>

The bundle

public async getBundleMetadataForTransaction(transactionIdOrHash: string): Promise<Object> source

Override:

SimbaBase#getBundleMetadataForTransaction

Params:

NameTypeAttributeDescription
transactionIdOrHash string

Either a transaction ID or a transaction hash

Return:

Promise<Object>

The bundle metadata

public async getFileFromBundleByNameForTransaction(transactionIdOrHash: string, fileName: string, stream: boolean): Promise<ReadableStream|Blob> source

Override:

SimbaBase#getFileFromBundleByNameForTransaction

Params:

NameTypeAttributeDescription
transactionIdOrHash string

Either a transaction ID or a transaction hash

fileName string

The name of the file in the bundle metadata

stream boolean

If true, returns a ReadableStream, otherwise returns a Blob

Return:

Promise<ReadableStream|Blob>

The file

public async getFileFromBundleForTransaction(transactionIdOrHash: string, fileIdx: number, stream: boolean): Promise<ReadableStream|Blob> source

Override:

SimbaBase#getFileFromBundleForTransaction

Params:

NameTypeAttributeDescription
transactionIdOrHash string

Either a transaction ID or a transaction hash

fileIdx number

The index of the file in the bundle metadata

stream boolean

If true, returns a ReadableStream, otherwise returns a Blob

Return:

Promise<ReadableStream|Blob>

The file

public async getMethodTransactions(method: string, parameters: Object): Promise<PagedResponse> source

Override:

SimbaBase#getMethodTransactions

Params:

NameTypeAttributeDescription
method string

The method

parameters Object

The query parameters

Return:

Promise<PagedResponse>

A response wrapped in a PagedResponse helper

public async getTransaction(transactionIdOrHash: string): Promise<Object> source

Override:

SimbaBase#getTransaction

Params:

NameTypeAttributeDescription
transactionIdOrHash string

Either a transaction ID or a transaction hash

Return:

Promise<Object>

The transaction

public getTransactionStatus(txnId: string): Promise<Object> source

Override:

SimbaBase#getTransactionStatus

Params:

NameTypeAttributeDescription
txnId string

the transaction ID

Return:

Promise<Object>

a promise resolving with the transaction details

public async getTransactions(parameters: Object): Promise<PagedResponse> source

Override:

SimbaBase#getTransactions

Params:

NameTypeAttributeDescription
parameters Object

The query parameters

Return:

Promise<PagedResponse>

A response wrapped in a PagedResponse helper

Protected Methods

protected async sendTransactionRequest(url: URL): Promise<PagedResponse> source

Override:

SimbaBase#sendTransactionRequest

Params:

NameTypeAttributeDescription
url URL

The URL

Return:

Promise<PagedResponse>

A response wrapped in a PagedResponse helper

Private Methods

private checkTransactionDone(txn: Object): boolean source

Override:

SimbaBase#checkTransactionDone

Params:

NameTypeAttributeDescription
txn Object

the transaction object

Return:

boolean

is the transaction complete

private checkTransactionStatus(txnId: string): Object source

Override:

SimbaBase#checkTransactionStatus

Params:

NameTypeAttributeDescription
txnId string

a transaction ID

Return:

Object

an object with status details

private checkTransactionStatusFromObject(txn: Object): Object source

Override:

SimbaBase#checkTransactionStatusFromObject

Params:

NameTypeAttributeDescription
txn Object

a transaction object

Return:

Object

an object with status details

private async initialize() source

Override:

SimbaBase#initialize

private async sendMethodRequest(url: string, formdata: object): Promise<Response> source

Params:

NameTypeAttributeDescription
url string

the url

formdata object

Formdata for the POST

Return:

Promise<Response>

The response with transaction data

private async submitTxn(txnId: string, signed: string): Promise<Response> source

Params:

NameTypeAttributeDescription
txnId string

the txnId

signed string

The signed txn

Return:

Promise<Response>

The response with transaction data