How to use the @zilliqa-js/account.TxStatus.Rejected function in @zilliqa-js/account

To help you get started, we’ve selected a few @zilliqa-js/account examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-contract / src / contract.ts View on Github external
async prepareTx(
    tx: Transaction,
    attempts: number = GET_TX_ATTEMPTS,
    interval: number = 1000,
    isDeploy: boolean,
  ): Promise {
    const response = await this.provider.send(
      RPCMethod.CreateTransaction,
      { ...tx.txParams, priority: tx.toDS },
    );

    if (response.error) {
      this.address = undefined;
      this.error = response.error;
      return tx.setStatus(TxStatus.Rejected);
    }

    if (isDeploy) {
      this.address = response.result.ContractAddress
        ? toChecksumAddress(response.result.ContractAddress)
        : undefined;
    }

    return tx.confirm(response.result.TranID, attempts, interval);
  }