How to use the eosjs.modules function in eosjs

To help you get started, we’ve selected a few eosjs 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 bagaking / eosplayer / src / types / libs.ts View on Github external
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)
github SocialXNetwork / socialx_react_native / packages / api-blockchain / src / api / index.ts View on Github external
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,
};
github LimeChain / eoslime / src / account / account-factory.js View on Github external
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);
    }
github LimeChain / eoslime / src / account / normal-account / account.js View on Github external
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,
github eosiosg / pomelo / src / pages / HomePage / saga.js View on Github external
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,
      });
github GetScatter / ScatterDesktop / src / plugins / defaults / eos.js View on Github external
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";
github GetScatter / ScatterDesktop / src / services / blockchain / EosAccountService.js View on Github external
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({
github bagaking / eosplayer / src / helpers / chain.js View on Github external
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
  }