Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as debug from 'debug';
import * as EosLib from 'eosjs';
const { ecc } = EosLib.modules;
export const Eos = EosLib;
export const Ecc = ecc;
export const Debug = debug;
//
// console.log("Eos", Eos)
// console.log("Ecc", Ecc)
// console.log("Debug", Debug)
const altApi = (config: Json | any) => {
return new apiGen('v1', apiInterface, config);
};
const rpc = (endPoint: string = 'http://127.0.0.1:8888') => new JsonRpc(endPoint, { fetch });
const api = (rpcRef: typeof JsonRpc, signatureProvider: typeof JsSignatureProvider) =>
new Api({
rpc: rpcRef,
signatureProvider,
textDecoder: new TextDecoder(),
textEncoder: new TextEncoder(),
});
const eos = (config: { [prop: string]: any }) => Eos(config);
const { ecc } = Eos.modules;
export {
// def ap
api,
rpc,
RpcError,
eos,
ecc,
// ot
altApi,
processArgs,
apiInterface,
};
const Account = require('./account');
const is = require('./../helpers/is')
const eosECC = require('eosjs').modules.ecc;
const crypto = require('./../helpers/crypto');
const createAccountNameFromPublicKey = require('./public-key-name-generator').createAccountNameFromPublicKey;
class AccountFactory {
constructor(provider) {
this.provider = provider;
this.defaultOptions = {
authority: 'active',
accountCreator: this.provider.defaultAccount
}
}
load(name, privateKey, authorityName = this.defaultOptions.authority) {
return new Account(name, privateKey, this.provider, authorityName);
}
const is = require('../../helpers/is')
const eosECC = require('eosjs').modules.ecc;
const BaseAccount = require('../base-account');
const AuthorityAccount = require('../authority-account/account');
class Account extends BaseAccount {
constructor(name, privateKey, provider, permission) {
super(name, privateKey, provider, permission);
}
async buyRam(bytes, payer = this) {
is(payer).instanceOf('BaseAccount');
return this.provider.eos.transaction(tr => {
tr.buyrambytes({
payer: payer.name,
receiver: this.name,
function getAccountName(data) {
let {ecc} = Eos.modules;
let isValidPrivateKey = ecc.isValidPrivate(data);
if(!isValidPrivateKey){
Toast.show(invalidPriKey,{
position: 200,
});
return false
}
let accountPublicKey = ecc.privateToPublic(data);
const eos = GetEOS(data);
return eos.getKeyAccounts( {'public_key':accountPublicKey} ).then(( result ,error ) => {
return result;
}).catch(err=>{
Toast.show(somethingWrong,{
position: 200,
});
import Plugin from '../Plugin';
import * as PluginTypes from '../PluginTypes';
import {Blockchains} from '../../models/Blockchains'
import Network from '../../models/Network'
import Account from '../../models/Account'
import KeyPairService from '../../services/secure/KeyPairService'
import {localized, localizedState} from '../../localization/locales'
import LANG_KEYS from '../../localization/keys'
import Eos from 'eosjs'
let {ecc} = Eos.modules;
import ObjectHelpers from '../../util/ObjectHelpers'
import {Popup} from '../../models/popups/Popup'
import PopupService from '../../services/utility/PopupService'
import StorageService from '../../services/utility/StorageService'
import * as Actions from '../../models/api/ApiActions';
import * as StoreActions from '../../store/constants'
import { Api, JsonRpc, RpcError, JsSignatureProvider } from 'eosjs2';
import * as numeric from "eosjs2/dist/eosjs-numeric";
import Token from "../../models/Token";
import AccountAction from "../../models/AccountAction";
import AccountService from "../../services/blockchain/AccountService";
import HardwareService from "../../services/secure/HardwareService";
import HistoricAction from "../../models/histories/HistoricAction";
import StoreService from "../../services/utility/StoreService";
import Eos from 'eosjs';
const {ecc} = Eos.modules;
import murmur from 'murmurhash';
import {Blockchains} from "../../models/Blockchains";
import PluginRepository from "../../plugins/PluginRepository";
import {remote} from '../../util/ElectronHelpers';
import BackendApiService from "../apis/BackendApiService";
const NodeMachineId = () => remote ? remote.getGlobal('appShared').NodeMachineId : null;
const fingerprinted = s => murmur.v2(s);
export default class EosAccountService {
static async allowsFreeAccounts(network){
const eos = Eos({httpEndpoint:network.fullhost(), chainId:network.chainId});
const getRows = id => {
return eos.getTableRows({
async checkTableRange (code, tableName, scope, from, length = 1, index_position = 1) {
if (length < 0) {
throw new Error(`range error: length(${length}) must larger than 0 `)
}
let rows = await this.checkTable(code, tableName, scope, length, from, (typeof from === 'number') ? from + length : new BN(EOS.modules.format.encodeName(from, false)).plus(length).toString(), index_position)
return rows
}