Options
All
  • Public
  • Public/Protected
  • All
Menu

js-test-env

Index

Type aliases

TOrder

TTx

Type parameters

  • LONG

TTxParams

Type parameters

  • LONG

Variables

Const accounts

accounts: Record<string, string>

Contains seeds generated by setupAccounts function E.g:

await setupAccounts({foo:10, bar: 20})
console.log(accounts.foo, accounts.bar) // these variables now contain seeds from accounts with 10 and 20 wavelets

Functions

accountData

  • accountData(address?: undefined | string, apiBase?: undefined | string): Promise<Record<string, IDataEntry>>
  • Get full account dictionary By default uses current environment address and node

    Parameters

    • Optional address: undefined | string
    • Optional apiBase: undefined | string

    Returns Promise<Record<string, IDataEntry>>

accountDataByKey

  • accountDataByKey(key: string, address?: undefined | string, apiBase?: undefined | string): Promise<IDataEntry>
  • Get data from account dictionary by key By default uses current environment address and node

    Parameters

    • key: string
    • Optional address: undefined | string
    • Optional apiBase: undefined | string

    Returns Promise<IDataEntry>

address

  • address(seed?: undefined | string, chainId?: undefined | string): string
  • Generates address By default uses current environment seed and chainId

    Parameters

    • Optional seed: undefined | string
    • Optional chainId: undefined | string

    Returns string

alias

  • Creates alias transaction or signs already formed one. Creates alias for address. Alias could be used in place of address later

    Parameters

    Returns IAliasTransaction & WithId

assetBalance

  • assetBalance(assetId: string, address?: undefined | string, apiBase?: undefined | string): Promise<any>
  • Retrieve information about specific asset account balance By default uses current environment address and node

    Parameters

    • assetId: string
    • Optional address: undefined | string
    • Optional apiBase: undefined | string

    Returns Promise<any>

balance

  • balance(address?: undefined | string, apiBase?: undefined | string): Promise<number>
  • Get account effective balance By default uses current environment address and node

    Parameters

    • Optional address: undefined | string
    • Optional apiBase: undefined | string

    Returns Promise<number>

balanceDetails

  • balanceDetails(address?: undefined | string, apiBase?: undefined | string): Promise<any>
  • Retrieve full information about acryl account balance. Effective, generating etc By default uses current environment address and node

    Parameters

    • Optional address: undefined | string
    • Optional apiBase: undefined | string

    Returns Promise<any>

broadcast

  • broadcast(tx: TTx, apiBase?: undefined | string): Promise<any>
  • Sends transaction to acryl node By default uses current environment address and node

    Parameters

    • tx: TTx
    • Optional apiBase: undefined | string

    Returns Promise<any>

burn

  • Creates burn transaction or signs already formed one. Burn transaction destroys tokens. You cannot burn ACRYL

    Parameters

    Returns IBurnTransaction & WithId

cancelLease

cancelOrder

  • Creates cancel-order request or signs already formed one

    Parameters

    Returns ICancelOrder

compile

  • compile(code: string): string
  • Returns base64 representations of compiled ride file

    Parameters

    • code: string

    Returns string

contract

  • contract(): Promise<string>
  • Shorthand for file()

    Returns Promise<string>

currentHeight

  • currentHeight(apiBase?: undefined | string): Promise<number>
  • Current blockchain height By default has 20s timeout and uses current environment node

    Parameters

    • Optional apiBase: undefined | string

    Returns Promise<number>

data

  • Creates data transaction or signs already formed one

    Parameters

    Returns IDataTransaction & WithId

expect

  • expect(target: any, message?: undefined | string): any
  • Shorthand for chai.expect chai

    Parameters

    • target: any
    • Optional message: undefined | string

    Returns any

file

  • file(name?: undefined | string): string
  • Returns file content as string. Either from 'ride' folder or WEB IDE storage

    Parameters

    • Optional name: undefined | string

    Returns string

invoke

  • invoke(options: IInvokeOptions, seed?: undefined | string, apiBase?: undefined | string): Promise<any>
  • Creates invoke tx and broadcasts it

    Parameters

    • options: IInvokeOptions
    • Optional seed: undefined | string
    • Optional apiBase: undefined | string

    Returns Promise<any>

