Options
All
  • Public
  • Public/Protected
  • All
Menu

Logos Account

This class is the base class of an account on the Logos Network. The most common uses for this account is to check the balance, history, and create new requests from this account as the origin.

Hierarchy

Index

Constructors

constructor

  • Instantiating

    const LogosAccount = new LogosAccount({
        label: null,
        address: null,
        publicKey: null,
        balance: '0',
        pendingBalance: '0',
        wallet: null,
        chain: [],
        receiveChain: [],
        pendingChain: [],
        privateKey: null
        tokenBalances: {},
        tokens: [],
        pendingTokenBalances: {},
        index: null
    })

    All logos account options are optional defaults are shown in the example above

    Account Options Description
    label Account label e.g. Checking Account
    address Address is the lgs_ string
    publicKey Public key of the account
    balance Balance of the account in the minor unit of Logos
    pendingBalance balance of the account including pending transaction in the minor unit of Logos
    wallet reference back to the parent wallet class
    chain Array of Request that are confirmed on this account's send chain
    receiveChain Array of Request that are confirmed on this account's receive chain
    pendingChain Array of Request that are not confirmed on this account's send chain
    privateKey Private key of the account used to sign transactions
    tokenBalances Balances tokens that this account has in their
    tokens Array of token addresses associated with this account
    pendingTokenBalances Unconfirmed balances of the tokens
    index index of the account

    Parameters

    • Default value options: LogosAccountOptions = {privateKey: null,tokenBalances: {},tokens: [],pendingTokenBalances: {},index: null}

    Returns LogosAccount

Properties

Private _index

_index: number

Private _pendingTokenBalances

_pendingTokenBalances: TokenBalances

Private _privateKey

_privateKey: string

Private _tokenBalances

_tokenBalances: TokenBalances

Private _tokens

_tokens: string[]

Accessors

address

  • get address(): string

balance

  • get balance(): string
  • set balance(amount: string): void

balanceInLogos

  • get balanceInLogos(): string

chain

index

  • get index(): number

label

  • get label(): string
  • set label(label: string): void

pendingBalance

  • get pendingBalance(): string
  • set pendingBalance(amount: string): void
  • The pending balance of the account in reason

    pending balance is balance minus the sends that are pending

    type

    {string}

    readonly

    Returns string

  • The pending balance of the account in reason

    pending balance is balance minus the sends that are pending

    Parameters

    • amount: string

    Returns void

pendingChain

  • get pendingChain(): Request[]
  • set pendingChain(val: Request[]): void
  • array of pending requests on the account

    These requests have been sent for consensus but we haven't heard back on if they are confirmed yet.

    type

    {Request[]}

    Returns Request[]

  • array of pending requests on the account

    These requests have been sent for consensus but we haven't heard back on if they are confirmed yet.

    Parameters

    Returns void

pendingRequestCount

  • get pendingRequestCount(): number

pendingTokenBalances

  • The pending token balance of the account in the minor token unit

    pending token balance is balance minus the token sends that are pending

    Example

    const pendingTokenBalances = logosAccount.pendingTokenBalances

    Returns TokenBalances

previous

  • get previous(): string
  • Return the previous request as hash

    type

    {string}

    readonly

    Returns string

    hash of the previous transaction

privateKey

  • get privateKey(): string

publicKey

  • get publicKey(): string

receiveChain

  • get receiveChain(): Request[]
  • set receiveChain(val: Request[]): void

receiveCount

  • get receiveCount(): number
  • Gets the total number of requests on the receive chain

    type

    {number} count of all the requests

    readonly

    Returns number

requestCount

  • get requestCount(): number

sequence

  • get sequence(): number

synced

  • get synced(): boolean
  • set synced(val: boolean): void

tokenBalances

tokens

  • get tokens(): string[]
  • Array of associated token ids to this account (full list available only with fullsync)

    Example

    const tokens = logosAccount.tokens

    Returns string[]

type

  • get type(): "LogosAccount"

version

  • get version(): number

wallet

Methods

addConfirmedRequest

  • addConfirmedRequest(requestInfo: RpcRequest): Promise<Request>
  • Creates a request object from the mqtt info and adds the request to the appropriate chain

    Parameters

    • requestInfo: RpcRequest

      Request information from the RPC or MQTT

      Example

      logosAccount.addConfirmedRequest([[RpcRequest]])

    Returns Promise<Request>

addRequest

  • Adds the request to the pending chain and publishes it

    throws

    An exception if the pending balance is less than the required amount to adjust a users status

    Example

    const request = await logosAccount.addRequest(REQUEST)

    Parameters

    • request: Request

      Request information from the RPC or MQTT

    Returns Promise<Request>

