Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QueueZilliqa

Hierarchy

  • Core
    • QueueZilliqa

Index

Constructors

constructor

  • new QueueZilliqa(zil?: Zilliqa, protocol?: { chainId: number; msgVersion: number }, secondsPerTxBlockAverage?: number): QueueZilliqa
  • Parameters

    • Optional zil: Zilliqa
    • protocol: { chainId: number; msgVersion: number } = ...

      the chain id and the message version of the used blockchain

      • chainId: number
      • msgVersion: number
    • secondsPerTxBlockAverage: number = 60

      the seconds on average it takes for a new transaction block to be created

    Returns QueueZilliqa

Properties

Protected VERSION

VERSION: number

Protected code

code: string

Protected secondsPerTxBlockAverage

secondsPerTxBlockAverage: number

Protected zil

zil: undefined | Zilliqa

Methods

Protected createValueParam

  • createValueParam(type: All, vname: string, value: ValueField): Value
  • Parameters

    • type: All
    • vname: string
    • value: ValueField

    Returns Value

deploy

  • deploy(payload: { maxQueueSize: string }, ownerAddress: string, options?: { gasLimit?: Long; gasPrice?: BN }): Promise<[string, Contract, Transaction]>
  • example

    const [address1, queueInstance, deployTx1] = await queue.deploy( { maxQueueSize: "3", }, deployerAddress );

    Parameters

    • payload: { maxQueueSize: string }

      the max queue size

      • maxQueueSize: string
    • ownerAddress: string

      the address of the owner of the queue

    • options: { gasLimit?: Long; gasPrice?: BN } = ...

      optional gas price and gas limit for the deploy

      • Optional gasLimit?: Long
      • Optional gasPrice?: BN

    Returns Promise<[string, Contract, Transaction]>

    the contract address the instance and confirmed transaction

futureTxBlockNumber

  • futureTxBlockNumber(blockNumber: number, secondsToAdd: number): string
  • example

    const txblock = await zil.blockchain.getLatestTxBlock(); const curBlockNumber = parseInt(txblock.result.header.BlockNum); // approx blocknumber 60 seconds into the future const futureBlockNumber = qv.futureTxBlockNumber(curBlockNumber, 60);

    Parameters

    • blockNumber: number

      the current block number of the blockchain

    • secondsToAdd: number

      seconds to add to the blocknumber to receive a block number that will be the current one x seconds in the future

    Returns string

Protected getCallParamsPayload

  • getCallParamsPayload(__namedParameters: { amount: number; gasLimit?: Long; gasPrice: BN }): [{ amount: BN; gasLimit: Long; gasPrice: BN; version: number }, number, number, boolean]
  • Parameters

    • __namedParameters: { amount: number; gasLimit?: Long; gasPrice: BN }
      • amount: number
      • Optional gasLimit?: Long
      • gasPrice: BN

    Returns [{ amount: BN; gasLimit: Long; gasPrice: BN; version: number }, number, number, boolean]

Protected getConfirmedTx

  • getConfirmedTx(tx: Transaction): Promise<Transaction>
  • Parameters

    • tx: Transaction

    Returns Promise<Transaction>

getContractState

  • getContractState(address: string, maxRetries?: number, intervalMs?: number): Promise<QueueState>
  • example

    const queueState = await queue.getContractState(address1, 14);

    Parameters

    • address: string

      the address of the contract to read state off

    • maxRetries: number = 6

      optional max number of retries to call the blockchain

    • intervalMs: number = 750

      optional interval in which the retries increase lineraly with

    Returns Promise<QueueState>

    the state of the queue

Protected getGasPriceAndLimit

  • getGasPriceAndLimit(__namedParameters: { gasLimit?: Long; gasPrice?: BN }): Promise<{ gasLimit: Long; gasPrice: BN }>
  • Parameters

    • __namedParameters: { gasLimit?: Long; gasPrice?: BN }
      • Optional gasLimit?: Long
      • Optional gasPrice?: BN

    Returns Promise<{ gasLimit: Long; gasPrice: BN }>

getInstance

  • getInstance(contractAddress: string): Contract
  • Parameters

    • contractAddress: string

      the address of a deployed qv or queue contract

    Returns Contract

    the instance of that contract

