How to use the @zilliqa-js/util.bytes.pack function in @zilliqa-js/util

To help you get started, we’ve selected a few @zilliqa-js/util 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 / nucleus-wallet / src / redux / zil / sagas.ts View on Github external
import {
  getAddressFromPrivateKey,
  getPubKeyFromPrivateKey,
  fromBech32Address
} from '@zilliqa-js/crypto';
import { Long, bytes, units, BN } from '@zilliqa-js/util';
import { RPCMethod } from '@zilliqa-js/core';
import { Transaction } from '@zilliqa-js/account';

import axios from 'axios';

import * as consts from './actions';
import { HOST } from '../../api';
import { CHAIN_ID, MSG_VERSION } from '../../constants';

const VERSION = bytes.pack(CHAIN_ID, MSG_VERSION);

const getZilState = (state) => state.zil;

export function* accessWalletSaga(action) {
  // debounce by 500ms
  yield delay(500);
  try {
    const { payload } = action;
    const privateKey: string = payload.privateKey;
    const address = getAddressFromPrivateKey(privateKey);
    const publicKey = getPubKeyFromPrivateKey(privateKey);

    const { zilliqa } = yield select(getZilState);
    zilliqa.wallet.addByPrivateKey(privateKey);

    yield put({
github zilpay / zil-pay / extension / controllers / services / blockchain / zilliqa.js View on Github external
async version(msgVerison=1) {
    const { result } = await this.network.GetNetworkId();
    return bytes.pack(result, msgVerison);
  }
github zilpay / zil-pay / src / controllers / services / blockchain / zilliqa.js View on Github external
async version(msgVerison=1) {
    const { result } = await this.network.GetNetworkId();
    return bytes.pack(result, msgVerison);
  }
github Zilliqa / nucleus-wallet / src / contexts / zil-context / index.tsx View on Github external
import React from 'react';
import {
  getAddressFromPrivateKey,
  getPubKeyFromPrivateKey,
  fromBech32Address
} from '@zilliqa-js/crypto';
import { Long, bytes, units, BN } from '@zilliqa-js/util';
import { Transaction } from '@zilliqa-js/account';

import { Zilliqa } from '@zilliqa-js/zilliqa';
import { HTTPProvider, RPCMethod } from '@zilliqa-js/core';
import { NODE_URL, CHAIN_ID, MSG_VERSION } from '../../constants';

const provider = new HTTPProvider(NODE_URL);
const zilliqa = new Zilliqa(NODE_URL, provider);
const version = bytes.pack(CHAIN_ID, MSG_VERSION);

const getHost = (host: string) => {
  switch (host) {
    default:
      return 'https://us-central1-nucleus-wallet.cloudfunctions.net';
  }
};

const isOk = (code) => code < 400;

const initialState: any = {
  wallet: zilliqa.wallet,
  isAuth: undefined,
  address: undefined,
  publicKey: undefined,
  privateKey: undefined
github zilpay / zil-pay / packages / background / services / blockchain / zilliqa.js View on Github external
async version(msgVerison = 1) {
    const { result } = await this.network.GetNetworkId()

    return bytes.pack(result, msgVerison)
  }
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-core / src / providers / http.ts View on Github external
setVersion(version: number) {
    return bytes.pack(this.chainID, version);
  }
}