Protected addToReceiveChain

  • addToReceiveChain(request: Request): void

Protected addToSendChain

  • addToSendChain(request: Request): void

addToken

  • addToken(tokenID: string): Promise<string[]>
  • Adds a token to the accounts associated tokens if it doesn't already exist

    Parameters

    • tokenID: string

      The TokenID you are associating with this account (this will be converted into a token account when stored)

    Returns Promise<string[]>

    Array of all the associated tokens

    Example

    const token = await logosAccount.addToken('lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd')

broadcastRequest

  • broadcastRequest(): Promise<Request>

Private combineRequests

  • combineRequests(): Promise<void>

createAdjustFeeRequest

  • Creates a request from the specified information

    throws

    An exception if the pending balance is less than the required amount to do a token distibution

    Example

    const request = await logosAccount.createAdjustFeeRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     feeType: 'flat',
     feeRate: '0'
    })

    Parameters

    Returns Promise<Request>

createAdjustUserStatusRequest

  • Creates a request from the specified information

    throws

    An exception if the pending balance is less than the required amount to adjust a users status

    Example

    const request = await logosAccount.createAdjustUserStatusRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     account: 'lgs_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo',
     status: 'frozen'
    })

    Parameters

    Returns Promise<Request>

createBurnRequest

  • Creates a Burn Token Request from the specified information

    throws

    An exception if the token account balance is less than the required amount to do a burn token request

    Example

    const request = await logosAccount.createBurnRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     amount: '1'
    })

    Parameters

    Returns Promise<Request>

createChangeSettingRequest

  • Creates a ChangeSetting Token Request from the specified information

    throws

    An exception if the token account balance is less than the required amount to do a change setting token request

    Example

    const request = await logosAccount.createChangeSettingRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     setting: 'issuance',
     value: true
    })

    Parameters

    Returns Promise<Request>

createDistributeRequest

  • Creates a request from the specified information

    throws

    An exception if the pending balance is less than the required amount to do a token distibution

    Example

    const request = await logosAccount.createDistributeRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     transaction: {
       amount: '1',
       destination: 'lgs_3mjbkiwijkbt3aqz8kzm5nmsfhtrbjwkmnyeqi1aoscc46t4xdnfdaunerr6'
     }
    })

    Parameters

    Returns Promise<Request>

createImmuteSettingRequest

  • Creates a ImmuteSetting Token Request from the specified information

    throws

    An exception if the token account balance is less than the required amount to do a immute setting token request

    Example

    const request = await logosAccount.createImmuteSettingRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     setting: 'issuance'
    })

    Parameters

    Returns Promise<Request>

createIssueAdditionalRequest

  • Creates a IssueAdditional Token Request from the specified information

    throws

    An exception if the token account balance is less than the required amount to do a issue additional token request

    Example

    const request = await logosAccount.createIssueAdditionalRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     amount: '1'
    })

    Parameters

    Returns Promise<Request>

createRevokeRequest

  • Creates a Revoke Token Request from the specified information

    throws

    An exception if the token account balance is less than the required amount to do a Revoke token request

    Example

    const request = await logosAccount.createRevokeRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     source: 'lgs_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo',
     transaction: {
       amount: '1',
       destination: 'lgs_3mjbkiwijkbt3aqz8kzm5nmsfhtrbjwkmnyeqi1aoscc46t4xdnfdaunerr6'
     }
    })

    Parameters

    Returns Promise<Request>

createSendRequest

  • Creates a request from the specified information

    throws

    An exception if the account has not been synced

    throws

    An exception if the pending balance is less than the required amount to do a send

    throws

    An exception if the request is rejected by the RPC

    Example

    const request = await logosAccount.createSendRequest([
     {
       destination: 'lgs_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo',
       amount: '1'
     }
    ])

    Parameters

    • transactions: Transaction[]

      The account destinations and amounts you wish to send them

    Returns Promise<Request>

