JS Node Documentation

Welcome to libsimba-js


  

 

libsimba-js is a library simplifying the use of SIMBAChain APIs. We aim to abstract away the various blockchain concepts, reducing the necessary time needed to get to working code.

🏠 Homepage

📝 Documentation

Install

npm install @simbachain/libsimba-js

Usage

  • ES2105 module import
    import * as libsimba from '@simbachain/libsimba-js';
    libsimba.getSimbaInstance(...);
  • CommonJS module require
    const libsimba  = require('@simbachain/libsimba-js');
    libsimba.getSimbaInstance(...);
  • AMD module require
    require(['@simbachain/libsimba-js'], function (libsimba) {
    libsimba.getSimbaInstance(...);
    });
  • <script> tag import
    <!doctype html>
    <html>
    ...
    <script src="./dist/libsimba.js"></script>
    <script>
    // ...
    // Global variable
    libsimba.getSimbaInstance(...);
    // Property in the window object
    window.libsimba.getSimbaInstance(...);
    // ...
    </script>
    </html>

Examples

See here

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

License

Copyright © 2019 SIMBAChain Inc.
This project is MIT licensed.

 

import {BadMetadataException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

BadMetadataException

Extends:

Error → BaseException → BadMetadataException

Thrown when metadata doesn't have something it should have

Constructor Summary

Public Constructor
public   constructor

Member Summary

Public Members
public    name: string
Inherited Summary

From class

public       cause: *
public message: *
Public name: string

Public Constructors

public constructor()                                                          source

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string
 
import {BaseException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

BaseException

Extends:

Error → BaseException

Base exception that all libsimba Exceptions extend

Constructor Summary

Public Constructor
public

constructor(message: string, cause: Error | string)

Base exception that all libsimba Exceptions extend

 

 

 

 

Member Summary

public       cause: *
public message: *
Public name: string

 

Public Constructors

public constructor(message: string, cause: Error | string)                                 source

Base exception that all libsimba Exceptions extend

Params:

Name Type Attribute Description
message string  

the error message

cause Error | string
  • optional

(Optional) wrap an existing error

 

 

 

 

 

Public Members

public       cause: *
public message: *
Public name: string

 

import {GenerateTransactionException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

GenerateTransactionException

Extends:

Error → BaseException → GenerateTransactionException

Thrown when the server fails to generate the transaction for signing

Constructor Summary

Public Constructor
public

 

 

 

Member Summary

Public Members
public

 

 

 

Inherited Summary

public       cause: *
public message: *
Public name: string

Public Constructors

public constructor()                                                                   source

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                                                                                                 source
 
import {GetRequestException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

GetRequestException

Extends:

Error → BaseException → GetRequestException

Direct Subclass:

Thrown when the server returns an error when querying transactions

Constructor Summary

Public Constructor
public constructor()

 

 

 

 

 

Member Summary

Public Members
public namestring

 

 

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

 

 

Public Constructors

public constructor()

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string

Override:

BaseException#name

 

 

import {GetTransactionsException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

GetTransactionsException

Extends:

Error → BaseException → GetRequestException → GetTransactionsException

Thrown when the server returns an error when querying transactions

Constructor Summary

Public Constructor
public

 

Member Summary

Public Members
public

 

 

 

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

 

 

 

 

 From class GetRequestException
public

 

 

 

 

Public Constructors

public constructor()

 

Base exception that all libsimba Exceptions extend

 

Override:

GetRequestException#constructor

 

Public Members

public name: string                                                         source

Override:

GetRequestException#name

 

 

import {MethodCallValidationMetadataException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

MethodCallValidationMetadataException

Extends:

Error → BaseException → MethodCallValidationMetadataException

Thrown when a method call isn't valid

Constructor Summary

Public Constructor
public

 

 

Member Summary

Public Members
public

 

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

 

Public Constructors

public constructor()                                                               source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string

Override:

BaseException#name

 

 

import {MissingMetadataException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

MissingMetadataException

Extends:

Error → BaseException → MissingMetadataException

Thrown when a method on a class inheriting [SimbaBase]SimbaBase is called before metadata is retrieved.

Constructor Summary

Public Constructor
public

 

 

Member Summary

Public Members
public

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

Public Constructors

public constructor()                                                             source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                                 source

 

 
 
 
 
import {NotImplementedException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

NotImplementedException

Extends:

Error → BaseException → NotImplementedException

Thrown when a method that should be implemented is not

Constructor Summary

Public Constructor
public

 

 

Member Summary

Public Members
public

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

Public Constructors

public constructor()                                                                source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                               source

 

 
 
 
import {NotInBrowserException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

NotInBrowserException

Extends:

Error → BaseException → NotInBrowserException

Thrown when a LocalWallet is created in a non browser environment

Constructor Summary

Public Constructor
public

 

 

 

Member Summary

Public Members
public

 

 

 

Inherited Summary

From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

Public Constructors

public constructor()                                                                source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                               source

 

 
 
 
import {PostRequestException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

PostRequestException

Extends:

Error → BaseException → PostRequestException

Thrown when the server returns an error when querying transactions

Constructor Summary

Public Constructor
public

 

 

 

Member Summary

Public Members
public

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

Public Constructors

public constructor()                                                          source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                            source

 

 
 
import {RetriesExceededException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

RetriesExceededException

Extends:

Error → BaseException → SigningException → RetriesExceededException

Thrown when a method call exceeds the max retries

Constructor Summary

Public Constructor
public

 

 

 

Member Summary

Public Members
public

 

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

 

 

 From class SigningException
public

 

 

 

Public Constructors

public constructor()                                                          source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                                 source

 

 
 
 
import {SigningException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

SigningException

Extends:

Error → BaseException → SigningException

Thrown when there's an error signing a transaction

Constructor Summary

Public Constructor
public

 

 

Member Summary

Public Members
public

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

Public Constructors

public constructor()                                                              source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                                   source

 

 
 
 
import {SubmitTransactionException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

SubmitTransactionException

Extends:

Error → BaseException → SubmitTransactionException

Thrown when the server returns an error after submitting a signed transaction

Constructor Summary

Public Constructor
public

 

 

Member Summary

Public Members
public

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

Public Constructors

public constructor()                                                             source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                              source

 

 
 
import {TransactionStatusCheckException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

TransactionStatusCheckException

Extends:

Error → BaseException → TransactionStatusCheckException

Thrown when an error occurs checking a transactions status

Constructor Summary

Public Constructor
public

 

 

 

Member Summary

Public Members
public

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

Public Constructors

public constructor()                                                            source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                                  source

 

 
 
 
import {UserRejectedSigningException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

UserRejectedSigningException

Extends:

Error → BaseException → SigningException → UserRejectedSigningException

Thrown when the user rejects the request to sign

Constructor Summary

Public Constructor
public

 

 

Member Summary

Public Members
public

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

 

 From class SigningException
public

 

 

Public Constructors

public constructor()                                                               source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                               source

 

 
 
 
import {WalletLockedException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

WalletLockedException

Extends:

Error → BaseException → SigningException → WalletLockedException

Thrown when a method on a class inheriting [SimbaBase]SimbaBase is called that requires a [Wallet]Wallet to be unlocked, and it isn't.

Constructor Summary

Public Constructor
public

 

 

 

Member Summary

Public Members
public

 

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

 

 From class SigningException
public

 

 

 

Public Constructors

public constructor()                                                           source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                                   source

 

 
 
 
import {WalletNotFoundException} from '@simbachain/libsimba-js/src/exceptions.js'
public class | source

WalletNotFoundException

Extends:

Error → BaseException → SigningException → WalletNotFoundException

Thrown when a method on a class inheriting [SimbaBase]SimbaBase is called that requires a [Wallet]Wallet to be set, and it isn't.

Constructor Summary

Public Constructor
public

 

 

Member Summary

Public Members
public

 

 

Inherited Summary

 From class BaseException
public

cause: *

public

message: *

public

 

 

 

 

 

 

 

 

 From class SigningException
public

 

 

Public Constructors

public constructor()                                                          source

 

Base exception that all libsimba Exceptions extend

 

Public Members

public name: string                                                            source

 

 
 

Function

Static Public Summary
public

async getSimbaInstance(url: string, wallet: Wallet, apiKey: string, managementKey: string): Promise<Simbachain>

Create an instance of a Simbachain API interaction class Automatically takes care of choosing the correct implementation and running asynchronous initialisation.

Static Public

public async getSimbaInstance(url: string, wallet: Wallet, apiKey: string, managementKey: string): Promise<Simbachain>source
import {getSimbaInstance} from '@simbachain/libsimba-js/src/index.js'

Create an instance of a Simbachain API interaction class Automatically takes care of choosing the correct implementation and running asynchronous initialisation.

Params:

Name Type Attribute Description
url string  

The API URL

wallet Wallet  

The Wallet to use

apiKey string
  • optional

(Optional) The API key

managementKey string
  • optional

(Optional) The Management API key

 

 

 

 

 

 

 

Return:

Promise<Simbachain>

An initialised instance of the API interaction class

 

 

 

 

public class | source

PagedResponse

Wrapper for paged responses

Constructor Summary

Public Constructor
public

constructor(data: Object, url: URL, simba: SimbaBase)

Wrapper for paged responses

 

 

 

Member Summary

Public Members
public

results: *

public

simba: *

public

url: *

 

 

 

 

 

 

Private Members
private

_count: *

private
private

 

 

 

 

 

Method Summary

Public Methods
public

Returns the result count

public

Returns the current page number

public

data(): Object

Returns the actual data

public

async next(): Promise<PagedResponse> | null

Grab the next page

public

Returns the next page number

public

async previous(): Promise<PagedResponse> | null

Grab the previous page

public

Returns the previous page number

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Public Constructors

public constructor(data: Object, url: URL, simba: SimbaBase)source

Wrapper for paged responses

Params:

Name Type Attribute Description
data Object  

The response

url URL  

The URL that provided the response

simba SimbaBase  

The SimbaBase instance that requested the response

Public Members

public results: *                                                             source
 
public simba: *                                                                source
 
public url: *                                                                  source

 

 

Private Members

private _count: *                                                              source
 
private _next_page: *                                                          source
 
private _previous_page: *                                                      source

 

 

Public Methods

public count(): number                                                         source

Returns the result count

Return:

number
 
 
 
public current_page(): number                                          source

Returns the current page number

Return:

number

 
 
 
public data(): Object                                                   source

Returns the actual data

Return:

Object
 
 
 
public async next(): Promise<PagedResponse> | null                      source

Grab the next page

Return:

Promise<PagedResponse> | null

Null if there's no next page

 
 
 
 
public next_page(): number                                                source

Returns the next page number

Return:

number
 
 
 
public async previous(): Promise<PagedResponse> | null                     source

Grab the previous page

Return:

Promise<PagedResponse> | null

Null if there's no next page

 
 
 
 
public previous_page(): number                                              source

Returns the previous page number

Return:

number
 
 
 
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

async getBalance(): Promise<Object>

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

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

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 Constructors

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

 

libsimba API Interaction for Simbachain.com

Params:

Name Type Attribute Description
endpoint string  

The endpoint of the API

wallet Wallet
  • optional

an optional Wallet instance

 

 

 

 

 

Public Members

public metadata: *                                                     source
 

Public Methods

public async addFunds(): Promise<Object>                                       source
 

Return:

Promise<Object>

details of the txn

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

 

 

 

 

Params:

Name Type Attribute Description
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
 

Params:

Name Type Attribute Description
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
 

Return:

Promise<Object>

the balance

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

Params:

Name Type Attribute Description
transactionIdOrHash string  

Either a transaction ID or a transaction hash

 

 

 

 

Return:

Promise<ReadableStream|Blob>

The bundle

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

Params:

Name Type Attribute Description
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

Params:

Name Type Attribute Description
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

Params:

Name Type Attribute Description
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

Params:

Name Type Attribute Description
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

Params:

Name Type Attribute Description
transactionIdOrHash string  

Either a transaction ID or a transaction hash

 

 

 

Return:

Promise<Object>

The transaction

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

Params:

Name Type Attribute Description
txnId string  

the transaction ID

 

 

 

 

Return:

Promise<Object>

a promise resolving with the transaction details

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

Params:

Name Type Attribute Description
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

Params:

Name Type Attribute Description
url URL  

The URL

 

 

 

Return:

Promise<PagedResponse>

A response wrapped in a PagedResponse helper

 

 

Private Methods

private checkTransactionDone(txn: Object): boolean                            source

Params:

Name Type Attribute Description
txn Object  

the transaction object

 

 

 

Return:

boolean

is the transaction complete

 

 

private checkTransactionStatus(txnId: string): Object                               source

Params:

Name Type Attribute Description
txnId string  

a transaction ID

 

 

 

Return:

Object

an object with status details

 
 
 
 
private checkTransactionStatusFromObject(txn: Object): Object                         source

Params:

Name Type Attribute Description
txn Object  

a transaction object

 

 

 

 

Return:

Object

an object with status details

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

Params:

Name Type Attribute Description
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:

Name Type Attribute Description
txnId string  

the txnId

signed string  

The signed txn

 

 

 

 

 

Return:

Promise<Response>

The response with transaction data

 
 
 
 
 
 
 
 
public class | source

SimbaBase

Direct Subclass:

Constructor Summary

Public Constructor
public

constructor(endpoint: string, wallet: Wallet)

Base class for libsimba API Interaction implementations

 

 

 

 

 

Member Summary

Public Members
public

apiKey: *

 
public  
public  
public

metadata: {}

 
public

wallet: *

 

 

 

 

 

 

 

Method Summary

Public Methods
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 Methods
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

 

Base class for libsimba API Interaction implementations

Params:

Name Type Attribute Description
endpoint string  

The endpoint of the API

wallet Wallet
  • optional

an optional Wallet instance

 

 

 

 

 

Public Members

public apiKey: *source


public endpoint: stringsource


public managementKey: *source


public metadata: {}source


public wallet: *source

Public Methods

public abstract addFunds(): Promise<Object>source

Return:

Promise<Object>

details of the txn

 
 
 
 
 
public abstract callMethod(method: string, parameters: Object): Promisesource

 

Params:

Name Type Attribute Description
method string  

the method to call

parameters Object  

the parameters for the method

 

 

 

 

Return:

Promise

a promise resolving with the transaction details

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

 

Params:

Name Type Attribute Description
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 abstract checkTransactionStatus(txnId: string): Objectsource

 

Params:

Name Type Attribute Description
txnId string  

a transaction ID

 

 

 

Return:

Object

an object with status details

 

 

 

public abstract getBalance(): Promise<Object>source
 

Return:

Promise<Object>

the balance

 

 

 

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

 

Params:

Name Type Attribute Description
transactionIdOrHash string  

Either a transaction ID or a transaction hash

stream boolean  

If true, returns a ReadableStream, otherwise returns a Blob

Return:

Promise<ReadableStream|Blob>

The bundle

 

 

 

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

 

Params:

Name Type Attribute Description
transactionIdOrHash string  

Either a transaction ID or a transaction hash

 

 

Return:

Promise<Object>

The bundle metadata

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

 

Params:

Name

Type

Attribute

Description

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 abstract getFileFromBundleForTransaction(transactionIdOrHash: string, fileIdx: number, stream: boolean): Promise<ReadableStream|Blob>source

 

Params:

Name Type Attribute Description
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 abstract getMethodTransactions(method: string, parameters: Object)source

 

Params:

Name Type Attribute Description
method string  

The method

parameters Object  

The query parameters

 

 

 

 

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

 

Params:

Name Type Attribute Description
transactionIdOrHash string  

Either a transaction ID or a transaction hash

 

 

Return:

Promise<Object>

The transaction

 

 

 

 

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

Params:

Name Type Attribute Description
txnId string  

the transaction ID

 

 

Return:

Promise<Object>

a promise resolving with the transaction details

 

 

 

 

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

 

Params:

Name Type Attribute Description
parameters Object  

The query parameters

 

 

Return:

Promise<PagedResponse>

A response wrapped in a PagedResponse helper

 

 

 

 

public abstract initialize()source

 

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

 

Params:

Name Type Attribute Description
url URL  

The URL

 

 

Return:

Promise<PagedResponse>

A response wrapped in a PagedResponse helper

 

 

 

 

public setApiKey(apiKey: string)source

Set the API Key to authenticate calls

Params:

Name Type Attribute Description
apiKey string  

the API Key

 

 

public setManagementKey(managementKey: string)source

 

Set the API Key to authenticate management calls

Params:

Name Type Attribute Description
managementKey string  

the management API Key

 

 

public setWallet(wallet: Wallet)source

Set the wallet

Params:

Name Type Attribute Description
wallet Wallet  

the wallet

 

 

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

 

Returns an object with 'future' and 'cancel' keys. future is the promise to listen on for the response or an error. cancel is a function - call it to cancel the polling.

Params:

Name Type Attribute Description
txnId string  

the transaction ID

pollInterval number
  • optional
  • default: 5000

the interval in ms for polling

 

 

 

 

Return:

*
 

 

 

Private Methods

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

Return:

{APIKEY: *, "Content-Type": string}
 

 

 

private abstract checkTransactionDone(txn: Object): booleansource

 

Params:

Name Type Attribute Description
txn Object  

the transaction object

 

 

 

Return:

boolean

is the transaction complete

 

 

 

private abstract checkTransactionStatusFromObject(txn: Object): Object        source

Params:

Name Type Attribute Description
txn Object  

a transaction object

 

 

Return:

Object

an object with status details

 

 

 

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

Return:

{APIKEY: *, "Content-Type": string}
 

 

 

private validateAnyGetCall(): booleansource

 

 

Return:

boolean
 

 

Throw:

MissingMetadataException

App Metadata not yet retrieved

BadMetadataException

App Metadata doesn't have methods

 

 

private validateCall(methodName: string, parameters: Object, files: Array): booleansource

 

Params:

Name Type Attribute Description
methodName string  

the methods name

parameters Object  

the parameters for the method call

files Array
  • optional

Optional array of files

 

 

 

 

 

Return:

boolean
 

 

Throw:

MissingMetadataException

App Metadata not yet retrieved

BadMetadataException

App Metadata doesn't have methods

MethodCallValidationMetadataException

Method call fails validation

 

 

 

private validateGetCall(methodName: string, parameters: Object): booleansource

 

Params:

Name Type Attribute Description
methodName string  

the methods name

parameters Object  

the parameters for the query

 

 

 

Return:

boolean
 

 

Throw:

MissingMetadataException

App Metadata not yet retrieved

BadMetadataException

App Metadata doesn't have methods

MethodCallValidationMetadataException

Method call fails validation

 
 
 
 
 
 
public class | source

LocalWallet

Extends:

Wallet → LocalWallet

libsimba-js Local Wallet implementation Stores the wallet as encrypted json within the browsers localstorage Wraps the [ethersjs]https://docs.ethers.io/ethers.js/html/ library.

Constructor Summary

Public Constructor
public

constructor(signingConfirmation: function)

Use a wallet stored in the browsers local storage

 

 

 

 

Member Summary

Public Members

public

wallet  *

 

public

window: *

 

 

 

 

 

Method Summary

Public Methods
public
 
 
public

generateWallet(passkey: string, progressCB: function): Promise

 
 
public

generateWalletFromEncryptedJson(json: string, passkey: string, progressCB: function): Promise

Generate a wallet from a encrypted json (see [ethers docs]{@link https://docs.ethers.io/ethers.js/html/api-wallet.html?highlight=fromencryptedjson})

 
public

generateWalletFromMnemonic(mnemonic: string, passkey: string, progressCB: function): Promise

Generate a wallet from a mnemonic

 
public

generateWalletFromPrivateKey(key: string, passkey: string, progressCB: function): Promise

Generate a wallet from an existing private key

 
public
 
 
public

getEncryptedJson(passkey: string, progressCB: function): Promise<string>

 
 
public

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

 
public

unlockWallet(passkey: string, progressCB: function): Promise

 
 
public
 
 
Protected Methods
protected

sign(payload: Object): Promise<string>

 
 

 

 

 

 

 

Private Methods

private

cleanPayload(payload: Object): string

 
 

 

 

 

 

 

Inherited Summary

 From class Wallet

 

 

Public Constructors

public constructor(signingConfirmation: function)source

 

Use a wallet stored in the browsers local storage

Params:

Name Type Attribute Description
signingConfirmation function
  • optional
  • an optional callback for requesting user permission to sign a transaction. Should resolve a promise with true for accept, and false (or reject) for reject.

Public Members

public wallet: *source
 
public window: *source

 

 

Public Methods

public deleteWallet()source

 

 
public generateWallet(passkey: string, progressCB: function): Promisesource

 

Params:

Name Type Attribute Description
passkey string  

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is created

 
 
 
 
public generateWalletFromEncryptedJson(json: string, passkey: string, progressCB: function): Promisesource

 

Generate a wallet from a encrypted json (see [ethers docs]{@link https://docs.ethers.io/ethers.js/html/api-wallet.html?highlight=fromencryptedjson})

Params:

Name Type Attribute Description
json string  

The json

passkey string  

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is created

 
 
 
 
public generateWalletFromMnemonic(mnemonic: string, passkey: string, progressCB: function): Promisesource

 

Generate a wallet from a mnemonic

Params:

Name Type Attribute Description
mnemonic string  

The mnemonic

passkey string  

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is created

 
 
 
 
 
public generateWalletFromPrivateKey(key: string, passkey: string, progressCB: function): Promisesource

 

Generate a wallet from an existing private key

Params:

Name Type Attribute Description
key string  

The existing private key

passkey string  

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is created

 
 
 
 
public getAddress(): Promise<string>source

 

 

Return:

Promise<string>

Returns a promise resolving to the wallets address

 
 
 
public getEncryptedJson(passkey: string, progressCB: function): Promise<string>source

 

Params:

Name Type Attribute Description
passkey string  

Passkey to encrypt the wallet

progressCB function
  • optional

An optional callback to monitor progress of encryption, calls with a value between 0-1

Return:

Promise<string>

A promise that resolves with the JSON wallet

 
 
 
 
public getMnemonic(): stringsource

 

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

 

Return:

string

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

 
 
 
 
 
public unlockWallet(passkey: string, progressCB: function): Promisesource

 

Params:

Name Type Attribute Description
passkey string  

The pass key to unlock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is unlocked

 
 
 
 
public walletExists(): booleansource

 

 

Return:

boolean

does the wallet exist

 

Protected Methods

protected sign(payload: Object): Promise<string>source

 

Override:

Wallet#sign

Params:

Name Type Attribute Description
payload Object  

The transaction to sign

 

 

Return:

Promise<string>

Returns a promise resolving to the signed transaction

 

 

 

Private Methods

private cleanPayload(payload: Object): stringsource

 

Params:

Name Type Attribute Description
payload Object  

The transaction to clean

 

 

 

Return:

string

The cleaned transaction

 

 

 

 

 

public class | source

PKWallet

Extends:

Wallet → PKWallet

libsimba-js Private Key Wallet implementation Use when you already have access to the decrypted private key Wraps the [ethersjs]https://docs.ethers.io/ethers.js/html/ library.

Constructor Summary

Public Constructor
public

constructor(private_key: string, signingConfirmation: function)

Use when you already have access to the decrypted private key

 

 

 

 

 

Member Summary

Public Members
public

pk: *

 
public

wallet: *

 

 

 

 

 

 

 

Method Summary

Public Methods
public
 
 
public

generateWallet(passkey: string, progressCB: function): Promise

 
 
public
 
 
public

getEncryptedJson(passkey: string, progressCB: function): Promise<string>

 
 
public

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

 
public

unlockWallet(passkey: string, progressCB: function): Promise

 
 
public
 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Protected Methods
protected

sign(payload: Object): Promise<string>

 
 

 

 

 

Private Methods
private

cleanPayload(payload: Object): string

 
 

 

 

 

 

Inherited Summary

 From class Wallet

 

 

 

 

Public Constructors

public constructor(private_key: string, signingConfirmation: function)source

 

Use when you already have access to the decrypted private key

Params:

Name Type Attribute Description
private_key string
  • optional

The private key in hexidecimal format

signingConfirmation function
  • optional
  • an optional callback for requesting user permission to sign a transaction. Should resolve a promise with true for accept, and false (or reject) for reject.

Public Members

public pk: *source
 
public wallet: *source

 

 

Public Methods

public deleteWallet()source

 

 
public generateWallet(passkey: string, progressCB: function): Promisesource

 

Params:

Name Type Attribute Description
passkey string  

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving with the private key when the wallet is created

 
 
 
 
public getAddress(): Promise<string>source

 

 

Return:

Promise<string>

Returns a promise resolving to the wallets address

 

 

 

public getEncryptedJson(passkey: string, progressCB: function): Promise<string>source

 

Params:

Name Type Attribute Description
passkey string  

Passkey to encrypt the wallet

progressCB function
  • optional

An optional callback to monitor progress of encryption, calls with a value between 0-1

Return:

Promise<string>

A promise that resolves with the JSON wallet

 

 

 

public getMnemonic(): stringsource

 

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

 

Return:

string

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

 

 

 

public unlockWallet(passkey: string, progressCB: function): Promisesource

 

Params:

Name Type Attribute Description
passkey string  

The pass key to unlock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is unlocked

 

 

 

public walletExists(): booleansource

 

 

Return:

boolean

does the wallet exist

 

 

 

Protected Methods

protected sign(payload: Object): Promise<string>source

 

Override:

Wallet#sign

Params:

Name Type Attribute Description
payload Object  

The transaction to sign

 

 

Return:

Promise<string>

Returns a promise resolving to the signed transaction

 

 

 

Private Methods

private cleanPayload(payload: Object): stringsource

 

Params:

Name Type Attribute Description
payload Object  

The transaction to clean

 

 

 

Return:

string

The cleaned transaction

 

 

 

 

public class | source

Wallet

Direct Subclass:

Constructor Summary

Public Constructor
public

constructor(signingConfirmation: *)

Base class for libsimba Wallet implementations

 

 

 

 

 

Member Summary

Public Members
public
 
 

 

 

 

 

Method Summary

Public Methods
public abstract
 
public abstract
 
public abstract
 
public abstract

unlockWallet(passkey: string): Promise

 
public abstract
 
Protected Methods
protected abstract

sign(payload: Object): Promise<string>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Public Constructors

public constructor(signingConfirmation: *)source

 

Base class for libsimba Wallet implementations

Params:

Name Type Attribute Description
signingConfirmation *  

{function} - an optional callback for requesting user permission to sign a transaction. Should resolve a promise with true for accept, and false (or reject) for reject.

Public Members

public signingConfirmation: *source

 

 

Public Methods

public abstract deleteWallet()source

 

 
public abstract generateWallet(passkey: string): Promisesource

 

Params:

Name Type Attribute Description
passkey string  

The pass key to lock the wallet

 

 

 

Return:

Promise

Returns a promise resolving when the wallet is created

 
 
 
 
 
public abstract getAddress(): Promise<string>source

 

 

Return:

Promise<string>

Returns a promise resolving to the wallets address

 
 
 
 
 
public abstract unlockWallet(passkey: string): Promisesource

 

Params:

Name Type Attribute Description
passkey string  

The pass key to unlock the wallet

 

 

 

Return:

Promise

Returns a promise resolving when the wallet is unlocked

 
 
 
 
 
public abstract walletExists(): booleansource

 

 

Return:

boolean

does the wallet exist

 

 

 

Protected Methods

protected abstract sign(payload: Object): Promise<string>source

 

Params:

Name Type Attribute Description
payload Object  

The transaction to sign

 

 

 

Return:

Promise<string>

Returns a promise resolving to the signed transaction