Protected getZil

  • getZil(): Zilliqa

getZilPay

  • getZilPay(): Promise<any>
  • webonly
    webonly
    webonly
    webonly
    example

    const provider = await qv.connectAndGetZilPayProvider(); const zil = new Zilliqa("", provider);

    Returns Promise<any>

handleDeploy

  • handleDeploy(promise: Promise<[Transaction, Contract]>): Promise<[string, Contract, Transaction]>
  • example

    const [address, instance, deployTx] = await qv.handleDeploy( contract.deploy(...qv.payloadDeploy({ gasPrice })) );

    Parameters

    • promise: Promise<[Transaction, Contract]>

      that is returned from the zil sdk

    Returns Promise<[string, Contract, Transaction]>

handleMinGas

  • handleMinGas(promise: Promise<RPCResponse<string, string>>): Promise<BN>
  • example

    const gasPrice = await qv.handleMinGas(zil.blockchain.getMinimumGasPrice());

    Parameters

    • promise: Promise<RPCResponse<string, string>>

      that is returned from the zil sdk

    Returns Promise<BN>

payloadDeploy

  • payloadDeploy(__namedParameters: { gasLimit?: Long; gasPrice: BN }): DeployPayload
  • description

    Payload used to deploy contracts

    example

    const gasPrice = await qv.handleMinGas(zil.blockchain.getMinimumGasPrice()); contractInstance.deploy(...qv.payloadDeploy({ gasPrice }));

    Parameters

    • __namedParameters: { gasLimit?: Long; gasPrice: BN }
      • Optional gasLimit?: Long
      • gasPrice: BN

    Returns DeployPayload

payloadPushQueue

  • payloadPushQueue(__namedParameters: ContractCall<{ addressToPush: string }>): CallPayload
  • description

    Payload to make a contract call to the push function it pushes the given address to the queue and dequeues the oldest one if max is reached

    note

    cannot push the same address

    warning

    ONLY OWNER OF QUEUE CAN CALL THIS

    example

    const pushTx = await queueInstance.call(...queue.payloadPushQueue({ payload: { addressToPush: qvotingAddress }, gasPrice }));

    Parameters

    • __namedParameters: ContractCall<{ addressToPush: string }>

    Returns CallPayload

payloadQueue

  • payloadQueue(__namedParameters: { ownerAddress: string; payload: { maxQueueSize: string } }): ContractPayload
  • description

    Payload that allows to create a contract factory instance

    example

    const queueContract = zil.contracts.new(...queue.payloadQueue({ payload: { maxQueueSize: "3", }, ownerAddress: deployerAddress, }));

    Parameters

    • __namedParameters: { ownerAddress: string; payload: { maxQueueSize: string } }
      • ownerAddress: string
      • payload: { maxQueueSize: string }
        • maxQueueSize: string

    Returns ContractPayload

push

  • push(queueInstance: Contract, payload: { addressToPush: string }, options?: { gasLimit?: Long; gasPrice?: BN }): Promise<Transaction>
  • example

    const pushTx = await queue.push(regeneratedQueueInstance, { addressToPush: qvotingAddress, });

    Parameters

    • queueInstance: Contract

      the instance of the deployed queue

    • payload: { addressToPush: string }

      the addresses to push to the queue

      • addressToPush: string
    • options: { gasLimit?: Long; gasPrice?: BN } = ...

      optional gas price and gas limit for the deploy

      • Optional gasLimit?: Long
      • Optional gasPrice?: BN

    Returns Promise<Transaction>

    confirmed transaction of the push

Protected retryLoop

  • retryLoop(maxRetries: number, intervalMs: number, func: () => Promise<RPCResponse<Value[], any>>): Promise<[undefined | Value[], any]>
  • Parameters

    • maxRetries: number
    • intervalMs: number
    • func: () => Promise<RPCResponse<Value[], any>>
        • (): Promise<RPCResponse<Value[], any>>
        • Returns Promise<RPCResponse<Value[], any>>

    Returns Promise<[undefined | Value[], any]>

Protected stripInit

  • stripInit(init: Value[]): {}
  • Parameters

    • init: Value[]

    Returns {}

    • [key: string]: any

Generated using TypeDoc