How to use the @zilliqa-js/crypto.decodeBase58 function in @zilliqa-js/crypto

To help you get started, we’ve selected a few @zilliqa-js/crypto 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 zilpay / zil-pay / extension / controllers / services / blockchain / zilliqa.js View on Github external
[
      'amount',
      'toAddr'
    ].forEach(key => {
      if (!payload.hasOwnProperty(key)) {
        throw new Error(
          errorsCode.WrongRequiredparam + key
        );
      }
    });

    const storage = new BrowserStorage();
    let forConfirm = await storage.get(fields.CONFIRM_TX);

    if (validation.isBase58(payload.toAddr)) {
      payload.toAddr = decodeBase58(payload.toAddr);
    } else if (validation.isBech32(payload.toAddr)) {
      payload.toAddr = fromBech32Address(payload.toAddr);
    }

    payload.toAddr = toChecksumAddress(payload.toAddr);

    try {
      forConfirm = forConfirm[fields.CONFIRM_TX];
      forConfirm.push(payload);
    } catch(err) {
      forConfirm = [payload];
    }

    await storage.set(new BuildObject(fields.CONFIRM_TX, forConfirm));
    this.notificationsCounter(forConfirm);
  }