createTokenIssuanceRequest

  • Creates a request from the specified information

    throws

    An exception if the account has not been synced

    throws

    An exception if the pending balance is less than the required amount to do a token issuance

    throws

    An exception if the request is rejected by the RPC

    Example

    const request = await logosAccount.createTokenIssuanceRequest(
     {
      name: `UnitTestCoin`,
      symbol: `UTC`,
      totalSupply: '1000',
      feeRate: '1',
      issuerInfo: '{"decimals":0,"website":"https://github.com/LogosNetwork/logos-webwallet-sdk"}',
      settings: {
        issuance: true,
        modify_issuance: true,
        revoke: true,
        modify_revoke: true,
        freeze: true,
        modify_freeze: true,
        adjust_fee: true,
        modify_adjust_fee: true,
        whitelist: false,
        modify_whitelist: true
      },
      controllers: [{
        account: 'lgs_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo',
        privileges: {
          change_issuance: true,
          change_modify_issuance: true,
          change_revoke: true,
          change_modify_revoke: true,
          change_freeze: true,
          change_modify_freeze: true,
          change_adjust_fee: true,
          change_modify_adjust_fee: true,
          change_whitelist: true,
          change_modify_whitelist: true,
          issuance: true,
          revoke: true,
          freeze: true,
          adjust_fee: true,
          whitelist: true,
          update_issuer_info: true,
          update_controller: true,
          burn: true,
          distribute: true,
          withdraw_fee: true,
          withdraw_logos: true
        }
      }]
     }
    )

    Parameters

    Returns Promise<Request>

createTokenSendRequest

  • Creates a request from the specified information

    throws

    An exception if the account has not been synced

    throws

    An exception if the pending balance is less than the required amount to do a send

    throws

    An exception if the request is rejected by the RPC

    Example

    const request = await logosAccount.createTokenSendRequest('lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd', [{
     destination: 'lgs_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo',
     amount: '1'
    }])

    Parameters

    • token: string

      The token address or token id

    • transactions: Transaction[]

      The account destinations and amounts you wish to send them

    Returns Promise<Request>

createUpdateControllerRequest

  • Creates a request from the specified information

    throws

    An exception if the pending balance is less than the required amount to Update Controller

    Example

    const request = await logosAccount.createUpdateControllerRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     action: 'add',
     controller: {
        account: 'lgs_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo',
        privileges: {
          change_issuance: true,
          change_modify_issuance: true,
          change_revoke: true,
          change_modify_revoke: true,
          change_freeze: true,
          change_modify_freeze: true,
          change_adjust_fee: true,
          change_modify_adjust_fee: true,
          change_whitelist: true,
          change_modify_whitelist: true,
          issuance: true,
          revoke: true,
          freeze: true,
          adjust_fee: true,
          whitelist: true,
          update_issuer_info: true,
          update_controller: true,
          burn: true,
          distribute: true,
          withdraw_fee: true,
          withdraw_logos: true
        }
      }
    })

    Parameters

    Returns Promise<Request>

createUpdateIssuerInfoRequest

  • Creates a request from the specified information

    throws

    An exception if the pending balance is less than the required amount to Update Issuer Info

    Example

    const request = await logosAccount.createUpdateIssuerInfoRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     issuerInfo: '{"decimals":0,"website":"https://github.com/LogosNetwork/logos-webwallet-sdk"}'
    })

    Parameters

    Returns Promise<Request>

createWithdrawFeeRequest

  • Creates a request from the specified information

    throws

    An exception if the pending balance is less than the required amount to do a withdraw fee request

    Example

    const request = await logosAccount.createWithdrawFeeRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     transaction: {
       amount: '1',
       destination: 'lgs_3mjbkiwijkbt3aqz8kzm5nmsfhtrbjwkmnyeqi1aoscc46t4xdnfdaunerr6'
     }
    })

    Parameters

    Returns Promise<Request>

createWithdrawLogosRequest

  • Creates a request from the specified information

    throws

    An exception if the pending balance is less than the required amount to do a withdraw logos request

    Example

    const request = await logosAccount.createWithdrawLogosRequest({
     tokenAccount: 'lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd',
     transaction: {
       amount: '1',
       destination: 'lgs_3mjbkiwijkbt3aqz8kzm5nmsfhtrbjwkmnyeqi1aoscc46t4xdnfdaunerr6'
     }
    })

    Parameters

    Returns Promise<Request>

getChainRequest

  • getChainRequest(hash: string): Request
  • Finds the request object of the specified request hash in the confirmed chain

    Parameters

    • hash: string

      The hash of the request we are looking for

    Returns Request

    false if no request object of the specified hash was found

getPendingRequest

  • getPendingRequest(hash: string): Request
  • Finds the request object of the specified request hash in the pending chain

    Parameters

    • hash: string

      The hash of the request we are looking for

    Returns Request

    false if no request object of the specified hash was found

getPendingRequestsUpTo

  • getPendingRequestsUpTo(hash: string): Request[]
  • Gets the requests up to a certain hash from the pending chain

    Parameters

    • hash: string

      Hash of the request you wish to stop retrieving requests at

    Returns Request[]

    all the requests up to and including the specified request

