How to use the @zilliqa-js/crypto.toChecksumAddress 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
throw new Error(errorsCode.WrongParams);
    }

    this.wallet.addByMnemonic(seed, index);

    const {
      address,
      publicKey,
      privateKey
    } = this.wallet.defaultAccount;
    const { result } = await this.getBalance(address);

    return {
      index, publicKey, privateKey,
      balance: result,
      address: toChecksumAddress(address)
    };
  }
github zilpay / zil-pay / extension / controllers / services / blockchain / zilliqa.js View on Github external
async addTransactionList(tx, net) {
    /**
     * @method: Add to storage payload data of completed transaction.
     * @param {tx}: Payload data.
     * @param net: It is network wthi which call transaction.
     */
    const storage = new BrowserStorage();
    const from = toChecksumAddress(tx.from);
    let txsList = await storage.get(fields.TRANSACTIONS);
    const data = {
      Info: tx.Info,
      TranID: tx.TranID,
      amount: tx.amount,
      toAddr: toChecksumAddress(tx.toAddr),
      nonce: tx.nonce
    };

    if (!net) {
      throw new Error(
        errorsCode.WrongRequiredparam + 'net'
      );
    }
    Object.keys(data).forEach(key => {
      if (!data[key]) {
github zilpay / zil-pay / extension / controllers / handlers.spec.js View on Github external
await ZilliqaHandler.initZilPay(value => {
      expect(value.provider).toBe(zilConfig[defaultSelected]['PROVIDER']);
      expect(value.isEnable).toBe(true);
      if (value.isConnect) {
        expect(value.account.address).toEqual(toChecksumAddress('a359105c9c8fda34278186c564ca2d3664e86821'));
      } else {
        expect(value.account).toBe(null);
      }
    });
  });
github zilpay / zil-pay / extension / controllers / handlers.spec.js View on Github external
await new AccountHandler().createAccountBySeed(value => {
      expect(value.resolve.selectedAddress).toEqual(2);
      expect(value.resolve.identities[2].index).toEqual(1);
      expect(value.resolve.identities[2].address).toEqual(toChecksumAddress('9ed19dd4c5d011eb458bbfda6d06d2db7ef9244f'));
    });
  });
github unstoppabledomains / resolution / src / Zns.ts View on Github external
async _getResolverRecords(resolverAddress: string): Promise {
    if (!resolverAddress || resolverAddress == NullAddress) {
      return {};
    }
    const resolver = this.zilliqa.contracts.at(
      toChecksumAddress(resolverAddress),
    );
    return ((await this.getContractField(resolver, 'records')) ||
      {}) as Dictionary;
  }
github zilpay / zil-pay / packages / background / services / blockchain / zilliqa.js View on Github external
async addTransactionList(tx, net) {
    const storage = new BrowserStorage()
    const from = toChecksumAddress(tx.from)
    let txsList = await storage.get(FIELDS.TRANSACTIONS)
    const data = {
      Info: tx.Info,
      TranID: tx.TranID,
      amount: tx.amount,
      toAddr: toChecksumAddress(tx.toAddr),
      nonce: tx.nonce
    }

    if (!net) {
      throw new Error(
        errorsCode.WrongRequiredparam + 'net'
      )
    }

    Object.keys(data).forEach(key => {
      if (!data[key]) {
        throw new Error(
          errorsCode.WrongRequiredparam + key
        )
      }
    })
github zilpay / zil-pay / packages / background / services / blockchain / zilliqa.js View on Github external
async getAccountByPrivateKey(importPrivateKey, index = 0) {
    if (!verifyPrivateKey(importPrivateKey)) {
      throw new Error(errorsCode.WrongPrivateKey)
    }

    const account = {
      privateKey: importPrivateKey,
      publicKey: getPubKeyFromPrivateKey(importPrivateKey),
      address: getAddressFromPrivateKey(importPrivateKey)
    }
    const { result } = await this.getBalance(account.address)

    account.address = toChecksumAddress(account.address)

    return {
      ...account,
      index,
      balance: result
    }
  }
github zilpay / zil-pay / src / filters / toAddress.js View on Github external
export default function (hex, format, isTrim=true) {
  let address;

  try {
    if (format === 'Base16') {
      address = toChecksumAddress(hex);
    } else if (format === 'Base58') {
      address = encodeBase58(hex);
    } else if (format === 'Bech32') {
      address = toBech32Address(hex);
    }
  } catch(err) {
    return null;
  }

  if (isTrim) {
    address = trim(address);
  }

  return address;
}
github zilpay / zil-pay / extension / controllers / services / blockchain / zilliqa.js View on Github external
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);
  }