Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FA12Helpers

TZIP-7 Util class for Tezos FA1.2 tokens related Atomex helper functions

Hierarchy

Index

Constructors

  • new FA12Helpers(tezos: TezosToolkit, entrypoints: Record<string, any>, contractAddress: string, timeBetweenBlocks: number, gasLimit: number, minimalFees: number, minimalNanotezPerGasUnit: number, minimalNanotezPerByte: number, costPerByte: number, redeemTxSize: number, initiateTxSize: number): FA12Helpers
  • 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 FA12Helpers

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
  • 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[]
  • 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
  • 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

      FA1.2 token symbol

    • Optional rpcUri: string

    Returns Promise<TezosHelpers>

    chain id of the connected chain

Generated using TypeDoc