getReceiveRequestsUpTo

  • getReceiveRequestsUpTo(hash: string): Request[]
  • Gets the requests up to a certain hash from the receive chain

    Parameters

    • hash: string

      Hash of the request you wish to stop retrieving requests at

    Returns Request[]

    all the requests up to and including the specified request

Protected getRecieveRequest

  • getRecieveRequest(hash: string): Request
  • Finds the request object of the specified request hash in the recieve chain

    Parameters

    • hash: string

      The hash of the request we are looking for

    Returns Request

    false if no request object of the specified hash was found

getRequest

  • getRequest(hash: string): Request
  • Finds the request object of the specified request hash

    Parameters

    • hash: string

      The hash of the request we are looking for

    Returns Request

    null if no request object of the specified hash was found

getRequestsUpTo

  • getRequestsUpTo(hash: string): Request[]
  • Gets the requests up to a certain hash from the send chain

    Parameters

    • hash: string

      Hash of the request you wish to stop retrieving requests at

    Returns Request[]

    all the requests up to and including the specified request

getTokenAccount

  • getTokenAccount(token: string | object): Promise<TokenAccount>
  • Gets tokenAccount

    throws

    An exception if no tokenID or tokenAccount

    Example

    const request = await logosAccount.getTokenAccount('lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd')

    Parameters

    • token: string | object

    Returns Promise<TokenAccount>

isSynced

processRequest

  • processRequest(requestInfo: RpcRequest): Promise<void>
  • Confirms the request in the local chain

    Parameters

    • requestInfo: RpcRequest

      The request from MQTT

      Example

      await logosAccount.processRequest(
       RpcRequest
      )

    Returns Promise<void>

recentPendingRequests

  • recentPendingRequests(count?: number, offset?: number): Request[]
  • Retreives pending requests from the send chain

    Parameters

    • Default value count: number = 5

      Number of requests you wish to retrieve

    • Default value offset: number = 0

      Number of requests back from the frontier tip you wish to start at

    Returns Request[]

    all the requests

recentReceiveRequests

  • recentReceiveRequests(count?: number, offset?: number): Request[]
  • Retreives requests from the receive chain

    Parameters

    • Default value count: number = 5

      Number of requests you wish to retrieve

    • Default value offset: number = 0

      Number of requests back from the frontier tip you wish to start at

    Returns Request[]

    all the requests

recentRequests

  • recentRequests(count?: number, offset?: number): Request[]
  • Retreives requests from the send chain

    Parameters

    • Default value count: number = 5

      Number of requests you wish to retrieve

    • Default value offset: number = 0

      Number of requests back from the frontier tip you wish to start at

    Returns Request[]

    all the requests

removePendingRequest

  • removePendingRequest(hash: string): boolean
  • Called when a request is confirmed to remove it from the pending request pool

    Parameters

    • hash: string

      The hash of the request we are confirming

    Returns boolean

    true or false if the pending request was found and removed

removePendingRequests

  • removePendingRequests(): void

Private shouldCombine

  • shouldCombine(minimumSaved?: number): boolean
  • Determines if you shold combine requests

    Returns true if the pending chain has x sends and the count of total transactions is <= (x-minimumSaved) * 8

    Parameters

    • Default value minimumSaved: number = 1

      The minimum amount of requests saved in order to combine defaults to 1

    Returns boolean

sync

toJSON

tokenBalance

  • tokenBalance(token: string): object
  • The balance of the given token in the minor unit and major unit (if available)

    Parameters

    • token: string

    Returns object

    The balance in minor unit or converted units

    Example

    const tokenBalance = logosAccount.tokenBalance('lgs_3q69z3kf6cq9n9smago3p1ptuyqy9pa3mdykyi9o8f7gnof47qdyxj9gejxd')
    • Optional major?: string
    • minor: string

updateBalancesFromChain

  • updateBalancesFromChain(): void

updateBalancesFromRequest

  • updateBalancesFromRequest(request: Request): void
  • Updates the balances of the account by doing math on the previous balance when given a new request Also updates the pending balance based on the new balance and the pending chain

    Parameters

    • request: Request

      request that is being calculated on

      Example

      logosAccount.updateBalancesFromRequest()

    Returns void

validateRequest

  • validateRequest(request: Request): Promise<boolean>

verifyChain

  • verifyChain(): boolean

verifyReceiveChain

  • verifyReceiveChain(): boolean

Generated using TypeDoc