Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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({
async version(msgVerison=1) {
const { result } = await this.network.GetNetworkId();
return bytes.pack(result, msgVerison);
}
async version(msgVerison=1) {
const { result } = await this.network.GetNetworkId();
return bytes.pack(result, msgVerison);
}
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
async version(msgVerison = 1) {
const { result } = await this.network.GetNetworkId()
return bytes.pack(result, msgVerison)
}
setVersion(version: number) {
return bytes.pack(this.chainID, version);
}
}