Options
All
  • Public
  • Public/Protected
  • All
Menu

js-test-env

Index

Type aliases

TTransaction

TTransaction: Exclude<Transaction, GenesisTransaction | PaymentTransaction>

TTransactionType

TTransactionType: Exclude<any, 1 | 2>

TTx

TTx: SignedTransaction<TTransaction>

TTxParams

Type parameters

  • LONG

WithChainId

WithChainId: object

Type declaration

Variables

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, requestOptions?: RequestInit): Promise<Record<string, TDataEntry>>
  • Get full account dictionary By default uses current environment address and node

    Parameters

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

    Returns Promise<Record<string, TDataEntry>>

accountDataByKey

  • accountDataByKey(key: string, address?: undefined | string, apiBase?: undefined | string, requestOptions?: RequestInit): Promise<TDataEntry>
  • 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
    • Optional requestOptions: RequestInit

    Returns Promise<TDataEntry>

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, requestOptions?: RequestInit): 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
    • Optional requestOptions: RequestInit

    Returns Promise<any>

balance

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

    Parameters

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

    Returns Promise<number>

balanceDetails

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

    Parameters

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

    Returns Promise<any>

broadcast

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

    Parameters

    • tx: TTx
    • Optional apiBase: undefined | string
    • Optional requestOptions: RequestInit

    Returns Promise<any>

burn

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

    Parameters

    Returns IBurnTransaction & WithId

cancelLease

  • Creates cancel-lease transaction or signs already formed one

    Parameters

    Returns ICancelLeaseTransaction & WithId

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, requestOptions?: RequestInit): Promise<number>
  • Current blockchain height By default has 20s timeout and uses current environment node

    Parameters

    • Optional apiBase: undefined | string
    • Optional requestOptions: RequestInit

    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, requestOptions?: RequestInit): Promise<any>
  • Creates invoke tx and broadcasts it

    Parameters

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

    Returns Promise<any>

invokeScript

  • Creates invoke-script transaction or signs already formed one

    Parameters

    Returns IInvokeScriptTransaction & WithId

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

  • Creates mass-transfer transaction or signs already formed one

    Parameters

    Returns IMassTransferTransaction & WithId

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

  • Creates reissue transaction or signs already formed one

    Parameters

    Returns IReissueTransaction & WithId

setAssetScript

  • Creates set-asset-script transaction or signs already formed one

    Parameters

    Returns ISetAssetScriptTransaction & WithId

setScript

  • Creates set-script transaction or signs already formed one

    Parameters

    Returns ISetScriptTransaction & WithId

setupAccounts

  • setupAccounts(balances: Record<string, number>, options?: ISetupAccountsOptions, requestOptions?: RequestInit): Promise<Record<string, string>>
  • Generates test accounts with balances. Sends waves 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

    • balances: Record<string, number>
    • Optional options: ISetupAccountsOptions
    • Optional requestOptions: RequestInit

    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

  • Creates sponsorship transaction or signs already formed one

    Parameters

    Returns ISponsorshipTransaction & WithId

stateChanges

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

    Parameters

    • invokeScriptTxId: string
    • Optional apiBase: undefined | string
    • Optional requestOptions: RequestInit

    Returns Promise<any>

transactionById

  • transactionById(txId: string, apiBase?: undefined | string, requestOptions?: RequestInit): 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
    • Optional requestOptions: RequestInit

    Returns Promise<ITransaction & WithId & object>

transfer

  • Creates transfer transaction or signs already formed one

    Parameters

    Returns ITransferTransaction & WithId

updateAssetInfo

  • Creates updateAssetInfo transaction or signs already formed one

    Parameters

    Returns IUpdateAssetInfoTransaction & WithId

waitForHeight

  • waitForHeight(target: number, options?: INodeRequestOptions, requestOptions?: RequestInit): 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
    • Optional requestOptions: RequestInit

    Returns Promise<void>

waitForTx

  • waitForTx(txId: string, options?: INodeRequestOptions, requestOptions?: RequestInit): Promise<TTx & object>
  • 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
    • Optional requestOptions: RequestInit

    Returns Promise<TTx & object>

waitForTxWithNConfirmations

  • waitForTxWithNConfirmations(txId: string, confirmations: number, options?: INodeRequestOptions, requestOptions?: RequestInit): Promise<TTx & object>
  • 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
    • Optional requestOptions: RequestInit

    Returns Promise<TTx & object>

waitNBlocks

  • waitNBlocks(blocksCount: number, options?: INodeRequestOptions, requestOptions?: RequestInit): 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
    • Optional requestOptions: RequestInit

    Returns Promise<void>

Generated using TypeDoc