Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BnsConnection

Talks directly to the BNS blockchain and exposes the same interface we have with the BCP protocol.

We can embed in iov-core process or use this in a BCP-relay

Hierarchy

  • BnsConnection

Implements

  • AtomicSwapConnection

Index

Methods

chainId

  • chainId(): ChainId
  • The chain ID this connection is connected to

    We store this info from the initialization, no need to query every time

    Returns ChainId

disconnect

  • disconnect(): void

getAccount

  • getAccount(query: AccountQuery): Promise<Account | undefined>
  • Parameters

    • query: AccountQuery

    Returns Promise<Account | undefined>

getAllTokens

  • getAllTokens(): Promise<keyof Token[]>

getBlockHeader

  • getBlockHeader(height: number): Promise<BlockHeader>

Protected getDefaultFee

  • getDefaultFee(): Promise<Amount | undefined>
  • Queries the blockchain for the enforced anti-spam fee

    Returns Promise<Amount | undefined>

getElectionRules

  • getElectionRules(): Promise<keyof ElectionRule[]>

getElectorates

  • getElectorates(): Promise<keyof Electorate[]>

getFeeQuote

  • getFeeQuote(transaction: UnsignedTransaction): Promise<Fee>

getNonce

  • getNonce(query: AddressQuery | PubkeyQuery): Promise<Nonce>
  • Parameters

    • query: AddressQuery | PubkeyQuery

    Returns Promise<Nonce>

getNonces

  • getNonces(query: AddressQuery | PubkeyQuery, count: number): Promise<keyof Nonce[]>
  • Parameters

    • query: AddressQuery | PubkeyQuery
    • count: number

    Returns Promise<keyof Nonce[]>

Protected getProductFee

  • getProductFee(transaction: BnsTx): Promise<Amount | undefined>
  • Queries the blockchain for the enforced product fee for this kind of transaction. Returns undefined if no product fee is defined

    Parameters

    Returns Promise<Amount | undefined>

getProposals

  • getProposals(): Promise<keyof Proposal[]>

getSwaps

  • getSwaps(query: AtomicSwapQuery): Promise<keyof AtomicSwap[]>
  • All matching swaps that are open (in app state)

    To get claimed and returned, we need to look at the transactions.... TODO

    Parameters

    • query: AtomicSwapQuery

    Returns Promise<keyof AtomicSwap[]>

getSwapsFromState

  • getSwapsFromState(query: AtomicSwapQuery): Promise<keyof AtomicSwap[]>
  • All matching swaps that are open (from app state)

    Parameters

    • query: AtomicSwapQuery

    Returns Promise<keyof AtomicSwap[]>

getToken

  • getToken(ticker: TokenTicker): Promise<Token | undefined>

getTx

  • getTx(id: TransactionId): Promise<ConfirmedAndSignedTransaction<UnsignedTransaction> | FailedTransaction>
  • Parameters

    • id: TransactionId

    Returns Promise<ConfirmedAndSignedTransaction<UnsignedTransaction> | FailedTransaction>

getUsernames

getValidators

  • getValidators(): Promise<keyof Validator[]>

getVotes

  • getVotes(voter: Address): Promise<keyof Vote[]>

height

  • height(): Promise<number>

listenTx

  • listenTx(query: TransactionQuery): Stream<ConfirmedTransaction<LightTransaction> | FailedTransaction>
  • A stream of all transactions that match the tags from the present moment on

    Parameters

    • query: TransactionQuery

    Returns Stream<ConfirmedTransaction<LightTransaction> | FailedTransaction>

liveTx

  • liveTx(query: TransactionQuery): Stream<ConfirmedTransaction<LightTransaction> | FailedTransaction>
  • Does a search and then subscribes to all future changes.

    It returns a stream starting the array of all existing transactions and then continuing with live feeds

    Parameters

    • query: TransactionQuery

    Returns Stream<ConfirmedTransaction<LightTransaction> | FailedTransaction>

postTx

  • postTx(tx: PostableBytes): Promise<PostTxResponse>

Protected query

searchTx

  • searchTx(query: TransactionQuery): Promise<keyof (FailedTransaction | ConfirmedTransaction<LightTransaction>)[]>
  • Parameters

    • query: TransactionQuery

    Returns Promise<keyof (FailedTransaction | ConfirmedTransaction<LightTransaction>)[]>

Protected updateSwapAmounts

  • updateSwapAmounts<T>(swap: T): Promise<T>
  • Type parameters

    • T: AtomicSwap

    Parameters

    • swap: T

    Returns Promise<T>

watchAccount

  • watchAccount(query: AccountQuery): Stream<Account | undefined>
  • Gets current balance and emits an update every time it changes

    Parameters

    • query: AccountQuery

    Returns Stream<Account | undefined>

watchBlockHeaders

  • watchBlockHeaders(): Stream<BlockHeader>

watchSwaps

  • watchSwaps(query: AtomicSwapQuery): Stream<AtomicSwap>
  • Emits currentState (getSwap) as a stream, then sends updates for any matching swap

    This includes an open swap beind claimed/aborted as well as a new matching swap being offered

    Parameters

    • query: AtomicSwapQuery

    Returns Stream<AtomicSwap>

withDefaultFee

  • withDefaultFee<T>(transaction: T): Promise<T>
  • Type parameters

    • T: UnsignedTransaction

    Parameters

    • transaction: T

    Returns Promise<T>

Static establish

Generated using TypeDoc