Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TezosHelpers

Tezos Util class for Tezos related Atomex helper functions

Hierarchy

Index

Constructors

  • new TezosHelpers(tezos: TezosToolkit, entrypoints: Record<string, any>, contractAddress: string, timeBetweenBlocks: number, gasLimit: number, minimalFees: number, minimalNanotezPerGasUnit: number, minimalNanotezPerByte: number, costPerByte: number, redeemTxSize: number, initiateTxSize: number): TezosHelpers
  • Parameters

    • tezos: TezosToolkit
    • entrypoints: Record<string, any>
    • contractAddress: string
    • timeBetweenBlocks: number
    • gasLimit: number
    • minimalFees: number
    • minimalNanotezPerGasUnit: number
    • minimalNanotezPerByte: number
    • costPerByte: number
    • redeemTxSize: number
    • initiateTxSize: number

    Returns TezosHelpers

Methods

  • buildAddTransaction(secretHash: string, amount: number): PartialTransactionBody
  • Get the tx data for Atomex Contract AdditionalFunds call

    Parameters

    • secretHash: string
    • amount: number

    Returns PartialTransactionBody

    contract address and tx data that can be used to make a contract call

  • buildInitiateTransaction(initiateParameters: InitiateParameters): PartialTransactionBody
  • Get the tx data for Atomex Contract Initiate Swap call

    Parameters

    • initiateParameters: InitiateParameters

    Returns PartialTransactionBody

    contract address and tx data that can be used to make a contract call

  • buildRedeemTransaction(secret: string, hashedSecret?: string): PartialTransactionBody
  • Get the tx data for Atomex Contract Redeem Swap call

    Parameters

    • secret: string
    • hashedSecret: string = ""

    Returns PartialTransactionBody

    contract address and tx data that can be used to make a contract call

  • buildRefundTransaction(secretHash: string): PartialTransactionBody
  • Get the tx data for Atomex Contract Refund Swap call

    Parameters

    • secretHash: string

    Returns PartialTransactionBody

    contract address and tx data that can be used to make a contract call

  • calcFees(gas?: number, storageDiff?: number, txSize?: number): number
  • Parameters

    • gas: number = 0
    • storageDiff: number = 0
    • txSize: number = 0

    Returns number

  • encodePublicKey(pubKey: string): string
  • encodeSignature(signature: string): string
  • estimateInitiateFees(source: string): Promise<number>
  • estimateRedeemFees(recipient: string): Promise<RedeemFees>
  • Estimates Miner Fee and Reward for Redeem to be used in a Swap

    Parameters

    • recipient: string

    Returns Promise<RedeemFees>

    the minerFee and the rewardForRedeem

  • findContractCall(block: BlockResponse, txID: string): OperationContentsAndResultTransaction[]
  • Parameters

    • block: BlockResponse
    • txID: string

    Returns OperationContentsAndResultTransaction[]

  • getAuthMessage(message: string, address: string): AuthMessage
  • Get the details needed for getAuthToken request

    remarks

    the msgToSign value needs to be signed before being used for Auth

    Parameters

    • message: string
    • address: string

    Returns AuthMessage

    details required for Atomex Auth

  • getBlockDetails(block: BlockResponse): { level: number; timestamp: number }
  • Get Block level

    Parameters

    • block: BlockResponse

    Returns { level: number; timestamp: number }

    level of the block and block generation time

    • level: number
    • timestamp: number
  • isValidAddress(address: string): boolean
  • parseInitiateParameters(content: OperationContentsAndResultTransaction): InitiateParameters
  • Parameters

    • content: OperationContentsAndResultTransaction

    Returns InitiateParameters

  • validateInitiateTransaction(blockHeight: number, txID: string, secretHash: string, receivingAddress: string, amount: number, payoff: number, minRefundTimestamp: number, minConfirmations?: number): Promise<SwapTransactionStatus>
  • Validate the Swap Details on chain using the tx detail from Atomex [does not check tx status, use status provided by atomex]

    Parameters

    • blockHeight: number
    • txID: string
    • secretHash: string
    • receivingAddress: string
    • amount: number
    • payoff: number
    • minRefundTimestamp: number
    • minConfirmations: number = 2

    Returns Promise<SwapTransactionStatus>

    status of tx, current no. of confirms and est. next block generation timestamp. No. of confirmations and block timestamp is only returned when status:Included

  • create(network: Network, currency?: TezosBasedCurrency, rpcUri?: string): Promise<TezosHelpers>
  • Connects to the supported tezos chain

    Parameters

    • network: Network

      networks supported by atomex, can be either mainnet or testnet

    • currency: TezosBasedCurrency = "XTZ"

      either native currency (XTZ) or any supported FA1.2/FA2 token symbol

    • Optional rpcUri: string

    Returns Promise<TezosHelpers>

    chain id of the connected chain

Generated using TypeDoc