All files / src index.js

100% Statements 41/41
90.91% Branches 10/11
100% Functions 2/2
100% Lines 41/41

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 709x 9x   9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x       24x     24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x       24x 24x 24x 24x 24x 24x                   9x   9x                    
const { Api, JsonRpc } = require('eosjs');
const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig');
 
const fetch = require('node-fetch');
const { TextDecoder, TextEncoder } = require('text-encoding');
const accounts = require('./accounts');
const cpu = require('./tokens/cpu');
const compose = require('./compose');
const createbridge = require('./createbridge');
const crypto = require('./modules/crypto');
const eos = require('./eos');
const errors = require('./errors');
const helpers = require('./helpers');
const instrument = require('./instrument');
const ore = require('./tokens/ore');
const oreStandardToken = require('./orestandardtoken');
const rightsRegistry = require('./rightsregistry');
const usageLog = require('./usagelog');
const verifier = require('./verifier');
 
class Orejs {
  constructor(config = {}) {
    this.constructEos(config);
 
    /* Mixins */
    Object.assign(this, accounts);
    Object.assign(this, compose);
    Object.assign(this, cpu);
    Object.assign(this, createbridge);
    Object.assign(this, crypto);
    Object.assign(this, eos);
    Object.assign(this, errors);
    Object.assign(this, helpers);
    Object.assign(this, instrument);
    Object.assign(this, ore);
    Object.assign(this, oreStandardToken);
    Object.assign(this, rightsRegistry);
    Object.assign(this, usageLog);
    Object.assign(this, verifier);
  }
 
  constructEos(config) {
    this.config = config;
    this.chainName = config.chainName || 'ore'; // ore || eos
    this.unusedAccountPubKey = config.unusedAccountPubKey || null;
    this.rpc = new JsonRpc(config.httpEndpoint, { fetch: config.fetch || fetch });
    this.signatureProvider = config.signatureProvider || new JsSignatureProvider(config.privateKeys || []);
    this.eos = new Api({
      chainId: config.chainId,
      rpc: this.rpc,
      signatureProvider: this.signatureProvider,
      textEncoder: new TextEncoder(),
      textDecoder: new TextDecoder()
    });
  }
}
 
const generateAccountNameString = accounts.generateAccountNameString;
 
module.exports = {
  compose,
  crypto,
  errors,
  generateAccountNameString,
  hexToUint8Array: eos.hexToUint8Array,
  isValidPublicKey: eos.isValidPublicKey,
  Orejs,
  JsSignatureProvider
};