invokeScript

issue

  • Creates issue transaction or signs already formed one

    Parameters

    Returns IIssueTransaction & WithId

keyPair

  • keyPair(seed?: undefined | string): object
  • Generates key pair from seed By default uses current environment seed

    Parameters

    • Optional seed: undefined | string

    Returns object

lease

  • Creates lease transaction or signs already formed one

    Parameters

    Returns ILeaseTransaction & WithId

massTransfer

order

  • Creates order or signs already formed one

    Parameters

    Returns TOrder & WithId

privateKey

  • privateKey(seed?: undefined | string): string
  • Generates private key from seed By default uses current environment seed

    Parameters

    • Optional seed: undefined | string

    Returns string

publicKey

  • publicKey(seed?: undefined | string): string
  • Generates public key from seed By default uses current environment seed

    Parameters

    • Optional seed: undefined | string

    Returns string

reissue

setAssetScript

setScript

setupAccounts

  • setupAccounts(balances: Record<string, number>, options?: ISetupAccountsOptions): Promise<Record<string, string>>
  • Generates test accounts with balances. Sends acryl to generated accounts from master seed. Saves account seeds accounts E.g.: setupAccounts({foo:1000}). Now accounts['foo'] contains seed phrase for account and this account has 1000 wavelets By default uses current environment node and seed as masterSeed

    Usage

    const wvs = 10 ** 8
    describe('some suite', () => {
        before(async ()) => {
            await setupAccounts({foo: 1 * wvs, bar: 2 * wvs})
        })
    
        it('logs balances', async () => {
            console.log(await balance(address(accounts.foo)))
            console.log(await balance(address(accounts.bar)))
        })
    })

    Parameters

    Returns Promise<Record<string, string>>

signBytes

  • signBytes(bytes: Uint8Array, seed?: undefined | string): string
  • Signs arbitrary bytes By default uses current environment seed and chainId

    Parameters

    • bytes: Uint8Array
    • Optional seed: undefined | string

    Returns string

signTx

sponsorship

stateChanges

  • stateChanges(invokeScriptTxId: string, apiBase?: undefined | string): Promise<any>
  • Get invokeScript tx state changes By default uses current environment address and node

    Parameters

    • invokeScriptTxId: string
    • Optional apiBase: undefined | string

    Returns Promise<any>

transactionById

  • transactionById(txId: string, apiBase?: undefined | string): Promise<ITransaction & WithId & object>
  • Get transaction by Id. Returns null if no transaction with such id present in blockchain

    Parameters

    • txId: string
    • Optional apiBase: undefined | string

    Returns Promise<ITransaction & WithId & object>

transfer

waitForHeight

  • waitForHeight(target: number, options?: INodeRequestOptions): Promise<void>
  • Resolves after target height has been reached By default has 20s timeout and uses current environment node

    Parameters

    • target: number
    • Optional options: INodeRequestOptions

    Returns Promise<void>

waitForTx

  • waitForTx(txId: string, options?: INodeRequestOptions): Promise<TTx>
  • Resolves when specified txId is mined into the block By default has 20s timeout and uses current environment node

    Usage

    const tx = .....
    await broadcast(tx)
    await waitForTx(tx.id)

    Parameters

    • txId: string
    • Optional options: INodeRequestOptions

    Returns Promise<TTx>

waitForTxWithNConfirmations

  • waitForTxWithNConfirmations(txId: string, confirmations: number, options?: INodeRequestOptions): Promise<TTx>
  • Resolves N blocks after specified txId is mined into the block By default has 20s timeout and uses current environment node

    Parameters

    • txId: string
    • confirmations: number
    • Optional options: INodeRequestOptions

    Returns Promise<TTx>

waitNBlocks

  • waitNBlocks(blocksCount: number, options?: INodeRequestOptions): Promise<void>
  • Resolves N blocks after current blockchain height By default has 20s timeout and uses current environment node

    Parameters

    • blocksCount: number
    • Optional options: INodeRequestOptions

    Returns Promise<void>

Generated using TypeDoc